C Standard Library Extensions  1.2.3
cxmemory.h
1 /*
2  * This file is part of the ESO C Extension Library
3  * Copyright (C) 2001-2017 European Southern Observatory
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19 
20 #ifndef CX_MEMORY_H
21 #define CX_MEMORY_H
22 
23 #include <cxtypes.h>
24 
25 
26 CX_BEGIN_DECLS
27 
28 struct _cx_memory_vtable_ {
29  cxptr (*malloc) (cxsize);
30  cxptr (*calloc) (cxsize, cxsize);
31  cxptr (*realloc) (cxptr, cxsize);
32  void (*free) (cxptr);
33 };
34 
35 typedef struct _cx_memory_vtable_ cx_memory_vtable;
36 
37 
38 
39 /*
40  * Memory allocation functions
41  */
42 
43 void cx_memory_vtable_set(const cx_memory_vtable *);
44 cxbool cx_memory_is_system_malloc(void);
45 
46 cxptr cx_malloc(cxsize);
47 cxptr cx_malloc_clear(cxsize);
48 cxptr cx_calloc(cxsize, cxsize);
49 cxptr cx_realloc(cxptr, cxsize);
50 void cx_free(cxptr);
51 
52 CX_END_DECLS
53 
54 #endif /* CX_MEMORY_H */
cxptr cx_malloc_clear(cxsize)
Allocate nbytes bytes and clear them.
Definition: cxmemory.c:329
void cx_memory_vtable_set(const cx_memory_vtable *)
Install a new set of memory managmement functions.
Definition: cxmemory.c:228
void cx_free(cxptr)
Memory block deallocation.
Definition: cxmemory.c:486
cxptr cx_malloc(cxsize)
Allocate nbytes bytes.
Definition: cxmemory.c:280
cxptr cx_realloc(cxptr, cxsize)
Change the size of a memory block.
Definition: cxmemory.c:441
cxptr cx_calloc(cxsize, cxsize)
Allocate memory for natoms elements of size size.
Definition: cxmemory.c:380
cxbool cx_memory_is_system_malloc(void)
Check if the system's defaults are used for memory allocation.
Definition: cxmemory.c:526