Remove aligned_alloc from libc allocator since it's not implemented on Windows
This commit is contained in:
parent
d8c7b3162f
commit
1ddc5610f9
@ -5,18 +5,21 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
internal inline void *mem_libc_alloc(u64 size, void *alloc_obj);
|
internal inline void *mem_libc_alloc(u64 size, void *alloc_obj);
|
||||||
|
// TODO (Abdelrahman): aligned_alloc isn't implemented on Windows. Revisit later
|
||||||
|
#if 0
|
||||||
internal inline void *mem_libc_alloc_aligned(u64 size, u64 alignment, void *alloc_obj);
|
internal inline void *mem_libc_alloc_aligned(u64 size, u64 alignment, void *alloc_obj);
|
||||||
|
#endif
|
||||||
internal inline void *mem_libc_realloc(void *ptr, u64 old_size, u64 new_size, void *alloc_obj);
|
internal inline void *mem_libc_realloc(void *ptr, u64 old_size, u64 new_size, void *alloc_obj);
|
||||||
internal inline void mem_libc_free(void **ptr, void *alloc_obj);
|
internal inline void mem_libc_free(void **ptr, void *alloc_obj);
|
||||||
|
|
||||||
Allocator wapp_mem_libc_allocator(void) {
|
Allocator wapp_mem_libc_allocator(void) {
|
||||||
return (Allocator){
|
return (Allocator){
|
||||||
.obj = NULL,
|
.obj = NULL,
|
||||||
.alloc = mem_libc_alloc,
|
.alloc = mem_libc_alloc,
|
||||||
.alloc_aligned = mem_libc_alloc_aligned,
|
.alloc_aligned = NULL,
|
||||||
.realloc = mem_libc_realloc,
|
.realloc = mem_libc_realloc,
|
||||||
.realloc_aligned = NULL,
|
.realloc_aligned = NULL,
|
||||||
.free = mem_libc_free,
|
.free = mem_libc_free,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -24,6 +27,7 @@ internal inline void *mem_libc_alloc(u64 size, void *alloc_obj) {
|
|||||||
return calloc(1, size);
|
return calloc(1, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
internal inline void *mem_libc_alloc_aligned(u64 size, u64 alignment,
|
internal inline void *mem_libc_alloc_aligned(u64 size, u64 alignment,
|
||||||
void *alloc_obj) {
|
void *alloc_obj) {
|
||||||
void *output = aligned_alloc(alignment, size);
|
void *output = aligned_alloc(alignment, size);
|
||||||
@ -33,6 +37,7 @@ internal inline void *mem_libc_alloc_aligned(u64 size, u64 alignment,
|
|||||||
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
internal inline void *mem_libc_realloc(void *ptr, u64 old_size, u64 new_size, void *alloc_obj) {
|
internal inline void *mem_libc_realloc(void *ptr, u64 old_size, u64 new_size, void *alloc_obj) {
|
||||||
return realloc(ptr, old_size);
|
return realloc(ptr, old_size);
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
TestFuncResult test_libc_allocator(void) {
|
TestFuncResult test_libc_allocator(void) {
|
||||||
Allocator allocator = wapp_mem_libc_allocator();
|
Allocator allocator = wapp_mem_libc_allocator();
|
||||||
bool result = allocator.obj == NULL && allocator.alloc != NULL &&
|
bool result = allocator.obj == NULL && allocator.alloc != NULL &&
|
||||||
allocator.alloc_aligned != NULL && allocator.realloc != NULL &&
|
allocator.alloc_aligned == NULL && allocator.realloc != NULL &&
|
||||||
allocator.realloc_aligned == NULL && allocator.free != NULL;
|
allocator.realloc_aligned == NULL && allocator.free != NULL;
|
||||||
void *ptr = wapp_mem_allocator_alloc(&allocator, 20);
|
void *ptr = wapp_mem_allocator_alloc(&allocator, 20);
|
||||||
result = result && (ptr != NULL);
|
result = result && (ptr != NULL);
|
||||||
|
Loading…
Reference in New Issue
Block a user