Put guards in place around debug heap operations (#7955)

* Put guards in place around debug heap operations

* Add macros to clean up code

* Add pointer as well
This commit is contained in:
Ben Meadors
2025-09-11 07:57:42 -05:00
committed by GitHub
parent abc0eb196a
commit e17c50bb86
7 changed files with 46 additions and 24 deletions

View File

@@ -44,11 +44,10 @@ void NodeInfoModule::sendOurNodeInfo(NodeNum dest, bool wantReplies, uint8_t cha
if (prevPacketId) // if we wrap around to zero, we'll simply fail to cancel in that rare case (no big deal)
service->cancelSending(prevPacketId);
shorterTimeout = _shorterTimeout;
auto heapBefore = memGet.getFreeHeap();
DEBUG_HEAP_BEFORE;
meshtastic_MeshPacket *p = allocReply();
auto heapAfter = memGet.getFreeHeap();
DEBUG_HEAP_AFTER("NodeInfoModule::sendOurNodeInfo", p);
LOG_HEAP("Alloc in NodeInfoModule::sendOurNodeInfo pointer 0x%x, size: %u, free: %u", p, heapBefore - heapAfter, heapAfter);
if (p) { // Check whether we didn't ignore it
p->to = dest;
p->decoded.want_response = (config.device.role != meshtastic_Config_DeviceConfig_Role_TRACKER &&

View File

@@ -172,11 +172,9 @@ bool DeviceTelemetryModule::sendTelemetry(NodeNum dest, bool phoneOnly)
telemetry.variant.device_metrics.battery_level, telemetry.variant.device_metrics.voltage,
telemetry.variant.device_metrics.uptime_seconds);
auto heapBefore = memGet.getFreeHeap();
DEBUG_HEAP_BEFORE;
meshtastic_MeshPacket *p = allocDataProtobuf(telemetry);
auto heapAfter = memGet.getFreeHeap();
LOG_HEAP("Alloc in DeviceTelemetryModule::sendTelemetry() pointer 0x%x, size: %u, free: %u", p, heapBefore - heapAfter,
heapAfter);
DEBUG_HEAP_AFTER("DeviceTelemetryModule::sendTelemetry", p);
p->to = dest;
p->decoded.want_response = false;