-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommon.c
More file actions
26 lines (23 loc) · 674 Bytes
/
common.c
File metadata and controls
26 lines (23 loc) · 674 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include "common.h"
#include <stdlib.h>
//!malloc wrapper
void *fast_alloc_malloc(size_t size, void *params) {
params = 0; //remove unused variable compiler warnings
return malloc(size);
}
//!free wrapper
void fast_alloc_free(void* tofree, void *params) {
params = 0; //remove unused variable compiler warnings
free(tofree);
}
//!assures block size is aligned to sizeof(void *)
size_t pad_size_to(size_t initial, size_t align) {
if (initial <= align)
return align;
if ((initial % align) == 0)
return initial;
return initial + align - (initial % align);
}
size_t pad_size(size_t initial) {
return pad_size_to(initial, 8);
}