| 3475 | } |
| 3476 | |
| 3477 | extern inline RPMALLOC_ALLOCATOR void* |
| 3478 | rpmalloc_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 | |
| 3503 | extern inline RPMALLOC_ALLOCATOR void* |
| 3504 | rpmalloc_heap_realloc(rpmalloc_heap_t* heap, void* ptr, size_t size, unsigned int flags) { |
no test coverage detected