Handle overwriting existing hash table entries

master
teknomunk 2 years ago
parent 3bd10ea746
commit 0b4becf5ae

@ -91,15 +91,19 @@ bool hash_index_set( const char* index, const char* key, int value )
};
struct hash_index_entry* ptr = &new_entry;
/*
for( int i = 0; i < ari.entries.count; ++i ) {
struct reverse_index_entry* entry = ari.entries.items[i];
printf( "\tentry[%d] = { .uri = %s, .account_id = %d }\n", i, entry->uri, entry->account_id );
// Overwrite existing entries
for( int i = 0; i < hi.entries.count; ++i ) {
struct hash_index_entry* entry = hi.entries.items[i];
//printf( "\tentry[%d] = { .key = %s, .value = %d }\n", i, entry->key, entry->value );
if( 0 == strcmp( entry->key, key ) ) {
entry->value = value;
goto exists;
}
}
//*/
array_append( &hi.entries, sizeof(struct hash_index_entry), &ptr );
exists:
json_write_object_layout_to_file( filename, "\t", hash_index_layout, &hi );
for( int i = 0; i < hi.entries.count-1; ++i ) {

Loading…
Cancel
Save