Added dual-class PSRAM/TLSF allocator system and refactored memory management

Introduces a flexible two-class allocator architecture (RNS_DEFAULT_ALLOCATOR and RNS_CONTAINER_ALLOCATOR) supporting heap, PSRAM, and TLSF pool variants for fine-grained control over embedded memory layout.

- New Memory.h/cpp with ContainerAllocator<T>, heap/PSRAM/pool allocator types, and heap stats reporting
- IdentityTable and PathTable now use ContainerAllocator
- Replaced RNS_USE_TLSF/RNS_USE_ALLOCATOR/RNS_USE_PSRAM flags with per-class allocator flags (RNS_DEFAULT_ALLOCATOR, RNS_CONTAINER_ALLOCATOR)
- Added ESP32 PSRAM allocator support (RNS_PSRAM_ALLOCATOR, RNS_PSRAM_POOL_ALLOCATOR)
- Added Transport::get_path()/remove_path() helpers
- Added loop callback (set_loop_callback) to enable more responsive app during long operations (like clean_cache)
- Aded guard against re-entrancy to clean_cache()
- Added callback option to list_directory() to avoid heap allocation
- Added OOM auto-restart (ESP.restart/NVIC_SystemReset) in Interface send/receive and Reticulum loop.
- Renamed setLogCallback to set_log_callback
- Made Link/Identity static members private
- Added native14 env to CI and platformio.ini
- Bumped version to 0.2.10
This commit is contained in:
Chad Attermann 2026-03-06 16:43:04 -07:00
parent 49ccbc2827
commit 4d6f0b9de2
32 changed files with 1485 additions and 985 deletions

View file

@ -247,14 +247,13 @@ void UniversalFileSystem::listDir(const char* dir) {
//if (!file) {
File* file = new File(SPIFFS.open(file_path, mode));
if (file == nullptr || !(*file)) {
if (file != nullptr) delete file;
ERRORF("open_file: failed to open output file %s", file_path);
return {RNS::Type::NONE};
}
TRACEF("open_file: successfully opened file %s", file_path);
return RNS::FileStream(new UniversalFileStream(file));
#elif BOARD_NRF52
//File file = File(InternalFS);
File* file = new File(InternalFS);
int mode;
if (file_mode == RNS::FileStream::MODE_READ) {
mode = FILE_O_READ;
@ -274,7 +273,10 @@ void UniversalFileSystem::listDir(const char* dir) {
ERRORF("open_file: unsupported mode %d", file_mode);
return {RNS::Type::NONE};
}
if (!file->open(file_path, mode)) {
//File file = File(InternalFS);
File* file = new File(InternalFS);
if (file == nullptr || !file->open(file_path, mode)) {
if (file != nullptr) delete file;
ERRORF("open_file: failed to open output file %s", file_path);
return {RNS::Type::NONE};
}
@ -430,7 +432,7 @@ void UniversalFileSystem::listDir(const char* dir) {
#endif
}
/*virtua*/ std::list<std::string> UniversalFileSystem::list_directory(const char* directory_path) {
/*virtua*/ std::list<std::string> UniversalFileSystem::list_directory(const char* directory_path, Callbacks::DirectoryListing callback /*= nullptr*/) {
TRACEF("list_directory: listing directory %s", directory_path);
std::list<std::string> files;
#ifdef ARDUINO
@ -447,7 +449,8 @@ void UniversalFileSystem::listDir(const char* dir) {
while (file) {
if (!file.isDirectory()) {
char* name = (char*)file.name();
files.push_back(name);
if (callback) callback(name);
else files.push_back(name);
}
// CBA Following close required to avoid leaking memory
file.close();