Skip to content

Commit

Permalink
Merge pull request #892 from bettio/atom-table-revamp
Browse files Browse the repository at this point in the history
New atom table implementation

Implement new atom table that overcomes previous implementation shortcomings.

Some further improvements are not part of this PR and they will be addressed
with further PRs, such as:

- Using gperf for default atoms
- Removing `atom_table_get_atom_string`
- Coalescing together atom strings that are allocated on the heap (instead of
using `strdup`)

These changes are made under both the "Apache 2.0" and the "GNU Lesser General
Public License 2.1 or later" license terms (dual license).

SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later
  • Loading branch information
bettio committed Dec 24, 2023
2 parents 9839e23 + 9e76b00 commit 273513f
Show file tree
Hide file tree
Showing 15 changed files with 970 additions and 194 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Shorten UART config options, such as `tx_pin` -> `tx`
- Introduced support to non-integer peripheral names, `"i2c0"`, `"uart1"` (instead of just `0` and
- `1`, which now they are deprecated)
- New atom table, which uses less memory, has improved performances and better code.

## [0.6.0-alpha.2] - 2023-12-10

Expand Down
2 changes: 2 additions & 0 deletions src/libAtomVM/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ project (libAtomVM)
set(HEADER_FILES
atom.h
atomshashtable.h
atom_table.h
avmpack.h
bif.h
bitstring.h
Expand Down Expand Up @@ -69,6 +70,7 @@ set(HEADER_FILES
set(SOURCE_FILES
atom.c
atomshashtable.c
atom_table.c
avmpack.c
bif.c
bitstring.c
Expand Down
2 changes: 1 addition & 1 deletion src/libAtomVM/atom.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ void atom_string_to_c(AtomString atom_string, char *buf, size_t bufsize)
{
size_t atom_len = *((const uint8_t *) atom_string);

if (bufsize < atom_len) {
if (bufsize <= atom_len) {
atom_len = bufsize - 1;
}
memcpy(buf, ((const uint8_t *) atom_string) + 1, atom_len);
Expand Down
Loading

0 comments on commit 273513f

Please sign in to comment.