summaryrefslogtreecommitdiffstats
path: root/XAlloc.c
AgeCommit message (Collapse)Author
2020-08-21Introduce xAsprintf as checked version of asprintfChristian Göttsche
2017-07-27Security review: check results of snprintf.Hisham Muhammad
Calls marked with xSnprintf shouldn't fail. Abort program cleanly if any of them does.
2016-06-03Fix xStrdup debug build failure & allow Clang to use ((nonnull))Explorer09
2016-06-02Add assert and __attribute__((nonnull)) on xStrdupExplorer09
__attribute__((nonnull)) will help catching "calling with NULL" mistake on compile time. I also convert xStrdup into a macro, that will do assert() inline when the code is *not* built with -DNDEBUG . For release builds (with -DNDEBUG), preprocessor trick will ensure that generated code remains the same.
2016-06-02Don't check if (!str) in xStrdupExplorer09
This effectively reverts "Stricter strdup." 4674b4a7320bb6b003a4e3b3840027573691e60d If str is NULL upon the calling of strdup(), it should crash with SIGSEGV. Just let it crash. Adding the "if (!str) fail();" code serves nothing but bloat.
2016-05-30Stricter strdup.Hisham
2016-03-11Revert 5c593fae4227651075cfc9445f17dad6ae0a0b47 (xCalloc)Explorer09
calloc() allows 'nmemb' or 'size' to be zero, in which case NULL may be returned. Letting htop die because of either argument being zero doesn't make sense. As a side note: As size_t is unsigned, compiler should be able to optimize conditional (nmemb > 0 && size > 0) to (nmemb && size). This theorically shouldn't increase code size too much.
2016-02-03Shorten the code using the err() function.Hisham
2016-02-03Be stricter!Hisham
2016-02-02Exit on failure!Hisham
2016-02-02Check for failure in allocations.Hisham
2016-01-31Add allocation testsHisham