unsigned long datastore_delete(datastore_t *ds, const char *key) { pthread_mutex_lock(&ds->mutex); datastore_entry_t *entry = dictionary_tfind(ds, key); if (entry == NULL) { pthread_mutex_unlock(&ds->mutex); return 0; } else { /* if (entry->rev != known_revision) { pthread_mutex_unlock(&ds->mutex); return 0; } */ dictionary_tdelete(ds, key); free((void *)entry->key); free((void *)entry->value); free(entry); pthread_mutex_unlock(&ds->mutex); return 1; } }
/** Internal use only. */ static int dictionary_remove_options(dictionary_t *d, const char *key, int free_memory) { dictionary_entry_t *entry = dictionary_tfind(d, key); if (entry == NULL) return NO_KEY_EXISTS; else { dictionary_tdelete(d, key); if (free_memory) { free((void *)entry->key); free((void *)entry->value); } free(entry); return 0; } }