summaryrefslogtreecommitdiff
path: root/lib/talloc/talloc.h
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2025-07-29 14:50:40 +0200
committerVolker Lendecke <vl@samba.org>2025-09-02 08:08:29 +0000
commit51d05da70e8461834396d361eead807127751b76 (patch)
tree942909702f638ed54858f96025d55f68e10b3b7f /lib/talloc/talloc.h
parent5b28822d9be81dae7a8341cc359c6e79498df241 (diff)
downloadsamba-talloc-2.4.4.tar.gz
samba-talloc-2.4.4.tar.bz2
samba-talloc-2.4.4.zip
lib: Add talloc_realloc_zero()talloc-2.4.4
Like talloc_realloc, zeroing out expanded memory Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Anoop C S <anoopcs@samba.org>
Diffstat (limited to 'lib/talloc/talloc.h')
-rw-r--r--lib/talloc/talloc.h33
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/talloc/talloc.h b/lib/talloc/talloc.h
index eef1a701b1f..62142d188f1 100644
--- a/lib/talloc/talloc.h
+++ b/lib/talloc/talloc.h
@@ -1298,6 +1298,39 @@ _PUBLIC_ void *_talloc_realloc_array(const void *ctx, void *ptr, size_t el_size,
#ifdef DOXYGEN
/**
+ * @brief Change the size of a talloc array, zero out additional space.
+ *
+ * Same as talloc_realloc() with the additional behavior to zero out
+ * code in case the array is expanded.
+ *
+ * @param[in] ctx The parent context used if ptr is NULL.
+ *
+ * @param[in] ptr The chunk to be resized.
+ *
+ * @param[in] type The type of the array element inside ptr.
+ *
+ * @param[in] count The intended number of array elements.
+ *
+ * @return The new array, NULL on error. The call will fail either
+ * due to a lack of memory, or because the pointer has more
+ * than one parent (see talloc_reference()).
+ */
+_PUBLIC_ void *talloc_realloc_zero(const void *ctx,
+ void *ptr,
+ #type,
+ size_t count);
+#else
+#define talloc_realloc_zero(ctx, p, type, count) \
+ (type *)_talloc_realloc_array_zero(ctx, p, sizeof(type), count, #type)
+_PUBLIC_ void *_talloc_realloc_array_zero(const void *ctx,
+ void *ptr,
+ size_t el_size,
+ unsigned count,
+ const char *name);
+#endif
+
+#ifdef DOXYGEN
+/**
* @brief Untyped realloc to change the size of a talloc array.
*
* The macro is useful when the type is not known so the typesafe