Re:“I'm basically giving myself a permanent vacation from be...
by shakna on Thursday July 12, 2018 @06:25PM
(#17519127)
It's handy in C for guarding parts of the language, as you often have to check return values anyway.
[ Parent
| on HN ]
Re:“I'm basically giving myself a permanent vacation from be...
by the-dude on Thursday July 12, 2018 @06:56PM
(#17519309)
Missing assingment.
Re:“I'm basically giving myself a permanent vacation from be...
by shakna on Thursday July 12, 2018 @07:34PM
(#17519481)
int success = NULL;
if(success = malloc(...)) {
}
if(success = malloc(...)) {
}
if(success = malloc(...)) {
}
Re:“I'm basically giving myself a permanent vacation from be...
by slavik81 on Thursday July 12, 2018 @08:39PM
(#17519737)
That will result in undefined behaviour if the value returned by malloc is greater than INT_MAX. If you really need an integer, use intptr_t. But, generally it makes more sense to just use a pointer.
char* p = NULL;
if (p = malloc(...)) {
...
}