extern "C" void* __cdecl _aligned_realloc_base( void* const block, size_t const size, size_t const alignment ) { return _aligned_offset_realloc_base(block, size, alignment, 0); }
extern "C" _CRTRESTRICT void* __cdecl _aligned_offset_realloc( void* const block, size_t const size, size_t const alignment, size_t const offset ) { #ifdef _DEBUG return _aligned_offset_realloc_dbg(block, size, alignment, offset, nullptr, 0); #else return _aligned_offset_realloc_base(block, size, alignment, offset); #endif }
extern "C" void* __cdecl _aligned_offset_recalloc_base( void* block, size_t count, size_t size, size_t align, size_t offset ) { size_t user_size = 0; /* wanted size, passed to aligned realoc */ size_t start_fill = 0; /* location where aligned recalloc starts to fill with 0 */ /* filling must start from the end of the previous user block */ void * retptr = nullptr; /* result of aligned recalloc*/ /* ensure that (size * num) does not overflow */ if (count > 0) { _VALIDATE_RETURN_NOEXC((_HEAP_MAXREQ / count) >= size, ENOMEM, nullptr); } user_size = size * count; if (block != nullptr) { start_fill = _aligned_msize(block, align, offset); } retptr = _aligned_offset_realloc_base(block, user_size, align, offset); if (retptr != nullptr) { if (start_fill < user_size) { memset ((char*)retptr + start_fill, 0, user_size - start_fill); } } return retptr; }
ALLOC_CALL void *__cdecl _aligned_offset_realloc(void *memblock, size_t size, size_t align, size_t offset) { return _aligned_offset_realloc_base( memblock, size, align, offset ); }