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

@@ -193,11 +193,9 @@ void MeshService::handleToRadio(meshtastic_MeshPacket &p)
// (so we update our nodedb for the local node)
// Send the packet into the mesh
auto heapBefore = memGet.getFreeHeap();
DEBUG_HEAP_BEFORE;
auto a = packetPool.allocCopy(p);
auto heapAfter = memGet.getFreeHeap();
LOG_HEAP("Alloc in MeshService::handleToRadio() pointer 0x%x, size: %u, free: %u", a, heapBefore - heapAfter, heapAfter);
DEBUG_HEAP_AFTER("MeshService::handleToRadio", a);
sendToMesh(a, RX_SRC_USER);
bool loopback = false; // if true send any packet the phone sends back itself (for testing)
@@ -254,10 +252,9 @@ void MeshService::sendToMesh(meshtastic_MeshPacket *p, RxSource src, bool ccToPh
}
if ((res == ERRNO_OK || res == ERRNO_SHOULD_RELEASE) && ccToPhone) { // Check if p is not released in case it couldn't be sent
auto heapBefore = memGet.getFreeHeap();
DEBUG_HEAP_BEFORE;
auto a = packetPool.allocCopy(*p);
auto heapAfter = memGet.getFreeHeap();
LOG_HEAP("Alloc in MeshService::sendToMesh() pointer 0x%x, size: %u, free: %u", a, heapBefore - heapAfter, heapAfter);
DEBUG_HEAP_AFTER("MeshService::sendToMesh", a);
sendToPhone(a);
}