mirror of https://github.com/ipxe/ipxe.git
Switch from calloc() to malloc()+memset() to match the practices used
almost everywhere else.pull/1/head
parent
48fe701716
commit
06630a3036
|
@ -178,9 +178,12 @@ struct pk_buff * netdev_rx_dequeue ( struct net_device *netdev ) {
|
||||||
*/
|
*/
|
||||||
struct net_device * alloc_netdev ( size_t priv_size ) {
|
struct net_device * alloc_netdev ( size_t priv_size ) {
|
||||||
struct net_device *netdev;
|
struct net_device *netdev;
|
||||||
|
size_t total_len;
|
||||||
|
|
||||||
netdev = calloc ( 1, sizeof ( *netdev ) + priv_size );
|
total_len = ( sizeof ( *netdev ) + priv_size );
|
||||||
|
netdev = malloc ( total_len );
|
||||||
if ( netdev ) {
|
if ( netdev ) {
|
||||||
|
memset ( netdev, 0, total_len );
|
||||||
INIT_LIST_HEAD ( &netdev->references );
|
INIT_LIST_HEAD ( &netdev->references );
|
||||||
INIT_LIST_HEAD ( &netdev->tx_queue );
|
INIT_LIST_HEAD ( &netdev->tx_queue );
|
||||||
INIT_LIST_HEAD ( &netdev->rx_queue );
|
INIT_LIST_HEAD ( &netdev->rx_queue );
|
||||||
|
|
|
@ -149,9 +149,10 @@ tcp_dump_flags ( struct tcp_connection *conn, unsigned int flags ) {
|
||||||
static struct tcp_connection * alloc_tcp ( void ) {
|
static struct tcp_connection * alloc_tcp ( void ) {
|
||||||
struct tcp_connection *conn;
|
struct tcp_connection *conn;
|
||||||
|
|
||||||
conn = calloc ( 1, sizeof ( *conn ) );
|
conn = malloc ( sizeof ( *conn ) );
|
||||||
if ( conn ) {
|
if ( conn ) {
|
||||||
DBGC ( conn, "TCP %p allocated\n", conn );
|
DBGC ( conn, "TCP %p allocated\n", conn );
|
||||||
|
memset ( conn, 0, sizeof ( *conn ) );
|
||||||
conn->tcp_state = conn->prev_tcp_state = TCP_CLOSED;
|
conn->tcp_state = conn->prev_tcp_state = TCP_CLOSED;
|
||||||
conn->snd_seq = random();
|
conn->snd_seq = random();
|
||||||
conn->timer.expired = tcp_expired;
|
conn->timer.expired = tcp_expired;
|
||||||
|
|
Loading…
Reference in New Issue