/** Allocate memory * * @param size Number of bytes to allocate. * * @return Allocated memory or NULL. * */ void *malloc(const size_t size) { futex_down(&malloc_futex); void *block = malloc_internal(size, BASE_ALIGN); futex_up(&malloc_futex); return block; }
/** Allocate memory with specified alignment * * @param align Alignment in byes. * @param size Number of bytes to allocate. * * @return Allocated memory or NULL. * */ void *memalign(const size_t align, const size_t size) { if (align == 0) return NULL; size_t palign = 1 << (fnzb(max(sizeof(void *), align) - 1) + 1); futex_down(&malloc_futex); void *block = malloc_internal(size, palign); futex_up(&malloc_futex); return block; }
void* umalloc(size_t size){ return malloc_internal(uheap, size); }
void* kmalloc(uint size){ if(kheap == NULL) return fmalloc(size); return malloc_internal(kheap, size); }