Code

plugin: Make sdb_plugin_info_t public.
[sysdb.git] / src / include / core / object.h
index 3c00fb51abe807d00799d931278e2d5dddc8ffd6..819d11e849b48d4e1e2eb65d35247f4abe22af29 100644 (file)
@@ -78,7 +78,9 @@ typedef struct {
  *
  * The init function will be called with the remaining arguments passed to
  * sdb_object_create. If the init function fails (returns a non-zero value),
- * the object will be destructed and destroyed.
+ * the object will be destructed and destroyed. In this case, the 'destroy'
+ * callback may be called on objects that were only half-way initialized. The
+ * callback has to handle that case correctly.
  *
  * The reference count of the new object will be 1.
  *
@@ -91,6 +93,29 @@ sdb_object_create(const char *name, sdb_type_t type, ...);
 sdb_object_t *
 sdb_object_vcreate(const char *name, sdb_type_t type, va_list ap);
 
+/*
+ * sdb_object_create_simple:
+ * Create a "simple" object without custom initialization and optional
+ * destructor. See the description of sdb_object_create for more details.
+ */
+sdb_object_t *
+sdb_object_create_simple(const char *name, size_t size,
+               void (*destructor)(sdb_object_t *));
+
+/*
+ * sdb_object_create_T:
+ * Create a simple object of type 't'.
+ */
+#define sdb_object_create_T(n,t) \
+       sdb_object_create_simple((n), sizeof(t), NULL)
+
+/*
+ * sdb_object_create_dT:
+ * Create a simple object of dynamic type 't' using destructor 'd'.
+ */
+#define sdb_object_create_dT(n,t,d) \
+       sdb_object_create_simple((n), sizeof(t), d)
+
 /*
  * sdb_object_create_wrapper:
  * Create a new sdb_object_t wrapping some arbitrary other object.