mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-03-22 04:34:44 +00:00
Fix TrackingAllocator reallocation_count being incremented on failed operations
The reallocation_count counter was being incremented regardless of whether the resize/remap operations succeeded. This led to inaccurate memory allocation statistics. - resize: Only increment when rawResize returns true (success) - remap: Only increment when rawRemap returns non-null (success) This fixes the TODO comments that were present in the code. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -501,7 +501,7 @@ pub const TrackingAllocator = struct {
|
|||||||
defer self.mutex.unlock();
|
defer self.mutex.unlock();
|
||||||
|
|
||||||
const result = self.parent_allocator.rawResize(old_mem, alignment, new_len, ra);
|
const result = self.parent_allocator.rawResize(old_mem, alignment, new_len, ra);
|
||||||
self.reallocation_count += 1; // TODO: only if result is not null?
|
if (result) self.reallocation_count += 1;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -531,7 +531,7 @@ pub const TrackingAllocator = struct {
|
|||||||
defer self.mutex.unlock();
|
defer self.mutex.unlock();
|
||||||
|
|
||||||
const result = self.parent_allocator.rawRemap(memory, alignment, new_len, ret_addr);
|
const result = self.parent_allocator.rawRemap(memory, alignment, new_len, ret_addr);
|
||||||
self.reallocation_count += 1; // TODO: only if result is not null?
|
if (result != null) self.reallocation_count += 1;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user