| 42 | #include <string.h> |
| 43 | |
| 44 | SKR_FORCEINLINE static void* calloc_aligned(size_t count, size_t size, size_t alignment) |
| 45 | { |
| 46 | #if !defined(_WIN32) |
| 47 | void* ptr = (alignment == 1) ? malloc(size * count) : NULL; |
| 48 | if (!ptr) |
| 49 | { |
| 50 | alignment = (alignment > 16) ? alignment : 16; |
| 51 | ptr = aligned_alloc(alignment, size * count); |
| 52 | } |
| 53 | if (!ptr) |
| 54 | { |
| 55 | posix_memalign(&ptr, alignment, size * count); |
| 56 | } |
| 57 | #else |
| 58 | void* ptr = _aligned_malloc(size * count, alignment); |
| 59 | #endif |
| 60 | memset(ptr, 0, size * count); |
| 61 | return ptr; |
| 62 | } |
| 63 | |
| 64 | static const char* kDefaultOSAllocPoolName = "sakura::os_alloc"; |
| 65 |
no test coverage detected