Main Page | Modules | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

switch_core_hash.c File Reference


Data Structures

struct  switch_hash

Functions

switch_status_t switch_core_hash_init (switch_hash_t **hash, switch_memory_pool_t *pool)
switch_status_t switch_core_hash_destroy (switch_hash_t **hash)
switch_status_t switch_core_hash_insert (switch_hash_t *hash, const char *key, const void *data)
switch_status_t switch_core_hash_insert_locked (switch_hash_t *hash, const char *key, const void *data, switch_mutex_t *mutex)
switch_status_t switch_core_hash_delete (switch_hash_t *hash, const char *key)
switch_status_t switch_core_hash_delete_locked (switch_hash_t *hash, const char *key, switch_mutex_t *mutex)
void * switch_core_hash_find (switch_hash_t *hash, const char *key)
void * switch_core_hash_find_locked (switch_hash_t *hash, const char *key, switch_mutex_t *mutex)
switch_hash_index_tswitch_hash_first (char *depricate_me, switch_hash_t *hash)
switch_hash_index_tswitch_hash_next (switch_hash_index_t *hi)
void switch_hash_this (switch_hash_index_t *hi, const void **key, switch_ssize_t *klen, void **val)


Function Documentation

switch_status_t switch_core_hash_delete switch_hash_t hash,
const char *  key
 

00087 {
00088         sqlite3HashInsert(&hash->table, key, (int)strlen(key)+1, NULL);
00089         return SWITCH_STATUS_SUCCESS;
00090 }

switch_status_t switch_core_hash_delete_locked switch_hash_t hash,
const char *  key,
switch_mutex_t mutex
 

00093 {
00094         if (mutex) {
00095         switch_mutex_lock(mutex);
00096     }
00097         
00098         sqlite3HashInsert(&hash->table, key, (int)strlen(key)+1, NULL);
00099         
00100         if (mutex) {
00101         switch_mutex_unlock(mutex);
00102     }
00103 
00104         return SWITCH_STATUS_SUCCESS;
00105 }

Here is the call graph for this function:

switch_status_t switch_core_hash_destroy switch_hash_t **  hash  ) 
 

00058 {
00059         switch_assert(hash != NULL && *hash != NULL);
00060         sqlite3HashClear(&(*hash)->table);
00061         *hash = NULL;
00062         return SWITCH_STATUS_SUCCESS;
00063 }

void* switch_core_hash_find switch_hash_t hash,
const char *  key
 

00108 {
00109         return sqlite3HashFind(&hash->table, key, (int)strlen(key)+1);
00110 }

void* switch_core_hash_find_locked switch_hash_t hash,
const char *  key,
switch_mutex_t mutex
 

00113 {
00114         void *val;
00115 
00116         if (mutex) {
00117                 switch_mutex_lock(mutex);
00118         }
00119 
00120         val = sqlite3HashFind(&hash->table, key, (int)strlen(key)+1);
00121         
00122         if (mutex) {
00123                 switch_mutex_unlock(mutex);
00124         }
00125 
00126         return val;
00127 }

Here is the call graph for this function:

switch_status_t switch_core_hash_init switch_hash_t **  hash,
switch_memory_pool_t pool
 

00045 {
00046         switch_hash_t *newhash;
00047         
00048         newhash = switch_core_alloc(pool, sizeof(*newhash));
00049         switch_assert(newhash);
00050 
00051         sqlite3HashInit(&newhash->table, SQLITE_HASH_STRING, 1);
00052         *hash = newhash;
00053         
00054         return SWITCH_STATUS_SUCCESS;
00055 }

switch_status_t switch_core_hash_insert switch_hash_t hash,
const char *  key,
const void *  data
 

00066 {
00067         sqlite3HashInsert(&hash->table, key, (int)strlen(key)+1, (void *)data);
00068         return SWITCH_STATUS_SUCCESS;
00069 }

switch_status_t switch_core_hash_insert_locked switch_hash_t hash,
const char *  key,
const void *  data,
switch_mutex_t mutex
 

00072 {
00073         if (mutex) {
00074         switch_mutex_lock(mutex);
00075     }
00076 
00077         sqlite3HashInsert(&hash->table, key, (int)strlen(key)+1, (void *)data);
00078 
00079         if (mutex) {
00080         switch_mutex_unlock(mutex);
00081     }   
00082 
00083         return SWITCH_STATUS_SUCCESS;
00084 }

Here is the call graph for this function:

switch_hash_index_t* switch_hash_first char *  depricate_me,
switch_hash_t hash
 

00130 {
00131         return (switch_hash_index_t *) sqliteHashFirst(&hash->table);
00132 }

switch_hash_index_t* switch_hash_next switch_hash_index_t hi  ) 
 

00135 {
00136         return (switch_hash_index_t *) sqliteHashNext((HashElem *) hi);
00137 }

void switch_hash_this switch_hash_index_t hi,
const void **  key,
switch_ssize_t klen,
void **  val
 

00140 {
00141         if (key) {
00142                 *key = sqliteHashKey((HashElem *) hi);
00143                 if (klen) {
00144                         *klen = strlen((char *) *key) + 1;
00145                 }
00146         }
00147         if (val) {
00148                 *val = sqliteHashData((HashElem *) hi);
00149         }
00150 }


Generated on Mon May 26 22:06:51 2008 for FreeSWITCH by  doxygen 1.3.9.1