tdb_wrap: Use talloc_pooled_object
authorVolker Lendecke <vl@samba.org>
Sun, 12 Jul 2015 10:37:43 +0000 (12:37 +0200)
committerRalph Böhme <slow@samba.org>
Thu, 23 Jul 2015 09:33:29 +0000 (11:33 +0200)
One malloc() less

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
lib/tdb_wrap/tdb_wrap.c

index a1bddf394869b214f71f1415b6f387ab53d34484..04f8d4806633e620cb99873a99c641b174323d1c 100644 (file)
@@ -92,14 +92,13 @@ static struct tdb_wrap_private *tdb_wrap_private_open(TALLOC_CTX *mem_ctx,
        struct tdb_wrap_private *result;
        struct tdb_logging_context lctx;
 
-       result = talloc(mem_ctx, struct tdb_wrap_private);
+       result = talloc_pooled_object(mem_ctx, struct tdb_wrap_private,
+                                     1, strlen(name)+1);
        if (result == NULL) {
                return NULL;
        }
+       /* Doesn't fail, see talloc_pooled_object */
        result->name = talloc_strdup(result, name);
-       if (result->name == NULL) {
-               goto fail;
-       }
 
        lctx.log_fn = tdb_wrap_log;
        lctx.log_private = NULL;