]> mj.ucw.cz Git - libucw.git/commitdiff
Growing arrays: GARY_FREE(NULL) does nothing
authorMartin Mares <mj@ucw.cz>
Fri, 30 Jul 2010 17:00:49 +0000 (19:00 +0200)
committerMartin Mares <mj@ucw.cz>
Wed, 18 Aug 2010 16:12:17 +0000 (18:12 +0200)
ucw/gary.h

index 386dd765cc913a7557b5f27e770b31f01bdf2df1..98fb26ffac1e97f323b93829358746b559299f47 100644 (file)
@@ -18,7 +18,7 @@ struct gary_hdr {
 #define GARY_BODY(ptr) ((byte *)(ptr) + GARY_HDR_SIZE)
 
 #define GARY_INIT(ptr, n) (ptr) = gary_init(sizeof(*(ptr)), (n))
-#define GARY_FREE(ptr) xfree(GARY_HDR(ptr))
+#define GARY_FREE(ptr) do { if (ptr) xfree(GARY_HDR(ptr)); } while (0)
 #define GARY_SIZE(ptr) (GARY_HDR(ptr)->num_elts)
 #define GARY_SET_SIZE(ptr, n) (ptr) = gary_set_size((ptr), (n))