mirror of
https://github.com/TREX-CoE/qmckl.git
synced 2024-07-19 01:13:50 +02:00
3.2 KiB
3.2 KiB
Memory management
We override the allocation functions to enable the possibility of optimized libraries to fine-tune the memory allocation.
3 files are produced:
- a header file :
qmckl_memory.h
- a source file :
qmckl_memory.c
- a test file :
test_qmckl_memory.c
qmckl_malloc
Analogous of malloc, but passing a context and a signed 64-bit integers as argument.
Header
void* qmckl_malloc(const qmckl_context ctx, const size_t size);
Source
void* qmckl_malloc(const qmckl_context ctx, const size_t size) {
if (ctx == (qmckl_context) 0) {
/* Avoids unused parameter error */
return malloc( (size_t) size );
}
return malloc( (size_t) size );
}
qmckl_free
Header
void qmckl_free(void *ptr);
Source
void qmckl_free(void *ptr) {
free(ptr);
}