Exemplo n.º 1
0
/*
 * Remove record r
 */
void strmap_erase(strmap_t *hmap, strmap_rec_t *r) {
  assert(strmap_find(hmap, r->key) == r);

  string_decref(r->key);
  r->key = DELETED_KEY;
  hmap->nelems --;
  hmap->ndeleted ++;
  if (hmap->ndeleted > hmap->cleanup_threshold) {
    strmap_cleanup(hmap);
  }
}
Exemplo n.º 2
0
/*
 * Delete: call decref on all keys
 */
void delete_strmap(strmap_t *hmap) {
  uint32_t i, n;
  char *key;

  n = hmap->size;
  for (i=0; i<n; i++) {
    key = hmap->data[i].key;
    if (valid_key(key)) {
      string_decref(key);
    }
  }

  safe_free(hmap->data);
  hmap->data = NULL;
}
Exemplo n.º 3
0
/*
 * Empty the table
 */
void reset_strmap(strmap_t *hmap) {
  uint32_t i, n;
  char *key;

  n = hmap->size;
  for (i=0; i<n; i++) {
    key = hmap->data[i].key;
    hmap->data[i].key = NULL;
    if (valid_key(key)) {
      string_decref(key);
    }
  }

  hmap->nelems = 0;
  hmap->ndeleted = 0;
}
Exemplo n.º 4
0
/*
 * All names in sym_table are built with clone_string.
 * Finalizer: decrement the refcount for a string.
 */
static void finalize(stbl_rec_t *r) {
  string_decref(r->string);
}