Revision
15070
Author
anthm
Date
2009-10-03 17:21:52 -0500 (Sat, 03 Oct 2009)

Log Message

use malloc in hashes when no pool specified

Modified Paths

Diff

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c (15069 => 15070)


--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c	2009-10-03 16:01:06 UTC (rev 15069)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c	2009-10-03 22:21:52 UTC (rev 15070)
@@ -444,6 +444,7 @@
 		}
 	}
 
+
 	if (codec_string) {
 		char *tmp_codec_string;
 		if ((tmp_codec_string = switch_core_session_strdup(tech_pvt->session, codec_string))) {

Modified: freeswitch/trunk/src/switch_core_hash.c (15069 => 15070)


--- freeswitch/trunk/src/switch_core_hash.c	2009-10-03 16:01:06 UTC (rev 15069)
+++ freeswitch/trunk/src/switch_core_hash.c	2009-10-03 22:21:52 UTC (rev 15070)
@@ -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_assert(hash != NULL && *hash != NULL);
 	sqlite3HashClear(&(*hash)->table);
+
+	if (!(*hash)->pool) {
+		free(*hash);
+	}
+
 	*hash = NULL;
+
 	return SWITCH_STATUS_SUCCESS;
 }