mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-18 12:52:44 +01:00
Merge pull request #15844 from benpicco/sys/oneway-malloc_align
sys/oneway-malloc: only allocate word-aligned chunks
This commit is contained in:
commit
1862a73d41
@ -20,15 +20,23 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "architecture.h"
|
||||
#include "malloc.h"
|
||||
|
||||
#define ENABLE_DEBUG 0
|
||||
#include "debug.h"
|
||||
|
||||
#define ARCHITECTURE_WORD_MASK (ARCHITECTURE_WORD_BYTES - 1)
|
||||
|
||||
extern void *sbrk(int incr);
|
||||
|
||||
void __attribute__((weak)) *malloc(size_t size)
|
||||
{
|
||||
/* ensure we always allocate word-aligned blocks */
|
||||
if (size & ARCHITECTURE_WORD_MASK) {
|
||||
size += ARCHITECTURE_WORD_BYTES - (size & ARCHITECTURE_WORD_MASK);
|
||||
}
|
||||
|
||||
if (size != 0) {
|
||||
void *ptr = sbrk(size);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user