summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2007-09-08 07:12:44 +0000
committerBenny Prijono <bennylp@teluu.com>2007-09-08 07:12:44 +0000
commit42bbebb4b0bba76683ff38ce79f5bdad97b0ce37 (patch)
tree1840979792055fd6bcf2830e9da4c933035a3579
parentb2ce067a55ee3eab4b80e48b3e83eefc02b8ade6 (diff)
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
-rw-r--r--pjlib/src/pj/hash.c9
1 files changed, 7 insertions, 2 deletions
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;