lib/portableproplib: fixes to allow building with NDEBUG (assert()s disabled).

This commit is contained in:
Juan RP 2013-12-06 11:54:34 +01:00
parent ae9363b620
commit e23c64bc84
3 changed files with 20 additions and 6 deletions

View File

@ -278,7 +278,10 @@ _prop_dict_keysym_equals(prop_object_t v1, prop_object_t v2,
static prop_dictionary_keysym_t
_prop_dict_keysym_alloc(const char *key)
{
prop_dictionary_keysym_t opdk, pdk, rpdk;
#ifdef DEBUG
prop_dictionary_keysym_t rpdk;
#endif
prop_dictionary_keysym_t opdk, pdk;
size_t size;
_PROP_ONCE_RUN(_prop_dict_init_once, _prop_dict_init);
@ -331,8 +334,10 @@ _prop_dict_keysym_alloc(const char *key)
_prop_dict_keysym_put(pdk);
return (opdk);
}
#ifdef DEBUG
rpdk = _prop_rb_tree_insert_node(&_prop_dict_keysym_tree, pdk);
_PROP_ASSERT(rpdk == pdk);
#endif
_PROP_MUTEX_UNLOCK(_prop_dict_keysym_tree_mutex);
return (pdk);
}

View File

@ -264,7 +264,10 @@ _prop_number_equals(prop_object_t v1, prop_object_t v2,
static prop_number_t
_prop_number_alloc(const struct _prop_number_value *pnv)
{
prop_number_t opn, pn, rpn;
#ifdef DEBUG
prop_number_t rpn;
#endif
prop_number_t opn, pn;
_PROP_ONCE_RUN(_prop_number_init_once, _prop_number_init);
@ -305,8 +308,10 @@ _prop_number_alloc(const struct _prop_number_value *pnv)
_PROP_POOL_PUT(_prop_number_pool, pn);
return (opn);
}
#ifdef DEBUG
rpn = _prop_rb_tree_insert_node(&_prop_number_tree, pn);
_PROP_ASSERT(rpn == pn);
#endif
_PROP_MUTEX_UNLOCK(_prop_number_tree_mutex);
return (pn);
}

View File

@ -997,14 +997,18 @@ _PROP_MUTEX_DECL_STATIC(_prop_refcnt_mutex)
void
prop_object_retain(prop_object_t obj)
{
struct _prop_object *po = obj;
#ifdef DEBUG
uint32_t ocnt;
#endif
struct _prop_object *po = obj;
_PROP_REFCNT_LOCK();
ocnt = po->po_refcnt++;
_PROP_REFCNT_UNLOCK();
po->po_refcnt++;
#ifdef DEBUG
ocnt = po->po_refcnt;
_PROP_ASSERT(ocnt != 0xffffffffU);
#endif
_PROP_REFCNT_UNLOCK();
}
/*