MCPcopy Create free account
hub / github.com/RapidAI/RapidASR / aligned_malloc

Function aligned_malloc

cpp_onnx/src/alignedmem.cpp:2–13  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1#include "precomp.h"
2void *aligned_malloc(size_t alignment, size_t required_bytes)
3{
4 void *p1; // original block
5 void **p2; // aligned block
6 int offset = alignment - 1 + sizeof(void *);
7 if ((p1 = (void *)malloc(required_bytes + offset)) == NULL) {
8 return NULL;
9 }
10 p2 = (void **)(((size_t)(p1) + offset) & ~(alignment - 1));
11 p2[-1] = p1;
12 return p2;
13}
14
15void aligned_free(void *p)
16{

Callers 2

alloc_buffMethod · 0.85
loadparamsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected