Skip to content

Commit

Permalink
fixup! Use the new hashtable for core_namemap
Browse files Browse the repository at this point in the history
  • Loading branch information
t8m committed May 27, 2024
1 parent b30c189 commit 4795895
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions crypto/core_namemap.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,38 +245,31 @@ static int namemap_add_name(OSSL_NAMEMAP *namemap, int number,
const char *name)
{
int ret;
HT_VALUE *val = NULL;
HT_VALUE val = { 0 };
NAMENUM_KEY key;

/* If it already exists, we don't add it */
if ((ret = ossl_namemap_name2num(namemap, name)) != 0)
return ret;

if ((number = numname_insert(namemap, number, name)) == 0)
goto err;
return 0;

/* Using tsan_store alone here is safe since we're under lock */
tsan_store(&namemap->max_number, number);

HT_INIT_KEY(&key);
HT_SET_KEY_STRING_CASE(&key, name, name);
val = OPENSSL_zalloc(sizeof(*val));
if (val == NULL)
goto err;
val->value = (void *)(intptr_t)number;
ret = ossl_ht_insert(namemap->namenum_ht, TO_HT_KEY(&key), val, NULL);
val.value = (void *)(intptr_t)number;
ret = ossl_ht_insert(namemap->namenum_ht, TO_HT_KEY(&key), &val, NULL);
if (!ossl_assert(ret != 0)) /* cannot happen as we are under write lock */
goto err;
return 0;
if (ret < 1) {
/* unable to insert due to too many collisions */
ERR_raise(ERR_LIB_CRYPTO, CRYPTO_R_TOO_MANY_NAMES);
goto err;
return 0;
}
return number;

err:
OPENSSL_free(val);
return 0;
}

int ossl_namemap_add_name(OSSL_NAMEMAP *namemap, int number,
Expand Down

0 comments on commit 4795895

Please sign in to comment.