pull/1/head
Behdad Esfahbod 15 years ago
parent f97bf4f812
commit f5ac9de259
  1. 24
      src/hb-object-private.h

@ -62,20 +62,19 @@ typedef struct {
#define HB_DEBUG_OBJECT HB_DEBUG+0 #define HB_DEBUG_OBJECT HB_DEBUG+0
#endif #endif
static inline hb_bool_t /* always returns TRUE */ static inline void
_hb_object_debug_out (const void *obj, _hb_trace_object (const void *obj,
hb_reference_count_t *ref_count, hb_reference_count_t *ref_count,
const char *function) const char *function)
{ {
if (HB_DEBUG_OBJECT) if (HB_DEBUG_OBJECT)
fprintf (stderr, "%p refcount=%d %s\n", fprintf (stderr, "OBJECT(%p) refcount=%d %s\n",
obj, obj,
HB_REFERENCE_COUNT_GET_VALUE (*ref_count), HB_REFERENCE_COUNT_GET_VALUE (*ref_count),
function); function);
return TRUE;
} }
#define HB_OBJECT_DEBUG_OUT(obj) _hb_object_debug_out ((void *) obj, &obj->ref_count, __FUNCTION__) #define TRACE_OBJECT(obj) _hb_trace_object (obj, &obj->ref_count, __FUNCTION__)
@ -96,8 +95,11 @@ _hb_object_debug_out (const void *obj,
likely (( \ likely (( \
(void) ( \ (void) ( \
((obj) = (Type *) calloc (1, sizeof (Type))) && \ ((obj) = (Type *) calloc (1, sizeof (Type))) && \
HB_OBJECT_DO_INIT_EXPR (obj) && \ ( \
HB_OBJECT_DEBUG_OUT (obj) \ HB_OBJECT_DO_INIT_EXPR (obj), \
TRACE_OBJECT (obj), \
TRUE \
) \
), \ ), \
(obj) \ (obj) \
)) ))
@ -107,7 +109,7 @@ _hb_object_debug_out (const void *obj,
int old_count; \ int old_count; \
if (unlikely (!(obj) || HB_OBJECT_IS_INERT (obj))) \ if (unlikely (!(obj) || HB_OBJECT_IS_INERT (obj))) \
return obj; \ return obj; \
HB_OBJECT_DEBUG_OUT (obj); \ TRACE_OBJECT (obj); \
old_count = hb_reference_count_inc (obj->ref_count); \ old_count = hb_reference_count_inc (obj->ref_count); \
assert (old_count > 0); \ assert (old_count > 0); \
return obj; \ return obj; \
@ -125,7 +127,7 @@ _hb_object_debug_out (const void *obj,
int old_count; \ int old_count; \
if (unlikely (!(obj) || HB_OBJECT_IS_INERT (obj))) \ if (unlikely (!(obj) || HB_OBJECT_IS_INERT (obj))) \
return; \ return; \
HB_OBJECT_DEBUG_OUT (obj); \ TRACE_OBJECT (obj); \
old_count = hb_reference_count_dec (obj->ref_count); \ old_count = hb_reference_count_dec (obj->ref_count); \
assert (old_count > 0); \ assert (old_count > 0); \
if (old_count != 1) \ if (old_count != 1) \

Loading…
Cancel
Save