]> mj.ucw.cz Git - libucw.git/blob - ucw/conf-alloc.c
Mainloop: Fixed +1 error in heap usage.
[libucw.git] / ucw / conf-alloc.c
1 /*
2  *      UCW Library -- Configuration files: memory allocation
3  *
4  *      (c) 2001--2006 Robert Spalek <robert@ucw.cz>
5  *      (c) 2003--2012 Martin Mares <mj@ucw.cz>
6  *
7  *      This software may be freely distributed and used according to the terms
8  *      of the GNU Lesser General Public License.
9  */
10
11 #include <ucw/lib.h>
12 #include <ucw/conf.h>
13 #include <ucw/conf-internal.h>
14 #include <ucw/mempool.h>
15
16 inline struct mempool *
17 cf_get_pool(void)
18 {
19   return cf_get_context()->pool;
20 }
21
22 void *
23 cf_malloc(uns size)
24 {
25   return mp_alloc(cf_get_pool(), size);
26 }
27
28 void *
29 cf_malloc_zero(uns size)
30 {
31   return mp_alloc_zero(cf_get_pool(), size);
32 }
33
34 char *
35 cf_strdup(const char *s)
36 {
37   return mp_strdup(cf_get_pool(), s);
38 }
39
40 char *
41 cf_printf(const char *fmt, ...)
42 {
43   va_list args;
44   va_start(args, fmt);
45   char *res = mp_vprintf(cf_get_pool(), fmt, args);
46   va_end(args);
47   return res;
48 }