C Standard Library Extensions 1.3.1
cxmemory.h
1/*
2 * This file is part of the ESO C Extension Library
3 * Copyright (C) 2001-2026 European Southern Observatory
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library 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 GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, see <https://www.gnu.org/licenses/>.
17 */
18
19#ifndef CX_MEMORY_H
20#define CX_MEMORY_H
21
22#include "cxtypes.h"
23
24
25CX_BEGIN_DECLS
26
27struct _cx_memory_vtable_
28{
29 cxptr (*malloc)(cxsize);
30 cxptr (*calloc)(cxsize, cxsize);
31 cxptr (*realloc)(cxptr, cxsize);
32 void (*free)(cxptr);
33};
34
35typedef struct _cx_memory_vtable_ cx_memory_vtable;
36
37
38/*
39 * Memory allocation functions
40 */
41
42void cx_memory_vtable_set(const cx_memory_vtable *);
44
45cxptr cx_malloc(cxsize);
46cxptr cx_malloc_clear(cxsize);
47cxptr cx_calloc(cxsize, cxsize);
48cxptr cx_realloc(cxptr, cxsize);
49void cx_free(cxptr);
50
51CX_END_DECLS
52
53#endif /* CX_MEMORY_H */
cxptr cx_malloc_clear(cxsize)
Allocate nbytes bytes and clear them.
Definition cxmemory.c:321
void cx_memory_vtable_set(const cx_memory_vtable *)
Install a new set of memory managmement functions.
Definition cxmemory.c:224
void cx_free(cxptr)
Memory block deallocation.
Definition cxmemory.c:477
cxptr cx_malloc(cxsize)
Allocate nbytes bytes.
Definition cxmemory.c:272
cxptr cx_realloc(cxptr, cxsize)
Change the size of a memory block.
Definition cxmemory.c:433
cxptr cx_calloc(cxsize, cxsize)
Allocate memory for natoms elements of size size.
Definition cxmemory.c:372
cxbool cx_memory_is_system_malloc(void)
Check if the system's defaults are used for memory allocation.
Definition cxmemory.c:518