Commit Graph

4 Commits

Author SHA1 Message Date
Michal Lenc 977f9ed4b8 libs/libc/obstack/lib_obstack_free.c: fix object check within chunk
The original condition incorrectly used &h->chunk instead of
h->chunk in the calculation whether the object is in the chunk. This
could lead to the wrong behavior as the first branch gave incorrect
result and thus sometimes the entire obstack was freed even though
object was not NULL.

The commit also simplifies the logic, we can use pointer arithmetic
here and just do h->chunk + 1 as it gives the same result as
(FAR char *)h->chunk + sizeof(struct _obstack_chunk). This saves
unnecessary cast and sizeof.

The second branch should be less than or equal, not just less than.
This ensures the object is correctly located in the chunk even after
previous obstack_finish was called.

Signed-off-by: Michal Lenc <michallenc@seznam.cz>
Co-authored-by: Karel Kočí <kkoci@elektroline.cz>
2025-12-13 18:13:19 -03:00
Alin Jerpelea 6b5dddd5d7 libs/libc: migrate to SPDX identifier
Most tools used for compliance and SBOM generation use SPDX identifiers
This change brings us a step closer to an easy SBOM generation.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2024-10-01 12:25:52 +08:00
Ville Juven 4781379ee2 obstack/obstack_free: Fix incorrect usage of void* for arithmetics
Using void* for arithmetics is a GCC extension, and thus should not be
used for portable code.
2022-11-23 23:22:06 +08:00
Karel Kočí 61b1791584 libs/libc: add obstack 2022-10-26 09:11:52 +08:00