summaryrefslogtreecommitdiff
path: root/wintable/new/util.h
diff options
context:
space:
mode:
Diffstat (limited to 'wintable/new/util.h')
-rw-r--r--wintable/new/util.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/wintable/new/util.h b/wintable/new/util.h
index 7ed8e98..470cef5 100644
--- a/wintable/new/util.h
+++ b/wintable/new/util.h
@@ -15,7 +15,7 @@ static BOOL runHandlers(const handlerfunc list[], struct table *t, UINT uMsg, WP
// memory allocation stuff
// each of these functions do an implicit ZeroMemory()
-// these also make tableRealloc(NULL, ...) act like realloc(NULL, ...) (that is, same as tableAlloc(...)/malloc(...))
+// these also make tableRealloc(NULL, ...)/tableFree(NULL) act like realloc(NULL, ...)/free(NULL) (that is, same as tableAlloc(...)/malloc(...) and a no-op, respectively)
// we're using LocalAlloc() because:
// - whether the malloc() family supports the last-error code is undefined
// - the HeapAlloc() family DOES NOT support the last-error code; you're supposed to use Windows exceptions, and I can't find a clean way to do this with MinGW-w64 that doesn't rely on inline assembly or external libraries (unless they added __try/__except blocks)
@@ -46,6 +46,8 @@ static void *tableRealloc(void *p, size_t size, const char *panicMessage)
static void tableFree(void *p, const char *panicMessage)
{
+ if (p == NULL)
+ return;
if (LocalFree((HLOCAL) p) != NULL)
panic(panicMessage);
}