From e30f9c972b789152d67ff34fd3bda294d20d1f51 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Tue, 27 Nov 2018 16:33:28 +0900 Subject: [PATCH] util: define free_func_t --- src/basic/alloc-util.h | 2 ++ src/basic/static-destruct.h | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/basic/alloc-util.h b/src/basic/alloc-util.h index 2a6deb12ca..7d237720b9 100644 --- a/src/basic/alloc-util.h +++ b/src/basic/alloc-util.h @@ -8,6 +8,8 @@ #include "macro.h" +typedef void (*free_func_t)(void *p); + #define new(t, n) ((t*) malloc_multiply(sizeof(t), (n))) #define new0(t, n) ((t*) calloc((n), sizeof(t))) diff --git a/src/basic/static-destruct.h b/src/basic/static-destruct.h index cad838083f..4a9a40a835 100644 --- a/src/basic/static-destruct.h +++ b/src/basic/static-destruct.h @@ -1,5 +1,6 @@ #pragma once +#include "alloc-util.h" #include "macro.h" /* A framework for registering static variables that shall be freed on shutdown of a process. It's a bit like gcc's @@ -9,7 +10,7 @@ typedef struct StaticDestructor { void *data; - void (*destroy)(void *p); + free_func_t destroy; } StaticDestructor; #define STATIC_DESTRUCTOR_REGISTER(variable, func) \ -- 2.25.1