]> mj.ucw.cz Git - libucw.git/blob - ucw/alloc.h
Imported tableprinter module
[libucw.git] / ucw / alloc.h
1 /*
2  *      UCW Library -- Generic allocators
3  *
4  *      (c) 2014 Martin Mares <mj@ucw.cz>
5  */
6
7 #ifndef _UCW_ALLOC_H
8 #define _UCW_ALLOC_H
9
10 /**
11  * This structure describes a generic allocator. It provides pointers
12  * to three functions, which handle the actual (re)allocations.
13  **/
14 struct ucw_allocator {
15   void * (*alloc)(struct ucw_allocator *alloc, size_t size);
16   void * (*realloc)(struct ucw_allocator *alloc, void *ptr, size_t old_size, size_t new_size);
17   void (*free)(struct ucw_allocator *alloc, void *ptr);
18 };
19
20 /* alloc-std.c */
21
22 /**
23  * [[std]]
24  * This allocator uses <<basics:xmalloc()>>, <<basics:xrealloc()>> and <<basics:xfree()>>. The memory
25  * it allocates is left unitialized.
26  **/
27 extern struct ucw_allocator ucw_allocator_std;
28
29 /**
30  * [[zeroing]]
31  * This allocator uses <<basics:xmalloc()>>, <<basics:xrealloc()>> and <<basics:xfree()>>. All memory
32  * is zeroed upon allocation.
33  **/
34 extern struct ucw_allocator ucw_allocator_zeroed;
35
36 #endif