aboutsummaryrefslogtreecommitdiff
path: root/include/_allocator.h
blob: 3bd78b200d428b08ef47690ac801886a2546c9fe (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#ifndef MLIB__ALLOCATOR_H
#define MLIB__ALLOCATOR_H

#include <setjmp.h>
#include <stddef.h>

typedef enum {
	ALLOC_NEW,
	ALLOC_RESIZE,
	ALLOC_FREE,
	ALLOC_FREEALL,
} alloc_mode_t;

typedef struct allocator {
	void *(*alloc)(struct allocator mem, alloc_mode_t mode, void *ptr,
		ptrdiff_t oldnmemb, ptrdiff_t newnmemb, ptrdiff_t elemsz,
		ptrdiff_t align);
	jmp_buf *err;
	void    *ctx;
} allocator_t;

#endif /* !MLIB__ALLOCATOR_H */