コード例 #1
0
ファイル: malloc.c プロジェクト: nbdd0121/norlit-libc
void *malloc(size_t size) {
	void* ret = allocator_malloc(allocator_get_global(), size);
	if (!ret) {
		errno = ENOMEM;
	}
	return ret;
}
コード例 #2
0
ファイル: realloc.c プロジェクト: wangyangmoc/norlit-libc
void *realloc(void *ptr, size_t size) {
	void* ret = allocator_realloc(allocator_get_global(), ptr, size);
	if (!ret) {
		errno = ENOMEM;
	}
	return ret;
}
コード例 #3
0
ファイル: posix_memalign.c プロジェクト: nbdd0121/norlit-libc
int posix_memalign(void **memptr, size_t alignment, size_t size) {
	if ((1 << log2_int(alignment)) != alignment) {
		return EINVAL;
	}
	*memptr = allocator_aligned_alloc(allocator_get_global(), alignment, size);
	if (!*memptr) {
		return ENOMEM;
	}
	return 0;
}
コード例 #4
0
ファイル: aligned_alloc.c プロジェクト: nbdd0121/norlit-libc
void *aligned_alloc(size_t alignment, size_t size) {
	if ((1 << log2_int(alignment)) != alignment) {
		errno = EINVAL;
		return NULL;
	}
	void* ret = allocator_aligned_alloc(allocator_get_global(), alignment, size);
	if (!ret) {
		errno = ENOMEM;
	}
	return ret;
}