aboutsummaryrefslogtreecommitdiffstats
path: root/common.h
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2021-04-02 22:47:53 +0200
committerMattias Andrée <maandree@kth.se>2021-04-02 22:47:53 +0200
commitd161aa539a449cc6fa66fb73ad54f997bcd49b13 (patch)
treee59a18a53191c148fc372a7cbbc82cd000bbfadc /common.h
parentAdd full name, use separate fields for birthday componets and add when leapies celebrate on common years (diff)
downloadlibcontacts-d161aa539a449cc6fa66fb73ad54f997bcd49b13.tar.gz
libcontacts-d161aa539a449cc6fa66fb73ad54f997bcd49b13.tar.bz2
libcontacts-d161aa539a449cc6fa66fb73ad54f997bcd49b13.tar.xz
Fix parsing and memory leaks
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'common.h')
-rw-r--r--common.h22
1 files changed, 18 insertions, 4 deletions
diff --git a/common.h b/common.h
index d74dde5..ab021cc 100644
--- a/common.h
+++ b/common.h
@@ -7,6 +7,7 @@
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
+#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -16,12 +17,25 @@
#define TIME_MAX ((time_t)((1ULL << (8 * sizeof(time_t) - 1)) - 1ULL))
-#define DESTROY_ALL(LIST, FUNC)\
+#define DESTROY_ALL_OBJECTS(LIST, FUNC)\
do {\
- void *destroy_all_temp__;\
- if ((destroy_all_temp__ = (LIST))) {\
- for (; *(LIST); (LIST)++)\
+ void *destroy_all_temp__ = (LIST);\
+ if (destroy_all_temp__) {\
+ for (; *(LIST); (LIST)++) {\
FUNC(*(LIST));\
+ free(*(LIST));\
+ }\
+ free(destroy_all_temp__);\
+ }\
+ } while (0)
+
+
+#define DESTROY_ALL_STRINGS(LIST)\
+ do {\
+ void *destroy_all_temp__ = (LIST);\
+ if (destroy_all_temp__) {\
+ for (; *(LIST); (LIST)++)\
+ free(*(LIST));\
free(destroy_all_temp__);\
}\
} while (0)