summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 231b242)
raw | patch | inline | side by side (parent: 231b242)
author | Sebastian Harl <sh@tokkee.org> | |
Sat, 23 Mar 2013 03:25:44 +0000 (20:25 -0700) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Sat, 23 Mar 2013 03:25:44 +0000 (20:25 -0700) |
src/core/object.c | patch | blob | history | |
src/include/core/object.h | patch | blob | history |
diff --git a/src/core/object.c b/src/core/object.c
index e9825b1d84cc122499600521a432e4bb162f24c8..65b256f908675018647e7bc41e9cda6458997ea0 100644 (file)
--- a/src/core/object.c
+++ b/src/core/object.c
++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 */
+
/* vim: set tw=78 sw=4 ts=4 noexpandtab : */
index dab220b2df41e6bd2d5361b2e9a5f12a0002c2a9..dce562c42fbb697865a4eab0dc1f5f5ead143b08 100644 (file)
void
sdb_object_ref(sdb_object_t *obj);
+/*
+ * sdb_object_clone:
+ * Clone an existing object using its type's 'clone' callback. The callback is
+ * responsible for correctly initializing a new object (which may be done
+ * using the object create function or the object's type's init function).
+ *
+ * Returns:
+ * - the cloned object on success
+ * - NULL on error or if no clone callback is available
+ */
+sdb_object_t *
+sdb_object_clone(const sdb_object_t *obj);
+
#ifdef __cplusplus
} /* extern "C" */
#endif