summaryrefslogtreecommitdiff
path: root/wintable
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-12-12 10:55:57 -0500
committerPietro Gagliardi <[email protected]>2014-12-12 10:55:57 -0500
commitddb4533affe337000b305be955284f244b99b97c (patch)
tree21eca43790e0e54db96f5cd88c9d7276c99cb18c /wintable
parent9e11c36f63c04e16f1d1a42a05ec545b2793ce65 (diff)
Defined tableFree(NULL).
Diffstat (limited to 'wintable')
-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);
}