[Freeciv-Dev] newbie C question
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Will pointers always be initialized to NULL? I seem to remember reading
that somewhere, but maybe that wasn't about C :)
In other words, are these safe:
char *ptr;
if (ptr!=NULL) free(ptr);
or
char *ptr;
fc_realloc(ptr, 4096);
or
struct mystruct *ptr;
fc_malloc(ptr, 11 * sizeof(&ptr));
if (ptr[0]->ptr!=NULL) free(ptr[0]->ptr);
If not, how about this:
struct mystruct *ptr;
fc_calloc(ptr, 11 * sizeof(&ptr));
if (ptr[0]->ptr!=NULL) free(ptr[0]->ptr);
Yours,
Per
"What we anticipate seldom occurs: but what we least expect generally
happens." -- Benjamin Disraeli
|
|