Add announce table culling, fix use-after-free, and refactor build/log

- Add cull_announce_table() with OOM-safe min_element fallback, matching pattern from cull_path_table() and cull_known_destinations()
- Call cull immediately after every announce/path/known-destination insert
- Fix use-after-free: guard announce_entry access with announce_erased flag
- remove_path() now also deletes cached packet files
- Path table insert now removes existing entry first to prevent duplicates
- Rename env:mcu -> env:embedded; add env:native_debug and heltec_wifi_lora_32_V4
- Make TLSF buffer size configurable via RNS_TLSF_BUFFER_SIZE macro
- Refactor log macros to unified RNS::log() path; add doHeadLog with callback support
- Prefix all bad_alloc error messages with "bad_alloc -" for easier grepping
This commit is contained in:
Chad Attermann committed 2026-02-28 19:54:15 -07:00
1 parent 086aac87b5
commit e86481e121
15 files changed
+891 -403

No files matched your search

+6 -2
View File
@@ -201,9 +201,11 @@ Can be used to load previously created and saved identities into Reticulum.
// CBA ACCUMULATES
try {
_known_destinations.insert({destination_hash, {OS::time(), packet_hash, public_key, app_data}});
// CBA IMMEDIATE CULL
cull_known_destinations();
}
catch (const std::bad_alloc&) {
ERROR("remember: out of memory, identity not stored for " + destination_hash.toHex());
ERROR("remember: bad_alloc - out of memory, identity not stored for " + destination_hash.toHex());
}
catch (const std::exception& e) {
ERROR(std::string("remember: exception storing identity: ") + e.what());
@@ -306,6 +308,8 @@ Recall last heard app_data for a destination hash.
//_known_destinations[destination_hash] = identity_entry;
// CBA ACCUMULATES
_known_destinations.insert({destination_hash, identity_entry});
// CBA IMMEDIATE CULL
cull_known_destinations();
}
}
@@ -390,7 +394,7 @@ Recall last heard app_data for a destination hash.
DEBUG("Removed " + std::to_string(count) + " path(s) from known destinations");
}
catch (const std::bad_alloc& e) {
ERROR("cull_known_destinations: out of memory building sort index, falling back to single erase");
ERROR("cull_known_destinations: bad_alloc - out of memory building sort index, falling back to single erase");
// Fallback: std::min_element does no heap allocation — erase one oldest entry
auto oldest = std::min_element(
_known_destinations.begin(), _known_destinations.end(),