I decided to test this out on my own computer using this code:
Here's the results:
#define MB (1024 * 1024)
int main(int argc, char *argv)
char *mem = NULL;
long long unsigned int size = MB * 512;
if((mem = malloc(size)) != NULL)
printf("Successfully allocated and freed %llu bytes!\n", size);
printf("Unable to allocate %llu bytes. Resize and try again!\n", size);
size += MB * 512;
It worked! It properly failed and reported it...
Successfully allocated and freed 536870912 bytes!
Successfully allocated and freed 1073741824 bytes!
Successfully allocated and freed 1610612736 bytes!
Successfully allocated and freed 2147483648 bytes!
Unable to allocate 2684354560 bytes. Resize and try again!
BTW, I only have 512mb ram. So this issue would actually come up if I were having to use too intensive of an application. I would much rather it give me a message like this than bail without saving my work.
But like I said, I haven't looked in the pulse code so I have no idea what context it's being used. But the generic argument that it's pointless not to bail from a failed malloc is wrong. Please don't write code that is going to destroy peoples work without warning.