AmendHub

Download:

jcs

/

subtext

/

amendments

/

448

util: No longer warn() when xmalloc fails, callers handle it now

Also panic when xfree() is called on a pointer to NULL, it's never ok.

jcs made amendment 448 about 1 year ago
--- util.c Tue Mar 7 22:54:53 2023 +++ util.c Sun Mar 26 22:10:00 2023 @@ -116,8 +116,10 @@ xmalloc(size_t size) panic("xmalloc: zero size"); ptr = NewPtr(size); +#if 0 if (ptr == NULL) warn("Insufficient memory available: xmalloc(%lu) failed", size); +#endif return ptr; } @@ -132,10 +134,8 @@ xfree(void *ptrptr) panic("xfree(NULL)"); ptr = (void *)*addr; - if (ptr == NULL) { - warn("xfree(&NULL) likely a double-free"); - return; - } + if (ptr == NULL) + panic("xfree(&NULL) likely a double-free"); DisposePtr(ptr); *addr = 0L;