mbed-os/platform
Kevin Bracey 5ab6f1cef6 Make readdir reentrant
Remove the static allocation for the dirent, and allocate it from the
heap during opendir().

Removing the static data can reduce RAM usage on some toolchains when
directories are not being used. The static allocation sometimes is
combined with the file handle array and can't be dropped by the linker.

Original readdir() was not thread-safe at all.

This was in violation of POSIX which states the result of readdir "is
not overwritten by another call to readdir() on a different directory
stream."

POSIX also defines readdir_r() as separate totally reentrant form where
the caller allocates the dirent, but this is generally deprecated as it
opens the door for an inadequate allocation causing a stack smash. Full
reentrancy is not typically necessary - having readdir()'s buffer data
be per-DIR is generally sufficient.
2020-09-04 16:58:23 +03:00
..
FEATURE_EXPERIMENTAL_API Move FEATURE_EXPERIMENTAL_API for PSA to platform 2020-08-21 14:35:10 +01:00
bare_metal Add "rtos-api" to bare metal 2020-03-16 11:40:49 +00:00
cxxsupport mstd_mutex: Add missing Chrono bits 2020-04-27 10:19:08 +03:00
include/platform Make readdir reentrant 2020-09-04 16:58:23 +03:00
source Make readdir reentrant 2020-09-04 16:58:23 +03:00
tests Move mbed_functional tests into platform/tests/TESTS 2020-08-14 17:53:19 +01:00
mbed_lib.json Force callback non-trivial for IAR 2020-05-25 15:29:27 +02:00