forked from Mirrors/freeswitch
Wed May 21 10:42:52 EDT 2008 Pekka Pessi <first.last@nokia.com>
* su_home_check_alloc(): added git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@8603 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
a45583dd73
commit
f81c67cd3a
@ -1 +1 @@
|
||||
Sat May 24 23:22:13 EDT 2008
|
||||
Sat May 24 23:25:00 EDT 2008
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user