Skip to content

Commit

Permalink
fix memory counting without custom allocator (vercel/turborepo#8102)
Browse files Browse the repository at this point in the history
### Description

<!--
  ✍️ Write a short summary of your work.
  If necessary, include relevant screenshots.
-->

### Testing Instructions

<!--
  Give a quick description of steps to test your changes.
-->


Closes PACK-3044
  • Loading branch information
sokra committed May 7, 2024
1 parent bcc92c3 commit ab1bae1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions crates/turbo-tasks-malloc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ unsafe impl GlobalAlloc for TurboMalloc {

unsafe fn alloc_zeroed(&self, layout: Layout) -> *mut u8 {
let ret = mimalloc::MiMalloc.alloc_zeroed(layout);
if ret.is_null() {
if !ret.is_null() {
add(layout.size());
}
ret
Expand Down Expand Up @@ -82,7 +82,7 @@ unsafe impl GlobalAlloc for TurboMalloc {

unsafe fn alloc_zeroed(&self, layout: Layout) -> *mut u8 {
let ret = std::alloc::System.alloc_zeroed(layout);
if ret.is_null() {
if !ret.is_null() {
add(layout.size());
}
ret
Expand Down

0 comments on commit ab1bae1

Please sign in to comment.