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 836d46406..71b4a50c7 100644 --- a/src/libAtomVM/ets.c +++ b/src/libAtomVM/ets.c @@ -431,7 +431,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);