Converted log calls across src/, examples/, and test/ to use DEBUGF/TRACEF/ERRORF/etc. macros instead of std::string + operator+. This eliminates temporary heap allocations on every log call, which matters on memory-constrained MCUs.
- 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
- Transport::inbound(): pre-emptive cull before destination-table insert;
try/catch around insert for explicit OOM diagnostics
- Transport::jobs(): split stale-entry culling into 5 independent
per-phase try/catch blocks so a failure in one phase doesn't abort
the others; reserve() before push_back loops in each phase
- cull_path_table()/cull_known_destinations(): std::min_element fallback
when sort-index allocation fails, breaking the cull-OOM-still-full loop
- Identity::remember(): wrapped _known_destinations.insert in try/catch
for explicit OOM diagnostic logging
- Destination::announce(): outer try/catch covers all OOM-prone ops
(Bytes concat, sign, Packet ctor, send); inner _path_responses.insert
catch preserved for degraded-mode behavior
- Packet::unpack(): dedicated std::bad_alloc catch returns false cleanly
- Type.h: MAX_RECEIPTS and MAX_QUEUED_ANNOUNCES now overridable at
compile time via RNS_RECEIPTS_MAX / RNS_QUEUED_ANNOUNCES_MAX
- Transport.h: hashlist_maxsize and max_pr_tags exposed as runtime
accessors for dynamic capacity tuning
Fix for link validation failure when poackets contain new MTU in payload
from RNS 1.0 (courtesy of @jlpoolen).
Optimization of announce re-broadcasts from RNS 1.0.
Added support for new `context_flag` in RNS packet header that is used
to indicate the use of ratchets.
Note that ratchet support is still missing from the implementation, but
this fix enables received ratchets to be able to handled gracefully.
Tests for Bytes::assignHex, appendHex, mid() edge cases, and
Transport receipt culling logic. 18 test cases covering the bugs
fixed in the previous commit.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Bytes::assignHex/appendHex: truncate to even length before parsing
to prevent reading past buffer on odd-length hex strings
- Bytes::mid(): fix off-by-one in bounds check (>= vs >)
- Transport: fix receipt culling loop iterating wrong list, which
caused stale receipts to accumulate instead of being removed
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Changed a few key logs to use printf-style instead of string
concatenation to avoid dynamic memory allocation. Still need to move
all remaining logging over to printf-style.
Added option (-DRNS_USE_ALLOCATOR=1) to override new/delete operators for
both allocation metrics and the ability to implement an alternate memory
allocator.
Added option (-DRNS_USE_TLSF=1) to use the alternate TLSF allocator
(must also define RNS_USE_ALLOCATOR). This allocator is well known for
reducing fragmentation and providing constant, O(1)-time allocation
and deallocation for real-time embedded systems.
This TLSF allocator appears to already be the default allocator for
ESP32 boards, but the allocator used by NRF52 is unknown at this time so
the TLSF allocator internal to microReticulum is only being used for
NRF52 boards at this time.
Future memory management improvements will include custom allocators for
long-lived structures like the path table that will segregate them from
the general pool of memory that is constantly cycling, thereby further
reducing fragmentation. It will also allow these structures to use
alternate memory like PSRAM present on T-Beam boards.