From c91b514b0cd4af5c280017b7622b6fa016e7010c Mon Sep 17 00:00:00 2001 From: Tomasz Sobkiewicz Date: Wed, 8 Jan 2025 09:56:14 +0100 Subject: [PATCH] Add unused to lock Signed-off-by: Tomasz Sobkiewicz --- CHANGELOG.md | 1 + libs/estdlib/src/ets.erl | 10 ++++++++++ src/libAtomVM/ets.c | 3 ++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6db6dd9ca..d5bdb0b2a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added the ability to run beams from the CLI for Generic Unix platform (it was already possible with nodejs and emscripten). - Added support for 'erlang:--/2'. - Added support for list insertion in 'ets:insert/2'. +- Added support for 'ets:delete/1'. ### Fixed diff --git a/libs/estdlib/src/ets.erl b/libs/estdlib/src/ets.erl index 043c54cdc..9c8a4351f 100644 --- a/libs/estdlib/src/ets.erl +++ b/libs/estdlib/src/ets.erl @@ -29,6 +29,7 @@ insert/2, lookup/2, lookup_element/3, + delete/1, delete/2 ]). @@ -101,3 +102,12 @@ lookup_element(_Table, _Key, _Pos) -> -spec delete(Table :: table(), Key :: term()) -> true. delete(_Table, _Key) -> erlang:nif_error(undefined). +%%----------------------------------------------------------------------------- +%% @param Table a reference to the ets table +%% @returns true; otherwise, an error is raised if arguments are bad +%% @doc Delete an ets table. +%% @end +%%----------------------------------------------------------------------------- +-spec delete(Table :: table()) -> true. +delete(_Table) -> + erlang:nif_error(undefined). diff --git a/src/libAtomVM/ets.c b/src/libAtomVM/ets.c index 58dbd1eb8..907f205df 100644 --- a/src/libAtomVM/ets.c +++ b/src/libAtomVM/ets.c @@ -436,7 +436,8 @@ EtsErrorCode ets_drop_table(term name_or_ref, term *ret, Context *ctx) return EtsPermissionDenied; } - synclist_wrlock(&ctx->global->ets.ets_tables); + struct ListHead *_ets_tables_list = synclist_wrlock(&ctx->global->ets.ets_tables); + UNUSED(_ets_tables_list); SMP_UNLOCK(ets_table); list_remove(&ets_table->head); ets_table_destroy(ets_table, ctx->global);