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:
parent
f04b5b9097
commit
954b276c33
|
@ -444,6 +444,7 @@ void sofia_glue_tech_prepare_codecs(private_object_t *tech_pvt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (codec_string) {
|
if (codec_string) {
|
||||||
char *tmp_codec_string;
|
char *tmp_codec_string;
|
||||||
if ((tmp_codec_string = switch_core_session_strdup(tech_pvt->session, codec_string))) {
|
if ((tmp_codec_string = switch_core_session_strdup(tech_pvt->session, codec_string))) {
|
||||||
|
|
|
@ -39,18 +39,25 @@
|
||||||
|
|
||||||
struct switch_hash {
|
struct switch_hash {
|
||||||
Hash table;
|
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_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;
|
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);
|
switch_assert(newhash);
|
||||||
|
|
||||||
sqlite3HashInit(&newhash->table, case_sensitive ? SQLITE_HASH_BINARY : SQLITE_HASH_STRING, 1);
|
sqlite3HashInit(&newhash->table, case_sensitive ? SQLITE_HASH_BINARY : SQLITE_HASH_STRING, 1);
|
||||||
*hash = newhash;
|
*hash = newhash;
|
||||||
|
|
||||||
return SWITCH_STATUS_SUCCESS;
|
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);
|
switch_assert(hash != NULL && *hash != NULL);
|
||||||
sqlite3HashClear(&(*hash)->table);
|
sqlite3HashClear(&(*hash)->table);
|
||||||
|
|
||||||
|
if (!(*hash)->pool) {
|
||||||
|
free(*hash);
|
||||||
|
}
|
||||||
|
|
||||||
*hash = NULL;
|
*hash = NULL;
|
||||||
|
|
||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue