History

ta: add talloc_zero_ptrtype

Convenience macro. I was searching for it few times already, so probably good to just add it.

Kacper Michajłow committed 1 year ago

Commit 844507a1 parent ae3420f2 files · +5 −0Browse files

Unified · Split

2 files
  1. ta/ta.h +4 −0
  2. ta/ta_talloc.h +1 −0
ta/ta.h+4−0
@@ -91,6 +91,9 @@ bool ta_vasprintf_append_buffer(char **str, const char *fmt, va_list ap) TA_PRF( · 90 unmodified lines
9191 #define ta_new_ptrtype(ta_parent, ptr) \
9292 (TA_TYPEOF(ptr))ta_alloc_size(ta_parent, sizeof(*ptr))
9393
94+#define ta_znew_ptrtype(ta_parent, ptr) \
95+ (TA_TYPEOF(ptr))ta_zalloc_size(ta_parent, sizeof(*ptr))
96+
9497 #define ta_new_array_ptrtype(ta_parent, ptr, count) \
9598 (TA_TYPEOF(ptr))ta_new_array_size(ta_parent, sizeof(*(ptr)), count)
9699
@@ -133,6 +136,7 @@ bool ta_vasprintf_append_buffer(char **str, const char *fmt, va_list ap) TA_PRF( · 36 unmodified lines
133136 #define ta_xznew_array(...) ta_oom_g(ta_znew_array(__VA_ARGS__))
134137 #define ta_xnew_array_size(...) ta_oom_p(ta_new_array_size(__VA_ARGS__))
135138 #define ta_xnew_ptrtype(...) ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
139+#define ta_xznew_ptrtype(...) ta_oom_g(ta_znew_ptrtype(__VA_ARGS__))
136140 #define ta_xnew_array_ptrtype(...) ta_oom_g(ta_new_array_ptrtype(__VA_ARGS__))
137141 #define ta_xdup(...) ta_oom_g(ta_dup(__VA_ARGS__))
138142
ta/ta_talloc.h+1−0
@@ -32,6 +32,7 @@ · 31 unmodified lines
3232 #define talloc_array_size ta_xnew_array_size
3333 #define talloc_realloc ta_xrealloc
3434 #define talloc_ptrtype ta_xnew_ptrtype
35+#define talloc_zero_ptrtype ta_xznew_ptrtype
3536 #define talloc_array_ptrtype ta_xnew_array_ptrtype
3637
3738 #define talloc_steal ta_steal

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t