4 ms·
> 1. printf may malloc so don't use it in an out of memory situation. Though I think this problem is vanishingly unlikely these days. You can avoid this by doi
by luke0016 7y ago
> 1. printf may malloc so don't use it in an out of memory situation. Though I think this problem is vanishingly unlikely these days.
You can avoid this by doing something like:
setvbuf(stdout, NULL, _IONBF, 0);
- saagarjha 7y agoYou sure about that? This seems to suggest otherwise: https://sourceware.org/git/?p=glibc.git;a=blob;f=stdio-common/vfprintf-internal.c;h=547a3a868b4668bf615cf3f39a92e3c11cbb98ad;hb=HEAD#l1343 https://sourceware.org/git/?p=glibc.git;a=blob;f=stdio-commo...
- crististm 7y agoIt will allocate a buffer on the stack: https://sourceware.org/git/?p=glibc.git;a=blob;f=stdio-common/vfprintf-internal.c;h=547a3a868b4668bf615cf3f39a92e3c11cbb98ad;hb=HEAD#l2346 https://sourceware.org/git/?p=glibc.git;a=blob;f=stdio-commo...