From e159e42d8472f36f51e400e351fc43f2a7dc44f5 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 6 Jan 2005 03:20:56 +0000 Subject: r4550: talloc() is now typesafe. It is exactly equivalent to the old talloc_p() macro. Use talloc_size() if you want the old behaviour. I have kept talloc_p() as an alias for now. Once we change all calls to be plain talloc() then we can remove it. (This used to be commit 2011bbeb841fd6bfccf3d44a49f79203f7f55baa) --- source4/lib/talloc/talloc.c | 4 ++-- source4/lib/talloc/talloc.h | 4 ++-- source4/lib/talloc/talloc_guide.txt | 40 ++++++++++++++++++------------------- source4/lib/talloc/testsuite.c | 4 ++-- 4 files changed, 26 insertions(+), 26 deletions(-) (limited to 'source4/lib/talloc') diff --git a/source4/lib/talloc/talloc.c b/source4/lib/talloc/talloc.c index 9e8868191f..bcadf40cfb 100644 --- a/source4/lib/talloc/talloc.c +++ b/source4/lib/talloc/talloc.c @@ -857,7 +857,7 @@ char *talloc_strndup(const void *t, const char *p, size_t n) for (len=0; p[len] && len talloc(context, size); + talloc_realloc(context, NULL, size) ==> talloc_size(context, size); talloc_realloc(context, ptr, 0) ==> talloc_free(ptr); The "context" argument is only used if "ptr" is not NULL, otherwise it @@ -407,7 +407,7 @@ void *talloc_zero(const void *ctx, size_t size); The talloc_zero() function is equivalent to: - ptr = talloc(ctx, size); + ptr = talloc_size(ctx, size); if (ptr) memset(ptr, 0, size); @@ -416,7 +416,7 @@ void *talloc_memdup(const void *ctx, const void *p, size_t size); The talloc_memdup() function is equivalent to: - ptr = talloc(ctx, size); + ptr = talloc_size(ctx, size); if (ptr) memcpy(ptr, p, size); @@ -425,7 +425,7 @@ char *talloc_strdup(const void *ctx, const char *p); The talloc_strdup() function is equivalent to: - ptr = talloc(ctx, strlen(p)+1); + ptr = talloc_size(ctx, strlen(p)+1); if (ptr) memcpy(ptr, p, strlen(p)+1); This functions sets the name of the new pointer to the passed @@ -473,7 +473,7 @@ void *talloc_array_p(const void *ctx, type, uint_t count); The talloc_array_p() macro is equivalent to: - (type *)talloc(ctx, sizeof(type) * count); + (type *)talloc_size(ctx, sizeof(type) * count); except that it provides integer overflow protection for the multiply, returning NULL if the multiply overflows. diff --git a/source4/lib/talloc/testsuite.c b/source4/lib/talloc/testsuite.c index ced3217105..d46964d9b6 100644 --- a/source4/lib/talloc/testsuite.c +++ b/source4/lib/talloc/testsuite.c @@ -523,11 +523,11 @@ static BOOL test_realloc(void) p1 = talloc_realloc(NULL, p1, 20); CHECK_SIZE(p1, 20); - talloc(p1, 0); + talloc_new(p1); p2 = talloc_realloc(p1, NULL, 30); - talloc(p1, 0); + talloc_new(p1); p2 = talloc_realloc(p1, p2, 40); -- cgit