X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fcore%2Fobject.c;h=9101918654379a1ff41491df64187d399468d186;hb=31c79a0408f61f43310093e0e03681c7f5206483;hp=0205ed588f1e58a8afd727a99443c8037add9604;hpb=73272856dba3b5e49710205601017724fbb6c424;p=sysdb.git diff --git a/src/core/object.c b/src/core/object.c index 0205ed5..9101918 100644 --- a/src/core/object.c +++ b/src/core/object.c @@ -25,6 +25,10 @@ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#if HAVE_CONFIG_H +# include "config.h" +#endif /* HAVE_CONFIG_H */ + #include "core/object.h" #include @@ -78,13 +82,14 @@ sdb_object_vcreate(const char *name, sdb_type_t type, va_list ap) { sdb_object_t *obj; - if (type.size <= sizeof(sdb_object_t)) + if (type.size < sizeof(sdb_object_t)) return NULL; obj = malloc(type.size); if (! obj) return NULL; memset(obj, 0, type.size); + obj->type = type; if (name) { obj->name = strdup(name); @@ -103,7 +108,6 @@ sdb_object_vcreate(const char *name, sdb_type_t type, va_list ap) } } - obj->type = type; obj->ref_cnt = 1; return obj; } /* sdb_object_vcreate */ @@ -120,6 +124,14 @@ sdb_object_create(const char *name, sdb_type_t type, ...) return obj; } /* sdb_object_create */ +sdb_object_t * +sdb_object_create_simple(const char *name, size_t size, + void (*destructor)(sdb_object_t *)) +{ + sdb_type_t t = { size, NULL, destructor }; + 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 *))