auxmemory.h /size: 1748 b    last modification: 2024-01-16 10:22
1/*
2    See license.txt in the root of this project.
3*/
4
5/*
6    Some operating systems come with |allocarray| so we use more verbose names. We cannot define
7    them because on some bsd/apple platforms |CLANG| cannot resolve them.
8
9*/
10
11# ifndef LMT_UTILITIES_MEMORY_H
12# define LMT_UTILITIES_MEMORY_H
13
14/*tex
15    This is an experiment. The impact of using an alternative allocator on native Windows makes a
16    native version some 5% faster than a cross compiled one. Otherwise the cross compiled version
17    outperforms the native one a bit. In \TEX\ and \METAPOST\ we already do something like this
18    but there we don't reclaim memory.
19
20*/
21
22# include <stdlib.h>
23# include <string.h>
24
25# if defined(LUAMETATEX_USE_MIMALLOC)
26    # include "libraries/mimalloc/include/mimalloc.h"
27    # define lmt_memory_malloc  mi_malloc
28    # define lmt_memory_calloc  mi_calloc
29    # define lmt_memory_realloc mi_realloc
30    # define lmt_memory_free    mi_free
31    # define lmt_memory_strdup  mi_strdup
32
33 // # include "libraries/mimalloc/include/mimalloc-override.h"
34
35# else
36    # define lmt_memory_malloc  malloc
37    # define lmt_memory_calloc  calloc
38    # define lmt_memory_realloc realloc
39    # define lmt_memory_free    free
40    # define lmt_memory_strdup  strdup
41# endif
42
43# define lmt_generic_malloc  malloc
44# define lmt_generic_calloc  calloc
45# define lmt_generic_realloc realloc
46# define lmt_generic_free    free
47# define lmt_generic_strdup  strdup
48
49extern void *aux_allocate_array       (int recordsize, int size, int reserved);
50extern void *aux_reallocate_array     (void *p, int recordsize, int size, int reserved);
51extern void *aux_allocate_clear_array (int recordsize, int size, int reserved);
52extern void  aux_deallocate_array     (void *p);
53
54# endif
55