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