diff options
author | Volker Lendecke <vl@samba.org> | 2013-09-06 15:30:38 -0700 |
---|---|---|
committer | Volker Lendecke <vl@samba.org> | 2013-09-08 11:34:07 +0200 |
commit | 256d10f5792a37d20cbb45f2af3f8578bd354110 (patch) | |
tree | 67b9aa1fc3721d0adf041896656c66fa576269fd /lib | |
parent | e82320e5197bcdd0330bc829c0963ad09854a36c (diff) | |
download | samba-256d10f5792a37d20cbb45f2af3f8578bd354110.tar.gz samba-256d10f5792a37d20cbb45f2af3f8578bd354110.tar.bz2 samba-256d10f5792a37d20cbb45f2af3f8578bd354110.zip |
talloc: Test the pooled object
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/talloc/testsuite.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/lib/talloc/testsuite.c b/lib/talloc/testsuite.c index f04f4f1cc7..888d260cbc 100644 --- a/lib/talloc/testsuite.c +++ b/lib/talloc/testsuite.c @@ -1291,6 +1291,40 @@ static bool test_pool_nest(void) return true; } +struct pooled { + char *s1; + char *s2; + char *s3; +}; + +static bool test_pooled_object(void) +{ + struct pooled *p; + const char *s1 = "hello"; + const char *s2 = "world"; + const char *s3 = ""; + + p = talloc_pooled_object(NULL, struct pooled, 3, + strlen(s1)+strlen(s2)+strlen(s3)+3); + + if (talloc_get_size(p) != sizeof(struct pooled)) { + return false; + } + + p->s1 = talloc_strdup(p, s1); + + TALLOC_FREE(p->s1); + p->s1 = talloc_strdup(p, s2); + TALLOC_FREE(p->s1); + + p->s1 = talloc_strdup(p, s1); + p->s2 = talloc_strdup(p, s2); + p->s3 = talloc_strdup(p, s3); + + TALLOC_FREE(p); + return true; +} + static bool test_free_ref_null_context(void) { void *p1, *p2, *p3; @@ -1591,6 +1625,8 @@ bool torture_local_talloc(struct torture_context *tctx) setlinebuf(stdout); test_reset(); + ret &= test_pooled_object(); + test_reset(); ret &= test_pool_nest(); test_reset(); ret &= test_ref1(); |