C Standard Library Extensions 1.2.7
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
26CX_BEGIN_DECLS
27
28struct _cx_memory_vtable_
29{
30 cxptr (*malloc)(cxsize);
31 cxptr (*calloc)(cxsize, cxsize);
32 cxptr (*realloc)(cxptr, cxsize);
33 void (*free)(cxptr);
34};
35
36typedef struct _cx_memory_vtable_ cx_memory_vtable;
37
38
39/*
40 * Memory allocation functions
41 */
42
43void cx_memory_vtable_set(const cx_memory_vtable *);
45
46cxptr cx_malloc(cxsize);
47cxptr cx_malloc_clear(cxsize);
48cxptr cx_calloc(cxsize, cxsize);
49cxptr cx_realloc(cxptr, cxsize);
50void cx_free(cxptr);
51
52CX_END_DECLS
53
54#endif /* CX_MEMORY_H */
cxptr cx_malloc_clear(cxsize)
Allocate nbytes bytes and clear them.
Definition cxmemory.c:320
void cx_memory_vtable_set(const cx_memory_vtable *)
Install a new set of memory managmement functions.
Definition cxmemory.c:223
void cx_free(cxptr)
Memory block deallocation.
Definition cxmemory.c:476
cxptr cx_malloc(cxsize)
Allocate nbytes bytes.
Definition cxmemory.c:271
cxptr cx_realloc(cxptr, cxsize)
Change the size of a memory block.
Definition cxmemory.c:432
cxptr cx_calloc(cxsize, cxsize)
Allocate memory for natoms elements of size size.
Definition cxmemory.c:371
cxbool cx_memory_is_system_malloc(void)
Check if the system's defaults are used for memory allocation.
Definition cxmemory.c:517