예제 #1
0
/** 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;
}
예제 #2
0
/** 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;
}
예제 #3
0
파일: kheap.c 프로젝트: 16Bitt/virtix
void* umalloc(size_t size){
	return malloc_internal(uheap, size);
}
예제 #4
0
파일: kheap.c 프로젝트: 16Bitt/virtix
void* kmalloc(uint size){
	if(kheap == NULL)
		return fmalloc(size);

	return malloc_internal(kheap, size);
}