From e97728dc23dba720769eed4de91b7fd293f40e47 Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Sat, 17 Aug 2013 20:35:00 +0200 Subject: [PATCH] object: Added sdb_object_vcreate(). This function expects an va_list argument rather than a "true" variadic list of arguments. --- src/core/object.c | 20 +++++++++++++------- src/include/core/object.h | 2 ++ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/core/object.c b/src/core/object.c index 7fbd5f0..d6665e7 100644 --- a/src/core/object.c +++ b/src/core/object.c @@ -75,7 +75,7 @@ static sdb_type_t sdb_object_wrapper_type = { */ sdb_object_t * -sdb_object_create(const char *name, sdb_type_t type, ...) +sdb_object_vcreate(const char *name, sdb_type_t type, va_list ap) { sdb_object_t *obj; @@ -97,22 +97,28 @@ sdb_object_create(const char *name, sdb_type_t type, ...) } if (type.init) { - va_list ap; - va_start(ap, type); - if (type.init(obj, ap)) { obj->ref_cnt = 1; sdb_object_deref(obj); - va_end(ap); return NULL; } - - va_end(ap); } obj->type = type; obj->ref_cnt = 1; return obj; +} /* sdb_object_vcreate */ + +sdb_object_t * +sdb_object_create(const char *name, sdb_type_t type, ...) +{ + sdb_object_t *obj; + va_list ap; + + va_start(ap, type); + obj = sdb_object_vcreate(name, type, ap); + va_end(ap); + return obj; } /* sdb_object_create */ sdb_object_t * diff --git a/src/include/core/object.h b/src/include/core/object.h index 016e718..23cd856 100644 --- a/src/include/core/object.h +++ b/src/include/core/object.h @@ -89,6 +89,8 @@ typedef struct { */ sdb_object_t * sdb_object_create(const char *name, sdb_type_t type, ...); +sdb_object_t * +sdb_object_vcreate(const char *name, sdb_type_t type, va_list ap); /* * sdb_object_create_wrapper: -- 2.30.2