Is it wrong to allocate memory as follows:
FOO *foo; while (!(foo = malloc(sizeof(FOO)))) ;
I do not know about bad practice, but this is unusual. malloc()crashes usually indicate serious system problems that your program is unlikely to recover from. If your system is different, your example can be very practical.
malloc()
NB - this answer assumes that it sizeof(FOO)is "reasonable" and that yours are malloc()not just refusing because you are requesting too much memory.
sizeof(FOO)
"" malloc(). malloc NULL, , (, ). .
NULL
, Linux:
Linux . , malloc() -NULL, , .
, , malloc - -NULL, - Linux -NULL , -, .
, .