src/libs/hash_lib.c
Flag hash_table_access_delete(Hash_Table* table, int64 key) {
  // {{{ access hash table using simple key compare
  uns               index  = HASH_INDEX(table, key);
  Hash_Table_Entry* bucket = table->entries[index];
  Hash_Table_Entry* temp;
  Hash_Table_Entry* prev = NULL;

  for(temp = bucket; temp != NULL; temp = temp->next) {
    if(temp->key == key) {
      Hash_Table_Entry* next_ptr = temp->next;
      sfree(table->data_size, temp->data);
      sfree(sizeof(Hash_Table_Entry), temp);
      if(prev)
        prev->next = next_ptr;
      else
        table->entries[index] = next_ptr;
      table->count--;
      ASSERT(0, table->count >= 0);
      return TRUE;
    } else
      prev = temp;
  }

  return FALSE;
  // }}}
}
/**************************************************************************************/
/* hash_table_access_delete: look up an entry and delete it. return
   TRUE if it was found, FALSE otherwise */
look up an entry and delete it. return
TRUE if it was found, FALSE otherwise
look up an entry and delete it . return TRUE if it was found FALSE otherwise
Flag hash_table_access_delete(Hash_Table* table, int64 key) {
  uns               index  = HASH_INDEX(table, key);
  Hash_Table_Entry* bucket = table->entries[index];
  Hash_Table_Entry* temp;
  Hash_Table_Entry* prev = NULL;
  for(temp = bucket; temp != NULL; temp = temp->next) {
    if(temp->key == key) {
      Hash_Table_Entry* next_ptr = temp->next;
      sfree(table->data_size, temp->data);
      sfree(sizeof(Hash_Table_Entry), temp);
      if(prev)
        prev->next = next_ptr;
      else
        table->entries[index] = next_ptr;
      table->count--;
      ASSERT(0, table->count >= 0);
      return TRUE;
    } else
      prev = temp;
  }
  return FALSE;
}
Flag hash_table_access_delete ( Hash_Table * table , int64 key ) { uns index = HASH_INDEX ( table , key ) ; Hash_Table_Entry * bucket = table -> entries [ index ] ; Hash_Table_Entry * temp ; Hash_Table_Entry * prev = NULL ; for ( temp = bucket ; temp != NULL ; temp = temp -> next ) { if ( temp -> key == key ) { Hash_Table_Entry * next_ptr = temp -> next ; sfree ( table -> data_size , temp -> data ) ; sfree ( sizeof ( Hash_Table_Entry ) , temp ) ; if ( prev ) prev -> next = next_ptr ; else table -> entries [ index ] = next_ptr ; table -> count -- ; ASSERT ( 0 , table -> count >= 0 ) ; return TRUE ; } else prev = temp ; } return FALSE ; }
hash_table_access_delete: look up an entry and delete it.
hash_table_access_delete : look up an entry and delete it .
// {{{ access hash table using simple key compare // }}}