/*
* True if this object is shared, that is, it uses reference
- * counting. Only used in developer mode.
+ * counting.
*/
bool is_shared;
};
#endif
/*
- * It is assumed that a "child" being "parented" is publicly reachable.
- * Therefore, a reference to its parent must be taken. The reference
- * to the parent will be released once the object's reference count
- * falls to zero.
+ * It is assumed that a "child" being "parented" is publicly
+ * reachable. Therefore, a reference to its parent must be
+ * taken. The reference to the parent will be released once the
+ * object's reference count falls to zero.
*/
BT_PUT(child->parent);
child->parent = bt_get(parent);
}
-#ifdef BT_DEV_MODE
static inline
-void _bt_object_set_is_shared(struct bt_object *obj, bool is_shared)
+void bt_object_set_is_shared(struct bt_object *obj, bool is_shared)
{
obj->is_shared = is_shared;
}
-# define bt_object_set_is_shared _bt_object_set_is_shared
-#else
-# define bt_object_set_is_shared(_obj, _is_shared)
-#endif
-
static inline
void bt_object_init(void *ptr, bt_object_release_func release)
{
pool->size--;
obj = pool->objects->pdata[pool->size];
pool->objects->pdata[pool->size] = NULL;
-
- if (obj->is_shared) {
- /* Object is shared: reset reference count to 1 */
- obj->ref_count.count = 1;
- }
goto end;
}
static inline
void bt_object_pool_recycle_object(struct bt_object_pool *pool, void *obj)
{
+ struct bt_object *bt_obj = obj;
+
BT_ASSERT(pool);
BT_ASSERT(obj);
g_ptr_array_set_size(pool->objects, pool->size + 1);
}
+ /* Reset reference count to 1 since it could be 0 now */
+ bt_obj->ref_count.count = 1;
+
+ /* Back to the pool */
pool->objects->pdata[pool->size] = obj;
pool->size++;