Skip to content

Commit

Permalink
xglobals: Add __MCF_mresize_0()
Browse files Browse the repository at this point in the history
  • Loading branch information
lhmouse committed Dec 6, 2024
1 parent 1d0fe6f commit d46aa3c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion mcfgthread/thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ _MCF_thread_new_aligned(_MCF_thread_procedure* proc, size_t align, const void* d

size_request = (uintptr_t) thrd->__data_opt + size - (uintptr_t) thrd;
__MCF_ASSERT(size_need <= size_request);
HeapReAlloc(__MCF_crt_heap, HEAP_REALLOC_IN_PLACE_ONLY, thrd, size_request);
__MCF_mresize_0(thrd, size_request);
}

/* Copy user-defined data. If this doesn't happen, they are implicit zeroes. */
Expand Down
14 changes: 14 additions & 0 deletions mcfgthread/xglobals.h
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,13 @@ __MCF_XGLOBALS_INLINE
void*
__MCF_malloc_0(size_t size) __attribute__((__malloc__, __alloc_size__(1)));

/* Set the size a block of memory in place, like `truncate()` on files.
* If the existent block should be extended, vacuum bytes are filled with
* zeroes. */
__MCF_XGLOBALS_INLINE
void*
__MCF_mresize_0(void* ptr, size_t size) __attribute__((__alloc_size__(2)));

/* Re-allocate a block of memory, like `realloc()`. If the existent
* block should be extended, vacuum bytes are filled with zeroes. */
__MCF_XGLOBALS_INLINE
Expand Down Expand Up @@ -489,6 +496,13 @@ __MCF_malloc_0(size_t size)
return HeapAlloc(__MCF_crt_heap, HEAP_ZERO_MEMORY, size);
}

__MCF_XGLOBALS_INLINE
void*
__MCF_mresize_0(void* ptr, size_t size)
{
return HeapReAlloc(__MCF_crt_heap, HEAP_ZERO_MEMORY | HEAP_REALLOC_IN_PLACE_ONLY, ptr, size);
}

__MCF_XGLOBALS_INLINE
void*
__MCF_mrealloc_0(void** pptr, size_t size)
Expand Down

0 comments on commit d46aa3c

Please sign in to comment.