Simplifies the code a bit. These hashes are all string-keyed.
* so set 'errno' to 0 before this ops are made. The 'obj' won't be freed,
* this is the caller's responsibility.
*
- * TODO I think most of the code is not checking this.
- *
* Functions that can OOM:
*
* HASH_ADD_TO_TABLE
* HASH_ADD_KEYPTR_BYHASHVALUE
* HASH_REPLACE_BYHASHVALUE
* HASH_REPLACE (*)
- * HASH_ADD_KEYPTR (**)
+ * HASH_REPLACE_STR (**)
+ * HASH_REPLACE_INT
+ * HASH_REPLACE_PTR
+ * HASH_ADD_KEYPTR
* HASH_ADD
* HASH_ADD_BYHASHVALUE
* HASH_SELECT
*
* (*) Used by Fort
- * (**) Used by Fort, but in its fatal uthash form.
+ * (**) Used by Fort, but only in its fatal uthash form.
*/
#define HASH_NONFATAL_OOM 1
#define uthash_nonfatal_oom(obj) \
(working_repo_peek_level() <= LOG_REPO_LEVEL);
rwlock_write_lock(&db_lock);
- HASH_ADD_KEYPTR(hh, err_uris_db, new_uri->uri, strlen(new_uri->uri),
- new_uri);
+ HASH_ADD_STR(err_uris_db, uri, new_uri);
rwlock_unlock(&db_lock);
return 0;
{
struct uris_table *old_uri;
- /*
- * TODO (fine) this should use HASH_REPLACE instead of HASH_ADD_KEYPTR
- */
-
- old_uri = find_rrdp_uri(uris, new_uri->uri);
- if (old_uri != NULL) {
- HASH_DELETE(hh, uris->table, old_uri);
+ HASH_REPLACE_STR(uris->table, uri, new_uri, old_uri);
+ if (old_uri != NULL)
uris_table_destroy(old_uri);
- }
- HASH_ADD_KEYPTR(hh, uris->table, new_uri->uri, strlen(new_uri->uri),
- new_uri);
}
static int
if (error)
return error;
- HASH_ADD_KEYPTR(hh, uris->table, elem->uri, strlen(elem->uri),
- elem);
-
+ HASH_ADD_STR(uris->table, uri, elem);
return 0;
}