diff options
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) |