Debian Codegraph @

melder/melder_alloc.h

raw symbols SCIP
1 #cxx . . $ `<file>/melder/melder_alloc.h`/ifndef _melder_alloc_h_
2 #define _melder_alloc_h_cxx . . $ `melder/melder_alloc.h:2:9`!
3 /* melder_alloc.h
4 *
5 * Copyright (C) 1992-2020 Paul Boersma
6 *
7 * This code is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or (at
10 * your option) any later version.
11 *
12 * This code is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15 * See the GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this work. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21 /* These functions call malloc, free, realloc, and calloc. */
22 /* If out of memory, the non-f versions throw an error message (like "Out of memory"); */
23 /* the f versions open up a rainy day fund or crash Praat. */
24 /* These functions also maintain a count of the total number of blocks allocated. */
25
26 void Melder_alloc_initcxx . . $ Melder_alloc_init(49f6e7a06ebc5aa8). (); // to be called around program start-up
27 void * _Melder_malloccxx . . $ _Melder_malloc(1de1fe46563a6a2a). (int64cxx . . $ int64# size);
28 #define Melder_malloccxx . . $ `melder/melder_alloc.h:28:9`!(type,numberOfElements) (type *) _Melder_malloc ((numberOfElements) * (int64) sizeof (type))
29 void * _Melder_malloc_fcxx . . $ _Melder_malloc_f(1de1fe46563a6a2a). (int64cxx . . $ int64# size);
30 #define Melder_malloc_fcxx . . $ `melder/melder_alloc.h:30:9`!(type,numberOfElements) (type *) _Melder_malloc_f ((numberOfElements) * (int64) sizeof (type))
31 void * Melder_realloccxx . . $ Melder_realloc(d42fd80046fa8ace). (void *pointer, int64cxx . . $ int64# size);
32 void * Melder_realloc_fcxx . . $ Melder_realloc_f(d42fd80046fa8ace). (void *pointer, int64cxx . . $ int64# size);
33 void * _Melder_calloccxx . . $ _Melder_calloc(d58a73cf1dc24cbb). (int64cxx . . $ int64# numberOfElements, int64cxx . . $ int64# elementSize);
34 #define Melder_calloccxx . . $ `melder/melder_alloc.h:34:9`!(type,numberOfElements) (type *) _Melder_calloc (numberOfElements, sizeof (type))
35 void * _Melder_calloc_fcxx . . $ _Melder_calloc_f(d58a73cf1dc24cbb). (int64cxx . . $ int64# numberOfElements, int64cxx . . $ int64# elementSize);
36 #define Melder_calloc_fcxx . . $ `melder/melder_alloc.h:36:9`!(type,numberOfElements) (type *) _Melder_calloc_f (numberOfElements, sizeof (type))
37
38 #define Melder_freecxx . . $ `melder/melder_alloc.h:38:9`!(pointer) _Melder_free ((void **) & (pointer))
39 void _Melder_freecxx . . $ _Melder_free(66f733d91e158b15). (void **pointer) noexcept;
40 /*
41 Preconditions:
42 none (*pointer may be null).
43 Postconditions:
44 *pointer == nullptr;
45 */
46
47 int64cxx . . $ int64# Melder_allocationCountcxx . . $ Melder_allocationCount(da6335ded91d79c2). ();
48 /*
49 Returns the total number of successful calls to
50 Melder_malloc, Melder_realloc (if 'ptr' is null), and Melder_calloc,
51 since the start of the process. Mainly for debugging purposes.
52 */
53
54 int64cxx . . $ int64# Melder_deallocationCountcxx . . $ Melder_deallocationCount(da6335ded91d79c2). ();
55 /*
56 Returns the total number of successful calls to Melder_free,
57 since the start of the process. Mainly for debugging purposes.
58 */
59
60 int64cxx . . $ int64# Melder_allocationSizecxx . . $ Melder_allocationSize(da6335ded91d79c2). ();
61 /*
62 Returns the total number of bytes allocated in calls to
63 Melder_malloc, Melder_realloc (if moved), and Melder_calloc,
64 since the start of the process. Mainly for debugging purposes.
65 */
66
67 int64cxx . . $ int64# Melder_reallocationsInSituCountcxx . . $ Melder_reallocationsInSituCount(da6335ded91d79c2). ();
68 int64cxx . . $ int64# Melder_movingReallocationsCountcxx . . $ Melder_movingReallocationsCount(da6335ded91d79c2). ();
69
70 /********** Arrays. **********/
71
72 namespace MelderArraycxx . . $ MelderArray/ {
73
74 enum class kInitializationTypecxx . . $ MelderArray/kInitializationType# { RAWcxx . . $ MelderArray/kInitializationType#RAW. = 0, ZEROcxx . . $ MelderArray/kInitializationType#ZERO. = 1 };
75
76 bytecxx . . $ byte# * _alloc_genericcxx . . $ MelderArray/_alloc_generic(2491babf9587f48b). (integercxx . . $ integer# cellSize, integercxx . . $ integer# numberOfCells, kInitializationTypecxx . . $ MelderArray/kInitializationType# initializationType);
77 void _free_genericcxx . . $ MelderArray/_free_generic(4434d2f5730ad69). (bytecxx . . $ byte# *cells, integercxx . . $ integer# numberOfCells) noexcept;
78
79 template <class T>
80 T* _alloccxx . . $ MelderArray/_alloc(9f9b4c19ca7bd9a6). (integercxx . . $ integer# numberOfCells, kInitializationTypecxx . . $ MelderArray/kInitializationType# initializationType) {
81 T* result = reinterpret_cast <T*> (MelderArraycxx . . $ MelderArray/:: _alloc_genericcxx . . $ MelderArray/_alloc_generic(2491babf9587f48b). (sizeof (T), numberOfCells, initializationType));
82 return result;
83 }
84
85 template <class T>
86 void _freecxx . . $ MelderArray/_free(3433bc89c495b7da). (T* cells, integercxx . . $ integer# numberOfCells) noexcept {
87 _free_genericcxx . . $ MelderArray/_free_generic(4434d2f5730ad69). (reinterpret_cast <bytecxx . . $ byte# *> (cells), numberOfCells);
88 }
89
90 }
91
92 int64cxx . . $ int64# MelderArray_allocationCountcxx . . $ MelderArray_allocationCount(da6335ded91d79c2). ();
93 int64cxx . . $ int64# MelderArray_deallocationCountcxx . . $ MelderArray_deallocationCount(da6335ded91d79c2). ();
94 int64cxx . . $ int64# MelderArray_cellAllocationCountcxx . . $ MelderArray_cellAllocationCount(da6335ded91d79c2). ();
95 int64cxx . . $ int64# MelderArray_cellDeallocationCountcxx . . $ MelderArray_cellDeallocationCount(da6335ded91d79c2). ();
96
97 /* End of file melder_alloc.h */
98 #endif