summaryrefslogtreecommitdiff
path: root/source4/lib
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2004-10-19 06:29:41 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:01:53 -0500
commit53e30b391d6f6704d365bbf956a2aa2ef8451000 (patch)
tree06b6ee2fe49d8a3d80a32e65734ae918bd42b87c /source4/lib
parent06fe5d6cd92bbf87f80c3df305d136760d0f91d8 (diff)
downloadsamba-53e30b391d6f6704d365bbf956a2aa2ef8451000.tar.gz
samba-53e30b391d6f6704d365bbf956a2aa2ef8451000.tar.bz2
samba-53e30b391d6f6704d365bbf956a2aa2ef8451000.zip
r3052: added talloc_zero_p() and talloc_zero_array_p() calls, for allocating zeroed memory
(This used to be commit 65b7316e9b4589b02a8bd94150ccbfe526f6d159)
Diffstat (limited to 'source4/lib')
-rw-r--r--source4/lib/talloc.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/source4/lib/talloc.c b/source4/lib/talloc.c
index 5c1f3e7dcd..12b21d21e6 100644
--- a/source4/lib/talloc.c
+++ b/source4/lib/talloc.c
@@ -776,9 +776,9 @@ void talloc_enable_leak_report_full(void)
/*
talloc and zero memory.
*/
-void *talloc_zero(const void *ctx, size_t size)
+void *_talloc_zero(const void *ctx, size_t size, const char *name)
{
- void *p = talloc(ctx, size);
+ void *p = talloc_named_const(ctx, size, name);
if (p) {
memset(p, '\0', size);
@@ -939,6 +939,17 @@ void *talloc_array(const void *ctx, size_t el_size, unsigned count, const char *
return talloc_named_const(ctx, el_size * count, name);
}
+/*
+ alloc an zero array, checking for integer overflow in the array size
+*/
+void *talloc_zero_array(const void *ctx, size_t el_size, unsigned count, const char *name)
+{
+ if (count >= MAX_TALLOC_SIZE/el_size) {
+ return NULL;
+ }
+ return _talloc_zero(ctx, el_size * count, name);
+}
+
/*
realloc an array, checking for integer overflow in the array size