MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / rpmalloc_heap_aligned_calloc

Function rpmalloc_heap_aligned_calloc

source/extern/rpmalloc.c:3477–3501  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3475}
3476
3477extern inline RPMALLOC_ALLOCATOR void*
3478rpmalloc_heap_aligned_calloc(rpmalloc_heap_t* heap, size_t alignment, size_t num, size_t size) {
3479 size_t total;
3480#if ENABLE_VALIDATE_ARGS
3481#if PLATFORM_WINDOWS
3482 int err = SizeTMult(num, size, &total);
3483 if ((err != S_OK) || (total >= MAX_ALLOC_SIZE)) {
3484 errno = EINVAL;
3485 return 0;
3486 }
3487#else
3488 int err = __builtin_umull_overflow(num, size, &total);
3489 if (err || (total >= MAX_ALLOC_SIZE)) {
3490 errno = EINVAL;
3491 return 0;
3492 }
3493#endif
3494#else
3495 total = num * size;
3496#endif
3497 void* block = _rpmalloc_aligned_allocate(heap, alignment, total);
3498 if (block)
3499 memset(block, 0, total);
3500 return block;
3501}
3502
3503extern inline RPMALLOC_ALLOCATOR void*
3504rpmalloc_heap_realloc(rpmalloc_heap_t* heap, void* ptr, size_t size, unsigned int flags) {

Callers 1

rpmalloc_heap_callocFunction · 0.85

Calls 1

Tested by

no test coverage detected