summaryrefslogtreecommitdiffstats
path: root/source4/lib/talloc/talloc.h
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2007-04-27 21:09:16 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:51:39 -0500
commitb06fc3b53c2f17cfa3f86ef1472a5778400c0fc9 (patch)
tree8b9b1c17953c224b23ea335a0167e74e5f57c6b5 /source4/lib/talloc/talloc.h
parent5a616802ff076814f0a105d64a469365aea6910a (diff)
downloadsamba-b06fc3b53c2f17cfa3f86ef1472a5778400c0fc9.tar.gz
samba-b06fc3b53c2f17cfa3f86ef1472a5778400c0fc9.tar.xz
samba-b06fc3b53c2f17cfa3f86ef1472a5778400c0fc9.zip
r22539: Added _strict varients of the talloc calls to
return NULL on size == 0 varients. Jeremy. (This used to be commit 1ef269067ca501e2a4ded4ca8654c6a6cc26f385)
Diffstat (limited to 'source4/lib/talloc/talloc.h')
-rw-r--r--source4/lib/talloc/talloc.h10
1 files changed, 9 insertions, 1 deletions
diff --git a/source4/lib/talloc/talloc.h b/source4/lib/talloc/talloc.h
index 195c6c25b6d..fde2ddc0d88 100644
--- a/source4/lib/talloc/talloc.h
+++ b/source4/lib/talloc/talloc.h
@@ -89,10 +89,16 @@ typedef void TALLOC_CTX;
#define talloc_new(ctx) talloc_named_const(ctx, 0, "talloc_new: " __location__)
#define talloc_zero(ctx, type) (type *)_talloc_zero(ctx, sizeof(type), #type)
+/* Varient of talloc_zero that returns NULL if size is zero. */
+#define talloc_zero_strict(ctx, type) (type *)_talloc_zero_strict(ctx, sizeof(type), #type)
#define talloc_zero_size(ctx, size) _talloc_zero(ctx, size, __location__)
#define talloc_zero_array(ctx, type, count) (type *)_talloc_zero_array(ctx, sizeof(type), count, #type)
+/* Varient of talloc_zero_array that returns NULL if count is zero. */
+#define talloc_zero_array_strict(ctx, type, count) (type *)_talloc_zero_array_strict(ctx, sizeof(type), count, #type)
#define talloc_array(ctx, type, count) (type *)_talloc_array(ctx, sizeof(type), count, #type)
+/* Varient of talloc_array that returns NULL if count is zero. */
+#define talloc_array_strict(ctx, type, count) (type *)_talloc_array_strict(ctx, sizeof(type), count, #type)
#define talloc_array_size(ctx, size, count) _talloc_array(ctx, size, count, __location__)
#define talloc_array_ptrtype(ctx, ptr, count) (_TALLOC_TYPEOF(ptr))talloc_array_size(ctx, sizeof(*(ptr)), count)
@@ -100,6 +106,8 @@ typedef void TALLOC_CTX;
#define talloc_realloc_size(ctx, ptr, size) _talloc_realloc(ctx, ptr, size, __location__)
#define talloc_memdup(t, p, size) _talloc_memdup(t, p, size, __location__)
+/* Varient of talloc_memdup that returns NULL if count is zero. */
+#define talloc_memdup_strict(t, p, size) _talloc_memdup_strict(t, p, size, __location__)
#define talloc_set_type(ptr, type) talloc_set_name_const(ptr, #type)
#define talloc_get_type(ptr, type) (type *)talloc_check_name(ptr, #type)
@@ -169,6 +177,6 @@ size_t talloc_get_size(const void *ctx);
void *talloc_find_parent_byname(const void *ctx, const char *name);
void talloc_show_parents(const void *context, FILE *file);
int talloc_is_parent(const void *context, const void *ptr);
+void *talloc_strict(const void *context, size_t size, const char *name);
#endif
-