summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8600838)
raw | patch | inline | side by side (parent: 8600838)
author | Sebastian Harl <sh@tokkee.org> | |
Fri, 3 Jan 2014 12:39:27 +0000 (13:39 +0100) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Fri, 3 Jan 2014 12:39:27 +0000 (13:39 +0100) |
src/core/store.c | patch | blob | history |
diff --git a/src/core/store.c b/src/core/store.c
index d195b8f0e3d029f4bf853910ba4ce05358e85d58..e0c1ac6e6ede64893cac4d63e52b7892a6434ed6 100644 (file)
--- a/src/core/store.c
+++ b/src/core/store.c
struct sdb_store_base {
sdb_object_t super;
+
+ /* object type */
+ int type;
+
+ /* common meta information */
sdb_time_t last_update;
sdb_store_base_t *parent;
};
typedef struct {
sdb_store_base_t super;
- int type;
sdb_llist_t *children;
-
sdb_llist_t *attributes;
} sdb_store_obj_t;
#define SDB_STORE_OBJ(obj) ((sdb_store_obj_t *)(obj))
store_base_init(sdb_object_t *obj, va_list ap)
{
sdb_store_base_t *sobj = STORE_BASE(obj);
- sobj->last_update = va_arg(ap, sdb_time_t);
+ sobj->type = va_arg(ap, int);
+
+ sobj->last_update = va_arg(ap, sdb_time_t);
sobj->parent = NULL;
return 0;
} /* store_base_init */
sdb_store_obj_t *sobj = SDB_STORE_OBJ(obj);
int ret;
+ /* this will consume the first argument (type) of ap */
ret = store_base_init(obj, ap);
if (ret)
return ret;
- sobj->type = va_arg(ap, int);
-
sobj->children = sdb_llist_create();
if (! sobj->children)
return -1;
const char *value;
int ret;
+ /* this will consume the first argument (type) of ap */
ret = store_base_init(obj, ap);
if (ret)
return ret;
sdb_store_obj_t *sobj = SDB_STORE_OBJ(sdb_llist_iter_get_next(iter));
assert(sobj);
- if ((sobj->type == type)
+ if ((STORE_BASE(sobj)->type == type)
&& (! strcasecmp(SDB_OBJ(sobj)->name, name))) {
sdb_llist_iter_destroy(iter);
return sobj;
}
/* don't lookups non-host types from hierarchical hosts */
- if ((type != SDB_HOST) && (sobj->type == SDB_HOST))
+ if ((type != SDB_HOST) && (STORE_BASE(sobj)->type == SDB_HOST))
continue;
sobj = sdb_store_lookup_in_list(sobj->children, type, name);
if (type == SDB_ATTRIBUTE)
/* the value will be updated by the caller */
new = STORE_BASE(sdb_object_create(name, sdb_attribute_type,
- last_update, NULL));
+ type, last_update, NULL));
else
new = STORE_BASE(sdb_object_create(name, sdb_store_obj_type,
- last_update, type));
+ type, last_update));
if (! new) {
char errbuf[1024];