Code

object: Added sdb_object_vcreate().
authorSebastian Harl <sh@tokkee.org>
Sat, 17 Aug 2013 18:35:00 +0000 (20:35 +0200)
committerSebastian Harl <sh@tokkee.org>
Sat, 17 Aug 2013 19:18:56 +0000 (21:18 +0200)
This function expects an va_list argument rather than a "true" variadic list
of arguments.

src/core/object.c
src/include/core/object.h

index 7fbd5f025228831503fdc626516f3c9733eeff81..d6665e7cbd7546645093d0d97c68136dc17ed8a0 100644 (file)
@@ -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 *
index 016e718110090038ad5549e77c28a27aa0f1de34..23cd8565d92c0f18ad04d5764750891192bee981 100644 (file)
@@ -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: