mirror of
https://github.com/amadvance/snapraid.git
synced 2026-10-26 10:51:54 -04:00
Renames ALIGN to avoid conflicts in some architectures.
This commit is contained in:
parent
bec047b0b3
commit
0e52776ecb
1 changed files with 8 additions and 4 deletions
12
util.c
12
util.c
|
|
@ -1323,19 +1323,23 @@ void* malloc_nofail(size_t size)
|
|||
return ptr;
|
||||
}
|
||||
|
||||
#define ALIGN 256
|
||||
/**
|
||||
* Memory alignment provided by malloc_nofail_align().
|
||||
* It should guarantee good cache performance everywhere.
|
||||
*/
|
||||
#define MALLOC_NOFAIL_ALIGN 256
|
||||
|
||||
void* malloc_nofail_align(size_t size, void** freeptr)
|
||||
{
|
||||
unsigned char* ptr = malloc_nofail(size + ALIGN);
|
||||
unsigned char* ptr = malloc_nofail(size + MALLOC_NOFAIL_ALIGN);
|
||||
uintptr_t offset;
|
||||
|
||||
*freeptr = ptr;
|
||||
|
||||
offset = ((uintptr_t)ptr) % ALIGN;
|
||||
offset = ((uintptr_t)ptr) % MALLOC_NOFAIL_ALIGN;
|
||||
|
||||
if (offset != 0) {
|
||||
ptr += ALIGN - offset;
|
||||
ptr += MALLOC_NOFAIL_ALIGN - offset;
|
||||
}
|
||||
|
||||
return ptr;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue