Initial commit
This commit is contained in:
29
src/allocator.c
Normal file
29
src/allocator.c
Normal file
@@ -0,0 +1,29 @@
|
||||
#include "allocator.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
static void *stdlib_alloc(void *ctx, size_t size) {
|
||||
(void)ctx;
|
||||
return malloc(size);
|
||||
}
|
||||
|
||||
static void *stdlib_realloc(void *ctx, void *ptr, size_t old_size,
|
||||
size_t new_size) {
|
||||
(void)ctx;
|
||||
(void)old_size;
|
||||
return realloc(ptr, new_size);
|
||||
}
|
||||
|
||||
static void stdlib_free(void *ctx, void *ptr, size_t size) {
|
||||
(void)ctx;
|
||||
(void)size;
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
Allocator allocator_default(void) {
|
||||
return (Allocator){
|
||||
.ctx = NULL,
|
||||
.alloc = stdlib_alloc,
|
||||
.realloc = stdlib_realloc,
|
||||
.free = stdlib_free,
|
||||
};
|
||||
}
|
||||
5
src/main.c
Normal file
5
src/main.c
Normal file
@@ -0,0 +1,5 @@
|
||||
#include "allocator.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(void) { return EXIT_SUCCESS; }
|
||||
Reference in New Issue
Block a user