Commit a3f29ae4 authored by Philipp Schafft's avatar Philipp Schafft 🦁

Update: Renamed "parent" to "associated" to make it more generally useful

parent 4e1dc94c
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
#define TO_BASE(x) REFOBJECT_TO_TYPE((x), refobject_base_t *) #define TO_BASE(x) REFOBJECT_TO_TYPE((x), refobject_base_t *)
refobject_t refobject_new(size_t len, refobject_free_t freecb, void *userdata, const char *name, refobject_t parent) refobject_t refobject_new(size_t len, refobject_free_t freecb, void *userdata, const char *name, refobject_t associated)
{ {
refobject_base_t *ret = NULL; refobject_base_t *ret = NULL;
...@@ -44,13 +44,13 @@ refobject_t refobject_new(size_t len, refobject_free_t freecb, void *userdat ...@@ -44,13 +44,13 @@ refobject_t refobject_new(size_t len, refobject_free_t freecb, void *userdat
} }
} }
if (!REFOBJECT_IS_NULL(parent)) { if (!REFOBJECT_IS_NULL(associated)) {
if (refobject_ref(parent) != 0) { if (refobject_ref(associated) != 0) {
refobject_unref(ret); refobject_unref(ret);
return REFOBJECT_NULL; return REFOBJECT_NULL;
} }
ret->parent = parent; ret->associated = associated;
} }
return (refobject_t)ret; return (refobject_t)ret;
...@@ -139,7 +139,7 @@ const char * refobject_get_name(refobject_t self) ...@@ -139,7 +139,7 @@ const char * refobject_get_name(refobject_t self)
return ret; return ret;
} }
refobject_t refobject_get_parent(refobject_t self) refobject_t refobject_get_associated(refobject_t self)
{ {
refobject_t ret; refobject_t ret;
...@@ -147,7 +147,7 @@ refobject_t refobject_get_parent(refobject_t self) ...@@ -147,7 +147,7 @@ refobject_t refobject_get_parent(refobject_t self)
return REFOBJECT_NULL; return REFOBJECT_NULL;
thread_mutex_lock(&(TO_BASE(self)->lock)); thread_mutex_lock(&(TO_BASE(self)->lock));
ret = TO_BASE(self)->parent; ret = TO_BASE(self)->associated;
thread_mutex_unlock(&(TO_BASE(self)->lock)); thread_mutex_unlock(&(TO_BASE(self)->lock));
return ret; return ret;
......
...@@ -36,15 +36,15 @@ struct refobject_base_tag { ...@@ -36,15 +36,15 @@ struct refobject_base_tag {
void *userdata; void *userdata;
refobject_free_t freecb; refobject_free_t freecb;
char *name; char *name;
refobject_t parent; refobject_t associated;
}; };
refobject_t refobject_new(size_t len, refobject_free_t freecb, void *userdata, const char *name, refobject_t parent); refobject_t refobject_new(size_t len, refobject_free_t freecb, void *userdata, const char *name, refobject_t associated);
int refobject_ref(refobject_t self); int refobject_ref(refobject_t self);
int refobject_unref(refobject_t self); int refobject_unref(refobject_t self);
void * refobject_get_userdata(refobject_t self); void * refobject_get_userdata(refobject_t self);
int refobject_set_userdata(refobject_t self, void *userdata); int refobject_set_userdata(refobject_t self, void *userdata);
const char * refobject_get_name(refobject_t self); const char * refobject_get_name(refobject_t self);
refobject_t refobject_get_parent(refobject_t self); refobject_t refobject_get_associated(refobject_t self);
#endif #endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment