Is this pointer initialization necessary?

Posted by bstullkid on Stack Overflow See other posts from Stack Overflow or by bstullkid
Published on 2010-05-14T20:21:10Z Indexed on 2010/05/14 20:24 UTC
Read the original article Hit count: 238

Filed under:
|
|

Lets say I have the following:

 CHARLINK * _init_link(CHARLINK **link)
 {
    short i;
    (*link)->cl = (CHARLINK **) calloc(NUM_CHARS, sizeof(CHARLINK *));
    for (i = 0; i < NUM_CHARS; i++)
        (*link)->cl[i] = NULL;
    return (*link);
}

Is the loop to initialize each element to NULL necessary or are they automatically NULL from calloc?

© Stack Overflow or respective owner

Related posts about c

    Related posts about malloc