use malloc in hashes when no pool specified

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@15070 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2009-10-03 22:21:52 +00:00
parent f04b5b9097
commit 954b276c33
2 changed files with 16 additions and 2 deletions

View File

@ -444,6 +444,7 @@ void sofia_glue_tech_prepare_codecs(private_object_t *tech_pvt)
}
}
if (codec_string) {
char *tmp_codec_string;
if ((tmp_codec_string = switch_core_session_strdup(tech_pvt->session, codec_string))) {

View File

@ -39,18 +39,25 @@
struct switch_hash {
Hash table;
switch_memory_pool_t *pool;
};
SWITCH_DECLARE(switch_status_t) switch_core_hash_init_case(switch_hash_t **hash, switch_memory_pool_t *pool, switch_bool_t case_sensitive)
{
switch_hash_t *newhash;
newhash = switch_core_alloc(pool, sizeof(*newhash));
if (pool) {
newhash = switch_core_alloc(pool, sizeof(*newhash));
newhash->pool = pool;
} else {
switch_zmalloc(newhash, sizeof(*newhash));
}
switch_assert(newhash);
sqlite3HashInit(&newhash->table, case_sensitive ? SQLITE_HASH_BINARY : SQLITE_HASH_STRING, 1);
*hash = newhash;
return SWITCH_STATUS_SUCCESS;
}
@ -58,7 +65,13 @@ SWITCH_DECLARE(switch_status_t) switch_core_hash_destroy(switch_hash_t **hash)
{
switch_assert(hash != NULL && *hash != NULL);
sqlite3HashClear(&(*hash)->table);
if (!(*hash)->pool) {
free(*hash);
}
*hash = NULL;
return SWITCH_STATUS_SUCCESS;
}