diff --git a/libs/sofia-sip/.update b/libs/sofia-sip/.update index 67109ebcc7..16d2bbd74e 100644 --- a/libs/sofia-sip/.update +++ b/libs/sofia-sip/.update @@ -1 +1 @@ -Sat May 24 23:22:13 EDT 2008 +Sat May 24 23:25:00 EDT 2008 diff --git a/libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/su_alloc.h b/libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/su_alloc.h index d4ff66559f..8eb12fdd67 100644 --- a/libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/su_alloc.h +++ b/libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/su_alloc.h @@ -103,6 +103,8 @@ SU_DLL int su_home_has_parent(su_home_t const *home); SU_DLL void su_home_check(su_home_t const *home); +SU_DLL int su_home_check_alloc(su_home_t const *home, void const *data); + SU_DLL int su_home_mutex_lock(su_home_t *home); SU_DLL int su_home_mutex_unlock(su_home_t *home); diff --git a/libs/sofia-sip/libsofia-sip-ua/su/su_alloc.c b/libs/sofia-sip/libsofia-sip-ua/su/su_alloc.c index 79d33d680a..a1bf6f206b 100644 --- a/libs/sofia-sip/libsofia-sip-ua/su/su_alloc.c +++ b/libs/sofia-sip/libsofia-sip-ua/su/su_alloc.c @@ -283,7 +283,7 @@ size_t su_block_find_collision, su_block_find_collision_used, su_block_find_collision_size; #endif -su_inline su_alloc_t *su_block_find(su_block_t *b, void const *p) +su_inline su_alloc_t *su_block_find(su_block_t const *b, void const *p) { size_t h, h0, probe; @@ -306,8 +306,10 @@ su_inline su_alloc_t *su_block_find(su_block_t *b, void const *p) probe = (b->sub_n > SUB_P) ? SUB_P : 1; do { - if (b->sub_nodes[h].sua_data == p) - return &b->sub_nodes[h]; + if (b->sub_nodes[h].sua_data == p) { + su_alloc_t const *retval = &b->sub_nodes[h]; + return (su_alloc_t *)retval; /* discard const */ + } h += probe; if (h >= b->sub_n) h -= b->sub_n; @@ -463,7 +465,7 @@ void *sub_alloc(su_home_t *home, home->suh_blocks = b2; if (sub && !sub->sub_auto) - safefree(sub); + free(sub); sub = b2; } @@ -836,6 +838,27 @@ void su_free(su_home_t *home, void *data) safefree(data); } +/** Check if pointer has been allocated through home. + * + * @param home pointer to a memory home + * @param data pointer to a memory area possibly allocated though home + */ +int su_home_check_alloc(su_home_t const *home, void const *data) +{ + int retval = 0; + + if (home && data) { + su_block_t const *sub = MEMLOCK(home); + su_alloc_t *allocation = su_block_find(sub, data); + + retval = allocation != NULL; + + UNLOCK(home); + } + + return retval; +} + /** Check home consistency. * * Ensures that the home structure and all memory blocks allocated through