From 42bbebb4b0bba76683ff38ce79f5bdad97b0ce37 Mon Sep 17 00:00:00 2001 From: Benny Prijono Date: Sat, 8 Sep 2007 07:12:44 +0000 Subject: Fixed ticket #367: Hash table will duplicate the hash key (thanks Scott Lu) git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@1429 74dad513-b988-da41-8d7b-12977e46ad98 --- pjlib/src/pj/hash.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'pjlib') diff --git a/pjlib/src/pj/hash.c b/pjlib/src/pj/hash.c index 2e13f450..0c2bda34 100644 --- a/pjlib/src/pj/hash.c +++ b/pjlib/src/pj/hash.c @@ -33,7 +33,7 @@ struct pj_hash_entry { struct pj_hash_entry *next; - const void *key; + void *key; pj_uint32_t hash; pj_uint32_t keylen; void *value; @@ -193,7 +193,12 @@ static pj_hash_entry **find_entry( pj_pool_t *pool, pj_hash_table_t *ht, } entry->next = NULL; entry->hash = hash; - entry->key = key; + if (pool) { + entry->key = pj_pool_alloc(pool, keylen); + pj_memcpy(entry->key, key, keylen); + } else { + entry->key = (void*)key; + } entry->keylen = keylen; entry->value = val; *p_entry = entry; -- cgit v1.2.3