mojoshader_common.c
changeset 1065 bb021d539ec5
parent 1064 d3f0f4cf84f2
child 1080 b92bdbf78621
equal deleted inserted replaced
1064:d3f0f4cf84f2 1065:bb021d539ec5
    83     *_value = NULL;
    83     *_value = NULL;
    84     *iter = NULL;
    84     *iter = NULL;
    85     return 0;
    85     return 0;
    86 } // hash_iter
    86 } // hash_iter
    87 
    87 
       
    88 int hash_iter_keys(const HashTable *table, const void **_key, void **iter)
       
    89 {
       
    90     HashItem *item = *iter;
       
    91     int idx = 0;
       
    92 
       
    93     if (item != NULL)
       
    94     {
       
    95         const HashItem *orig = item;
       
    96         item = item->next;
       
    97         if (item == NULL)
       
    98             idx = calc_hash(table, orig->key) + 1;
       
    99     } // if
       
   100 
       
   101     while (!item && (idx < table->table_len))
       
   102         item = table->table[idx++];  // skip empty buckets...
       
   103 
       
   104     if (item == NULL)  // no more matches?
       
   105     {
       
   106         *_key = NULL;
       
   107         *iter = NULL;
       
   108         return 0;
       
   109     } // if
       
   110 
       
   111     *_key = item->key;
       
   112     *iter = item;
       
   113     return 1;
       
   114 } // hash_iter_keys
    88 
   115 
    89 int hash_insert(HashTable *table, const void *key, const void *value)
   116 int hash_insert(HashTable *table, const void *key, const void *value)
    90 {
   117 {
    91     HashItem *item = NULL;
   118     HashItem *item = NULL;
    92     const uint32 hash = calc_hash(table, key);
   119     const uint32 hash = calc_hash(table, key);