X-Git-Url: https://plomlompom.com/repos/berlin_corona.txt?a=blobdiff_plain;f=src%2Fcommon%2Ftry_malloc.c;h=41d80c9db1402a07bae04636346a82617e6e28e4;hb=491e8bc8e7a9b1d312256817c0b8be7e05b127be;hp=70392be27618c8c3a0dba5c4cc40dd4118702721;hpb=483f25751ae49c810456faf0bb7a375bc437df10;p=plomrogue diff --git a/src/common/try_malloc.c b/src/common/try_malloc.c index 70392be..41d80c9 100644 --- a/src/common/try_malloc.c +++ b/src/common/try_malloc.c @@ -9,16 +9,16 @@ -extern void * try_malloc(size_t size, char * f) +extern void * try_malloc(size_t size, const char * f) { - char * prefix = "Trouble with malloc() in "; + char * prefix = "Trouble with malloc in "; char * msg = malloc(strlen(prefix) + strlen(f) + 1 + 1); - exit_err(NULL == msg, - "Trouble in try_malloc() with malloc() for error message string."); + exit_err(!msg, + "Trouble in try_malloc with malloc for error message string."); int test = sprintf(msg, "%s%s.", prefix, f); - exit_err(test < 0, "Trouble in try_malloc() with sprintf()."); + exit_err(test < 0, "Trouble in try_malloc with sprintf."); void * p = malloc(size); - exit_err(NULL == p, msg); /* Bypass exit_trouble() calling try_malloc(). */ + exit_err(!p, msg); /* Bypass exit_trouble() calling try_malloc(). */ free(msg); return p; }