src/model/m_dict.c
/* FIXME: remove all key/keylen data */
remove all key/keylen data
remove all key / keylen data
void* dict_remove(dict_t *d, const char *key, int keylen) {
   if (d && key && keylen) {
      dict_kv_t *rkv = _dict_get_kv(d, key, keylen);
      if (rkv) {
         void *value = rkv->value;
         uint32_t h = rkv->hash % d->capacity;
         dict_kv_t *kv = d->data[h];
         if (kv == rkv) {
            d->data[h] = kv->next;
         }
         else {
            while (kv->next != rkv) {
               kv = kv->next;
            }
            kv->next = rkv->next;
         }
         lst_remove(d->lst, rkv->node);
         mm_free(rkv);
         d->count--;
         return value;
      }
   }
   return NULL;
}
void * dict_remove ( dict_t * d , const char * key , int keylen ) { if ( d && key && keylen ) { dict_kv_t * rkv = _dict_get_kv ( d , key , keylen ) ; if ( rkv ) { void * value = rkv -> value ; uint32_t h = rkv -> hash % d -> capacity ; dict_kv_t * kv = d -> data [ h ] ; if ( kv == rkv ) { d -> data [ h ] = kv -> next ; } else { while ( kv -> next != rkv ) { kv = kv -> next ; } kv -> next = rkv -> next ; } lst_remove ( d -> lst , rkv -> node ) ; mm_free ( rkv ) ; d -> count -- ; return value ; } } return NULL ; }
FIXME: remove all key/keylen data
FIXME : remove all key / keylen data
//mm_free(rkv->key);