From 844507a094f555ded0d25ed5c8b91c768cad0dfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= Date: Wed, 12 Mar 2025 21:30:43 +0100 Subject: [PATCH] ta: add talloc_zero_ptrtype Convenience macro. I was searching for it few times already, so probably good to just add it. --- ta/ta.h | 4 ++++ ta/ta_talloc.h | 1 + 2 files changed, 5 insertions(+) diff --git a/ta/ta.h b/ta/ta.h index 4fbb0635e2..efe4945fb2 100644 --- a/ta/ta.h +++ b/ta/ta.h @@ -91,6 +91,9 @@ bool ta_vasprintf_append_buffer(char **str, const char *fmt, va_list ap) TA_PRF( #define ta_new_ptrtype(ta_parent, ptr) \ (TA_TYPEOF(ptr))ta_alloc_size(ta_parent, sizeof(*ptr)) +#define ta_znew_ptrtype(ta_parent, ptr) \ + (TA_TYPEOF(ptr))ta_zalloc_size(ta_parent, sizeof(*ptr)) + #define ta_new_array_ptrtype(ta_parent, ptr, count) \ (TA_TYPEOF(ptr))ta_new_array_size(ta_parent, sizeof(*(ptr)), count) @@ -133,6 +136,7 @@ bool ta_vasprintf_append_buffer(char **str, const char *fmt, va_list ap) TA_PRF( #define ta_xznew_array(...) ta_oom_g(ta_znew_array(__VA_ARGS__)) #define ta_xnew_array_size(...) ta_oom_p(ta_new_array_size(__VA_ARGS__)) #define ta_xnew_ptrtype(...) ta_oom_g(ta_new_ptrtype(__VA_ARGS__)) +#define ta_xznew_ptrtype(...) ta_oom_g(ta_znew_ptrtype(__VA_ARGS__)) #define ta_xnew_array_ptrtype(...) ta_oom_g(ta_new_array_ptrtype(__VA_ARGS__)) #define ta_xdup(...) ta_oom_g(ta_dup(__VA_ARGS__)) diff --git a/ta/ta_talloc.h b/ta/ta_talloc.h index 5cbc5c1c56..8291fa5bc3 100644 --- a/ta/ta_talloc.h +++ b/ta/ta_talloc.h @@ -32,6 +32,7 @@ #define talloc_array_size ta_xnew_array_size #define talloc_realloc ta_xrealloc #define talloc_ptrtype ta_xnew_ptrtype +#define talloc_zero_ptrtype ta_xznew_ptrtype #define talloc_array_ptrtype ta_xnew_array_ptrtype #define talloc_steal ta_steal