コード例 #1
0
ファイル: malloc.c プロジェクト: pratikmankawde/HelenOS_Nano
/** 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
ファイル: malloc.c プロジェクト: pratikmankawde/HelenOS_Nano
/** 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);
}