MCPcopy Create free account
hub / github.com/SakuraEngine/SakuraEngine / calloc_aligned

Function calloc_aligned

modules/core/core/src/core/memory/memory.c:44–62  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42#include <string.h>
43
44SKR_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
64static const char* kDefaultOSAllocPoolName = "sakura::os_alloc";
65

Callers 1

traced_os_calloc_alignedFunction · 0.85

Calls 2

memsetFunction · 0.85
mallocFunction · 0.50

Tested by

no test coverage detected