Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Duet3D/RepRapFirmware.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Crocker <dcrocker@eschertech.com>2021-03-07 16:22:55 +0300
committerDavid Crocker <dcrocker@eschertech.com>2021-03-07 16:22:55 +0300
commitd40f1bcb0248c280975d13d57bfdb0d0c16c9252 (patch)
tree07a2b11a1ba949a574d7b7b02429f850ba2298e1 /src/Platform
parentb4f04a76ef0dc8a6ac7a1ec1f34dd5d5b8d91ebf (diff)
Fix to garbage collector
Diffstat (limited to 'src/Platform')
-rw-r--r--src/Platform/Heap.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/Platform/Heap.cpp b/src/Platform/Heap.cpp
index b38bada4..2f74b8b9 100644
--- a/src/Platform/Heap.cpp
+++ b/src/Platform/Heap.cpp
@@ -88,11 +88,11 @@ unsigned int StringHandle::gcCyclesDone = 0;
while (p < currentBlock->data + currentBlock->allocated)
{
const size_t len = reinterpret_cast<StorageSpace*>(p)->length;
- if (len & 1) // if this slot has been marked as free
+ if (len & 1u) // if this slot has been marked as free
{
break;
}
- p += (len & ~1u) + sizeof(StorageSpace::length);
+ p += len + sizeof(StorageSpace::length);
}
if (p < currentBlock->data + currentBlock->allocated) // if we found an unused block before we reached the end
@@ -104,8 +104,8 @@ unsigned int StringHandle::gcCyclesDone = 0;
// Find the end of the unused blocks
while (p < currentBlock->data + currentBlock->allocated)
{
- size_t len = reinterpret_cast<StorageSpace*>(p)->length;
- if ((len & 1) == 0)
+ const size_t len = reinterpret_cast<StorageSpace*>(p)->length;
+ if ((len & 1u) == 0)
{
break;
}
@@ -124,18 +124,18 @@ unsigned int StringHandle::gcCyclesDone = 0;
unsigned int numHandlesToAdjust = 0;
while (p < currentBlock->data + currentBlock->allocated)
{
- size_t len = reinterpret_cast<StorageSpace*>(p)->length;
- if ((len & 1) == 0)
+ const size_t len = reinterpret_cast<StorageSpace*>(p)->length;
+ if (len & 1u)
{
break;
}
++numHandlesToAdjust;
- p += (len & ~1u) + sizeof(StorageSpace::length);
+ p += len + sizeof(StorageSpace::length);
}
// Move the contiguous blocks down
- //TODO make this more efficient by building up a small table f several adjustments, so we need to make fewer passes through the index
memmove(startSkip, startUsed, p - startUsed);
+ //TODO make this more efficient by building up a small table of several adjustments, so we need to make fewer passes through the index
AdjustHandles(startUsed, p, startUsed - startSkip, numHandlesToAdjust);
startSkip += p - startUsed;
}