diff options
author | Andrew Tridgell <tridge@samba.org> | 2005-01-06 03:06:58 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:08:25 -0500 |
commit | ddc10d4d37984246a6547e34a32d629c689c40d1 (patch) | |
tree | bba9f8756de8fe38a6926edd0802aeff25abe0cf /source4/lib/talloc | |
parent | 0b54d9236fad72527ed1bcf4236767a09090d304 (diff) | |
download | samba-ddc10d4d37984246a6547e34a32d629c689c40d1.tar.gz samba-ddc10d4d37984246a6547e34a32d629c689c40d1.tar.bz2 samba-ddc10d4d37984246a6547e34a32d629c689c40d1.zip |
r4549: got rid of a lot more uses of plain talloc(), instead using
talloc_size() or talloc_array_p() where appropriate.
also fixed a memory leak in pvfs_copy_file() (failed to free a memory
context)
(This used to be commit 89b74b53546e1570b11b3702f40bee58aed8c503)
Diffstat (limited to 'source4/lib/talloc')
-rw-r--r-- | source4/lib/talloc/talloc.h | 1 | ||||
-rw-r--r-- | source4/lib/talloc/testsuite.c | 18 |
2 files changed, 10 insertions, 9 deletions
diff --git a/source4/lib/talloc/talloc.h b/source4/lib/talloc/talloc.h index ee3e0be8eb..99a6b7a770 100644 --- a/source4/lib/talloc/talloc.h +++ b/source4/lib/talloc/talloc.h @@ -34,6 +34,7 @@ typedef void TALLOC_CTX; /* useful macros for creating type checked pointers */ #define talloc(ctx, size) talloc_named_const(ctx, size, __location__) +#define talloc_size(ctx, size) talloc_named_const(ctx, size, __location__) #define talloc_zero(ctx, size) _talloc_zero(ctx, size, __location__) #define talloc_realloc(ctx, ptr, size) _talloc_realloc(ctx, ptr, size, __location__) #define talloc_p(ctx, type) (type *)talloc_named_const(ctx, sizeof(type), #type) diff --git a/source4/lib/talloc/testsuite.c b/source4/lib/talloc/testsuite.c index a3a448ef40..ced3217105 100644 --- a/source4/lib/talloc/testsuite.c +++ b/source4/lib/talloc/testsuite.c @@ -335,7 +335,7 @@ static BOOL test_misc(void) root = talloc_new(NULL); - p1 = talloc(root, 0x7fffffff); + p1 = talloc_size(root, 0x7fffffff); if (p1) { printf("failed: large talloc allowed\n"); return False; @@ -517,7 +517,7 @@ static BOOL test_realloc(void) root = talloc_new(NULL); - p1 = talloc(root, 10); + p1 = talloc_size(root, 10); CHECK_SIZE(p1, 10); p1 = talloc_realloc(NULL, p1, 20); @@ -581,7 +581,7 @@ static BOOL test_realloc_child(void) printf("TESTING REALLOC WITH CHILD\n"); - root = talloc(NULL, 0); + root = talloc_new(NULL); el1 = talloc_p(root, struct el1); el1->list = talloc_p(el1, struct el2 *); @@ -607,7 +607,7 @@ static BOOL test_steal(void) printf("TESTING STEAL\n"); - root = talloc(NULL, 0); + root = talloc_new(NULL); p1 = talloc_array_p(root, char, 10); CHECK_SIZE(p1, 10); @@ -645,7 +645,7 @@ static BOOL test_steal(void) talloc_free(root); - p1 = talloc(NULL, 3); + p1 = talloc_new(NULL); CHECK_SIZE(NULL, 3); talloc_free(p1); @@ -661,7 +661,7 @@ static BOOL test_ldb(void) printf("TESTING LDB\n"); - root = talloc(NULL, 0); + root = talloc_new(NULL); p1 = talloc_realloc_fn(root, NULL, 10); CHECK_BLOCKS(root, 2); @@ -709,7 +709,7 @@ static BOOL test_unref_reparent(void) */ static BOOL test_speed(void) { - void *ctx = talloc(NULL, 0); + void *ctx = talloc_new(NULL); unsigned count; struct timeval tv; @@ -719,9 +719,9 @@ static BOOL test_speed(void) count = 0; do { void *p1, *p2, *p3; - p1 = talloc(ctx, count); + p1 = talloc_size(ctx, count); p2 = talloc_strdup(p1, "foo bar"); - p3 = talloc(p1, 300); + p3 = talloc_size(p1, 300); talloc_free(p1); count += 3; } while (timeval_elapsed(&tv) < 5.0); |