aboutsummaryrefslogtreecommitdiff
path: root/src/obj.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/obj.h')
-rw-r--r--src/obj.h12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/obj.h b/src/obj.h
index 240b4a9..ff26399 100644
--- a/src/obj.h
+++ b/src/obj.h
@@ -52,9 +52,8 @@ struct obj_class_t {
* NULL: can drop
*/
bool (*hook_drop)(struct object_t*, user_t *user);
- void* (*hook_clone)(void*); /* clone the user data pointer */
- void (*hook_destroy)(struct object_t*);
- const char* (*hook_desc)(struct object_t*, user_t*);
+ void (*hook_destroy)(struct object_t*); // free resources
+ const char* (*hook_desc)(struct object_t*, user_t*); // get object description
};
struct object_t {
@@ -64,6 +63,8 @@ struct object_t {
bool list;
+ unsigned refcount;
+
void *userdata;
};
@@ -76,10 +77,11 @@ void obj_write(int fd, struct object_t *obj);
/* deserialize an object */
struct object_t *obj_read(int fd);
-/* make a duplicate of an object
- * used for "moving" an object */
+/* this used to actually make a duplicate of an object...
+ * now it just increments its reference count */
struct object_t *obj_dup(struct object_t *obj);
+/* this only frees the object if its reference count is zero */
void obj_free(void*);
/* shut down the obj_* module */