diff options
author | Benny Prijono <bennylp@teluu.com> | 2006-01-30 18:40:05 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2006-01-30 18:40:05 +0000 |
commit | 0d61adeb5f784b45f76d76dad9974f4111fb3c8c (patch) | |
tree | 4fe8830715bd6af57dd91ebca780318a645435cd /pjlib/include/pj | |
parent | 7638eeee106fe58a1225f642e733629f29418818 (diff) |
Finished implementation of UA layer (to be tested)
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@127 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjlib/include/pj')
-rw-r--r-- | pjlib/include/pj/assert.h | 2 | ||||
-rw-r--r-- | pjlib/include/pj/hash.h | 51 |
2 files changed, 49 insertions, 4 deletions
diff --git a/pjlib/include/pj/assert.h b/pjlib/include/pj/assert.h index 6814e4cd..d6cb5163 100644 --- a/pjlib/include/pj/assert.h +++ b/pjlib/include/pj/assert.h @@ -49,7 +49,7 @@ /** * @hideinitializer - * If #PJ_ENABLE_EXTRA_CHECK is declared and non-zero, then + * If #PJ_ENABLE_EXTRA_CHECK is declared and the value is non-zero, then * #PJ_ASSERT_RETURN macro will evaluate the expression in @a expr during * run-time. If the expression yields false, assertion will be triggered * and the current function will return with the specified return value. diff --git a/pjlib/include/pj/hash.h b/pjlib/include/pj/hash.h index 41c89bc0..091c82b6 100644 --- a/pjlib/include/pj/hash.h +++ b/pjlib/include/pj/hash.h @@ -45,6 +45,11 @@ PJ_BEGIN_DECL #define PJ_HASH_KEY_STRING ((unsigned)-1) /** + * This indicates the size of of each hash entry. + */ +#define PJ_HASH_ENTRY_SIZE (3*sizeof(void*) + 2*sizeof(pj_uint32_t)) + +/** * This is the function that is used by the hash table to calculate hash value * of the specified key. * @@ -92,15 +97,24 @@ PJ_DECL(pj_hash_table_t*) pj_hash_create(pj_pool_t *pool, unsigned size); * @param key the key to look for. * @param keylen the length of the key, or PJ_HASH_KEY_STRING to use the * string length of the key. + * @param hval if this argument is not NULL and the value is not zero, + * the value will be used as the computed hash value. If + * the argument is not NULL and the value is zero, it will + * be filled with the computed hash upon return. * * @return the value associated with the key, or NULL if the key is not found. */ PJ_DECL(void *) pj_hash_get( pj_hash_table_t *ht, - const void *key, unsigned keylen ); + const void *key, unsigned keylen, + pj_uint32_t *hval ); /** - * Associate/disassociate a value with the specified key. + * Associate/disassociate a value with the specified key. If value is not + * NULL and entry already exists, the entry's value will be overwritten. + * If value is not NULL and entry does not exist, a new one will be created + * with the specified pool. Otherwise if value is NULL, entry will be + * deleted if it exists. * * @param pool the pool to allocate the new entry if a new entry has to be * created. @@ -108,13 +122,44 @@ PJ_DECL(void *) pj_hash_get( pj_hash_table_t *ht, * @param key the key. * @param keylen the length of the key, or PJ_HASH_KEY_STRING to use the * string length of the key. + * @param hval if the value is not zero, then the hash table will use + * this value to search the entry's index, otherwise it will + * compute the key. This value can be obtained when calling + * #pj_hash_get(). * @param value value to be associated, or NULL to delete the entry with * the specified key. */ PJ_DECL(void) pj_hash_set( pj_pool_t *pool, pj_hash_table_t *ht, - const void *key, unsigned keylen, + const void *key, unsigned keylen, pj_uint32_t hval, void *value ); + +/** + * Associate/disassociate a value with the specified key. This function works + * like #pj_hash_set(), except that it doesn't use pool (hence the np -- no + * pool suffix). If new entry needs to be allocated, it will use the entry_buf. + * + * @param ht the hash table. + * @param key the key. + * @param keylen the length of the key, or PJ_HASH_KEY_STRING to use the + * string length of the key. + * @param hval if the value is not zero, then the hash table will use + * this value to search the entry's index, otherwise it will + * compute the key. This value can be obtained when calling + * #pj_hash_get(). + * @param entry_buf Pointer to buffer which will be used for the new entry, + * when one needs to be created. The buffer must be at least + * PJ_HASH_ENTRY_SIZE long, and the first PJ_HASH_ENTRY_SIZE + * bytes of the buffer will be used by the hash table. + * Application may use the remaining portion of the buffer + * for its own purpose. + * @param value value to be associated, or NULL to delete the entry with + * the specified key. + */ +PJ_DECL(void) pj_hash_set_np(pj_hash_table_t *ht, + const void *key, unsigned keylen, + pj_uint32_t hval, void *entry_buf, void *value); + /** * Get the total number of entries in the hash table. * |