summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 20a7641)
raw | patch | inline | side by side (parent: 20a7641)
author | Sebastian Harl <sh@tokkee.org> | |
Mon, 4 Mar 2013 16:23:59 +0000 (17:23 +0100) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Mon, 4 Mar 2013 16:23:59 +0000 (17:23 +0100) |
src/core/store.c | patch | blob | history | |
src/utils/llist.c | patch | blob | history |
diff --git a/src/core/store.c b/src/core/store.c
index e5cd886aae31be9bb1d35be92e9f42b7d729e4b5..cbd5f0c05595ccdca54ce2dba48b02d386fed972 100644 (file)
--- a/src/core/store.c
+++ b/src/core/store.c
sdb_host_t *
sdb_host_clone(const sdb_host_t *host)
{
- sdb_host_t *clone;
+ sdb_host_t *new;
- clone = sdb_host_create(host->host_name);
- if (! clone)
+ new = sdb_host_create(host->host_name);
+ if (! new)
return NULL;
/* make sure these are initialized; else sdb_object_deref() might access
* arbitrary memory in case of an error */
- clone->services = clone->attributes = NULL;
+ new->services = new->attributes = NULL;
if (host->attributes) {
- clone->attributes = sdb_llist_clone(host->attributes);
- if (! clone->attributes) {
- sdb_object_deref(SDB_OBJ(clone));
+ new->attributes = sdb_llist_clone(host->attributes);
+ if (! new->attributes) {
+ sdb_object_deref(SDB_OBJ(new));
return NULL;
}
}
- clone->host_last_update = host->host_last_update;
+ new->host_last_update = host->host_last_update;
if (host->services) {
- clone->services = sdb_llist_clone(host->services);
- if (! clone->services) {
- sdb_object_deref(SDB_OBJ(clone));
+ new->services = sdb_llist_clone(host->services);
+ if (! new->services) {
+ sdb_object_deref(SDB_OBJ(new));
return NULL;
}
}
- return clone;
+ return new;
} /* sdb_host_clone */
int
sdb_attribute_t *
sdb_attribute_clone(const sdb_attribute_t *attr)
{
- sdb_attribute_t *clone;
+ sdb_attribute_t *new;
- clone = sdb_attribute_create(attr->hostname,
+ new = sdb_attribute_create(attr->hostname,
attr->attr_name, attr->attr_value);
- if (! clone)
+ if (! new)
return NULL;
- clone->attr_last_update = attr->attr_last_update;
- return clone;
+ new->attr_last_update = attr->attr_last_update;
+ return new;
} /* sdb_attribute_clone */
int
sdb_service_t *
sdb_service_clone(const sdb_service_t *svc)
{
- sdb_service_t *clone;
+ sdb_service_t *new;
- clone = sdb_service_create(svc->hostname, svc->svc_name);
- if (! clone)
+ new = sdb_service_create(svc->hostname, svc->svc_name);
+ if (! new)
return NULL;
- clone->svc_last_update = svc->svc_last_update;
- return clone;
+ new->svc_last_update = svc->svc_last_update;
+ return new;
} /* sdb_service_clone */
int
diff --git a/src/utils/llist.c b/src/utils/llist.c
index e853001bc45bf7fd9a02f55961930105f89366cf..7d573cfa7449ca1dba229e18702fbac009d688c5 100644 (file)
--- a/src/utils/llist.c
+++ b/src/utils/llist.c
sdb_llist_t *
sdb_llist_clone(sdb_llist_t *list)
{
- sdb_llist_t *clone;
+ sdb_llist_t *new;
sdb_llist_elem_t *elem;
if (! list)
return NULL;
- clone = sdb_llist_create();
- if (! clone)
+ new = sdb_llist_create();
+ if (! new)
return NULL;
if (! list->length) {
assert((! list->head) && (! list->tail));
- return clone;
+ return new;
}
for (elem = list->head; elem; elem = elem->next) {
- if (sdb_llist_append(clone, elem->obj)) {
- sdb_llist_destroy(clone);
+ if (sdb_llist_append(new, elem->obj)) {
+ sdb_llist_destroy(new);
return NULL;
}
}
- return clone;
+ return new;
} /* sdb_llist_clone */
void