diff options
author | Mattias Andrée <maandree@kth.se> | 2021-04-02 22:47:53 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2021-04-02 22:47:53 +0200 |
commit | d161aa539a449cc6fa66fb73ad54f997bcd49b13 (patch) | |
tree | e59a18a53191c148fc372a7cbbc82cd000bbfadc /common.h | |
parent | Add full name, use separate fields for birthday componets and add when leapies celebrate on common years (diff) | |
download | libcontacts-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 '')
-rw-r--r-- | common.h | 22 |
1 files changed, 18 insertions, 4 deletions
@@ -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) |