Code

Include config.h in source files.
[sysdb.git] / src / core / object.c
index 7fbd5f025228831503fdc626516f3c9733eeff81..9d10f9831720ba8eaf310d3f83227c8572025df1 100644 (file)
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#if HAVE_CONFIG_H
+#      include "config.h"
+#endif /* HAVE_CONFIG_H */
+
 #include "core/object.h"
 
 #include <assert.h>
@@ -66,8 +70,7 @@ static sdb_type_t sdb_object_wrapper_type = {
        sizeof(sdb_object_wrapper_t),
 
        sdb_object_wrapper_init,
-       sdb_object_wrapper_destroy,
-       /* clone = */ NULL
+       sdb_object_wrapper_destroy
 };
 
 /*
@@ -75,7 +78,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;
 
@@ -86,6 +89,7 @@ sdb_object_create(const char *name, sdb_type_t type, ...)
        if (! obj)
                return NULL;
        memset(obj, 0, type.size);
+       obj->type = type;
 
        if (name) {
                obj->name = strdup(name);
@@ -97,24 +101,36 @@ 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 *
+sdb_object_create_simple(const char *name, size_t size)
+{
+       sdb_type_t t = { size, NULL, NULL };
+       return sdb_object_create(name, t);
+} /* sdb_object_create_simple */
+
 sdb_object_t *
 sdb_object_create_wrapper(const char *name,
                void *data, void (*destructor)(void *))
@@ -149,14 +165,6 @@ sdb_object_ref(sdb_object_t *obj)
        ++obj->ref_cnt;
 } /* sdb_object_ref */
 
-sdb_object_t *
-sdb_object_clone(const sdb_object_t *obj)
-{
-       if ((! obj) || (! obj->type.clone))
-               return NULL;
-       return obj->type.clone(obj);
-} /* sdb_object_clone */
-
 int
 sdb_object_cmp_by_name(const sdb_object_t *o1, const sdb_object_t *o2)
 {