Scippy

SCIP

Solving Constraint Integer Programs

memory.h
Go to the documentation of this file.
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2 /* */
3 /* This file is part of the library */
4 /* BMS --- Block Memory Shell */
5 /* */
6 /* Copyright (C) 2002-2019 Konrad-Zuse-Zentrum */
7 /* fuer Informationstechnik Berlin */
8 /* */
9 /* BMS is distributed under the terms of the ZIB Academic License. */
10 /* */
11 /* You should have received a copy of the ZIB Academic License */
12 /* along with BMS; see the file COPYING. If not email to scip@zib.de. */
13 /* */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15 
16 /**@file memory.h
17  * @brief memory allocation routines
18  * @author Tobias Achterberg
19  * @author Gerald Gamrath
20  * @author Marc Pfetsch
21  */
22 
23 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
24 
25 #ifndef __BMS_MEMORY_H__
26 #define __BMS_MEMORY_H__
27 
28 #include <limits.h>
29 #include <stdlib.h>
30 #include <stddef.h>
31 
32 /*
33  * include build configuration flags
34  */
35 #ifndef NO_CONFIG_HEADER
36 #include "scip/config.h"
37 #endif
38 
39 #ifdef __cplusplus
40 
41 
42 /* special thanks to Daniel Junglas for following template and macros */
43 
44 template<typename T> T* docast(T*, void *v);
45 template<typename T> T* docast(T*, void *v) { return reinterpret_cast<T*>(v); }
46 
47 /* For C++11, we can easily check whether the types for memory functions like BMSduplicateXYZArray() are equal. */
48 #if __cplusplus > 199711L
49 #include <type_traits>
50 
51 /* the following adds a type check for the parameters, used in ASSIGNCHECK below */
52 template<typename T1, typename T2> T1* docastcheck(T1* v1, void* v, T2* v2)
53 {
54  typedef typename std::remove_const<T1>::type t1;
55  typedef typename std::remove_const<T2>::type t2;
56  static_assert(std::is_same<t1, t2>::value, "need equal types");
57  return reinterpret_cast<T1*>(v);
58 }
59 #else
60 /* for older compilers do nothing */
61 template<typename T1, typename T2> T1* docastcheck(T1* v1, void* v, T2* v2) { return reinterpret_cast<T1*>(v); }
62 #endif
63 
64 
65 extern "C" {
66 
67 #define ASSIGN(pointerstarstar, voidstarfunction) (*(pointerstarstar) = docast(*(pointerstarstar), (voidstarfunction)))
68 #define ASSIGNCHECK(pointerstarstar, voidstarfunction, origpointer) (*(pointerstarstar) = docastcheck(*(pointerstarstar), (voidstarfunction), (origpointer)))
69 
70 #else
71 
72 #define ASSIGN(pointerstarstar, voidstarfunction) (*(pointerstarstar) = (voidstarfunction))
73 #define ASSIGNCHECK(pointerstarstar, voidstarfunction, origpointer) (*(pointerstarstar) = (voidstarfunction))
74 
75 #endif
76 
77 /*
78  * Define the macro EXTERN depending if the OS is Windows or not
79  */
80 #ifndef EXTERN
81 
82 #if defined(_WIN32) || defined(_WIN64)
83 #define EXTERN __declspec(dllexport)
84 #else
85 #define EXTERN extern
86 #endif
87 
88 #endif
89 
90 /* define if not already existing to make file independent from def.h */
91 #ifndef SCIP_UNUSED
92 #define SCIP_UNUSED(x) ((void) (x))
93 #endif
94 
95 
96 /*************************************************************************************
97  * Standard Memory Management
98  *
99  * In debug mode, these methods extend malloc() and free() by logging all currently
100  * allocated memory elements in an allocation list. This can be used as a simple leak
101  * detection.
102  *************************************************************************************/
103 
104 /* Note: values that are passed as a size_t parameter are first converted to ptrdiff_t to be sure that negative numbers
105  * are extended to the larger size. Then they are converted to size_t. Thus, negative numbers are converted to very
106  * large size_t values. This is then checked within the functions. */
107 
108 #define BMSallocMemory(ptr) ASSIGN((ptr), BMSallocMemory_call( sizeof(**(ptr)), __FILE__, __LINE__ ))
109 #define BMSallocMemorySize(ptr,size) ASSIGN((ptr), BMSallocMemory_call( (size_t)(ptrdiff_t)(size), __FILE__, __LINE__ ))
110 #define BMSallocMemoryCPP(size) BMSallocMemory_call( (size_t)(ptrdiff_t)(size), __FILE__, __LINE__ )
111 #define BMSallocClearMemorySize(ptr,size) ASSIGN((ptr), BMSallocClearMemory_call((size_t)(1), (size_t)(ptrdiff_t)(size), __FILE__, __LINE__ ))
112 #define BMSallocMemoryArray(ptr,num) ASSIGN((ptr), BMSallocMemoryArray_call((size_t)(ptrdiff_t)(num), sizeof(**(ptr)), __FILE__, __LINE__ ))
113 #define BMSallocMemoryArrayCPP(num,size) BMSallocMemoryArray_call( (size_t)(ptrdiff_t)(num), (size_t)(ptrdiff_t)(size), __FILE__, __LINE__ )
114 #define BMSallocClearMemoryArray(ptr,num) ASSIGN((ptr), BMSallocClearMemory_call((size_t)(ptrdiff_t)(num), sizeof(**(ptr)), __FILE__, __LINE__ ))
115 #define BMSreallocMemorySize(ptr,size) ASSIGN((ptr), BMSreallocMemory_call((void*)(*(ptr)), (size_t)(ptrdiff_t)(size), __FILE__, __LINE__ ))
116 #define BMSreallocMemoryArray(ptr,num) ASSIGN((ptr), BMSreallocMemoryArray_call( *(ptr), (size_t)(ptrdiff_t)(num), sizeof(**(ptr)), __FILE__, __LINE__ ))
117 
118 #define BMSclearMemory(ptr) BMSclearMemory_call( (void*)(ptr), sizeof(*(ptr)) )
119 #define BMSclearMemoryArray(ptr, num) BMSclearMemory_call( (void*)(ptr), (size_t)(ptrdiff_t)(num)*sizeof(*(ptr)) )
120 #define BMSclearMemorySize(ptr, size) BMSclearMemory_call( (void*)(ptr), (size_t)(ptrdiff_t)(size) )
121 
122 #define BMScopyMemory(ptr, source) BMScopyMemory_call( (void*)(ptr), (const void*)(source), sizeof(*(ptr)) )
123 #define BMScopyMemoryArray(ptr, source, num) BMScopyMemory_call( (void*)(ptr), (const void*)(source), (size_t)(ptrdiff_t)(num)*sizeof(*(ptr)) )
124 #define BMScopyMemorySize(ptr, source, size) BMScopyMemory_call( (void*)(ptr), (const void*)(source), (size_t)(ptrdiff_t)(size) )
125 
126 #define BMSmoveMemory(ptr, source) BMSmoveMemory_call( (void*)(ptr), (const void*)(source), sizeof(*(ptr)) )
127 #define BMSmoveMemoryArray(ptr, source, num) BMSmoveMemory_call( (void*)(ptr), (const void*)(source), (size_t)(ptrdiff_t)(num) * sizeof(*(ptr)) )
128 #define BMSmoveMemorySize(ptr, source, size) BMSmoveMemory_call( (void*)(ptr), (const void*)(source), (size_t)(ptrdiff_t)(size) )
129 
130 #define BMSduplicateMemory(ptr, source) ASSIGN((ptr), BMSduplicateMemory_call( (const void*)(source), sizeof(**(ptr)), __FILE__, __LINE__ ))
131 #define BMSduplicateMemorySize(ptr, source, size) ASSIGN((ptr), BMSduplicateMemory_call( (const void*)(source), (size_t)(ptrdiff_t)(size), __FILE__, __LINE__ ))
132 #define BMSduplicateMemoryArray(ptr, source, num) ASSIGNCHECK((ptr), BMSduplicateMemoryArray_call( (const void*)(source), (size_t)(ptrdiff_t)(num), \
133  sizeof(**(ptr)), __FILE__, __LINE__ ), source)
134 #define BMSfreeMemory(ptr) BMSfreeMemory_call( (void**)(ptr), __FILE__, __LINE__ )
135 #define BMSfreeMemoryNull(ptr) BMSfreeMemoryNull_call( (void**)(ptr), __FILE__, __LINE__ )
136 #define BMSfreeMemoryArray(ptr) BMSfreeMemory_call( (void**)(ptr), __FILE__, __LINE__ )
137 #define BMSfreeMemoryArrayNull(ptr) BMSfreeMemoryNull_call( (void**)(ptr), __FILE__, __LINE__ )
138 #define BMSfreeMemorySize(ptr) BMSfreeMemory_call( (void**)(ptr), __FILE__, __LINE__ )
139 #define BMSfreeMemorySizeNull(ptr) BMSfreeMemoryNull_call( (void**)(ptr), __FILE__, __LINE__ )
140 
141 #ifndef NDEBUG
142 #define BMSgetPointerSize(ptr) BMSgetPointerSize_call(ptr)
143 #define BMSdisplayMemory() BMSdisplayMemory_call()
144 #define BMScheckEmptyMemory() BMScheckEmptyMemory_call()
145 #define BMSgetMemoryUsed() BMSgetMemoryUsed_call()
146 #else
147 #define BMSgetPointerSize(ptr) 0
148 #define BMSdisplayMemory() /**/
149 #define BMScheckEmptyMemory() /**/
150 #define BMSgetMemoryUsed() 0LL
151 #endif
152 
153 /** allocates array and initializes it with 0; returns NULL if memory allocation failed */
154 extern
156  size_t num, /**< number of memory element to allocate */
157  size_t typesize, /**< size of memory element to allocate */
158  const char* filename, /**< source file where the allocation is performed */
159  int line /**< line number in source file where the allocation is performed */
160  );
161 
162 /** allocates memory; returns NULL if memory allocation failed */
163 extern
164 void* BMSallocMemory_call(
165  size_t size, /**< size of memory element to allocate */
166  const char* filename, /**< source file where the allocation is performed */
167  int line /**< line number in source file where the allocation is performed */
168  );
169 
170 /** allocates array; returns NULL if memory allocation failed */
171 extern
173  size_t num, /**< number of components of array to allocate */
174  size_t typesize, /**< size of each component */
175  const char* filename, /**< source file where the allocation is performed */
176  int line /**< line number in source file where the allocation is performed */
177  );
178 
179 /** allocates memory; returns NULL if memory allocation failed */
180 extern
182  void* ptr, /**< pointer to memory to reallocate */
183  size_t size, /**< new size of memory element */
184  const char* filename, /**< source file where the reallocation is performed */
185  int line /**< line number in source file where the reallocation is performed */
186  );
187 
188 /** reallocates array; returns NULL if memory allocation failed */
189 extern
191  void* ptr, /**< pointer to memory to reallocate */
192  size_t num, /**< number of components of array to allocate */
193  size_t typesize, /**< size of each component */
194  const char* filename, /**< source file where the reallocation is performed */
195  int line /**< line number in source file where the reallocation is performed */
196  );
197 
198 /** clears a memory element (i.e. fills it with zeros) */
199 extern
201  void* ptr, /**< pointer to memory element */
202  size_t size /**< size of memory element */
203  );
204 
205 /** copies the contents of one memory element into another memory element */
206 extern
207 void BMScopyMemory_call(
208  void* ptr, /**< pointer to target memory element */
209  const void* source, /**< pointer to source memory element */
210  size_t size /**< size of memory element to copy */
211  );
212 
213 /** moves the contents of one memory element into another memory element, should be used if both elements overlap,
214  * otherwise BMScopyMemory is faster
215  */
216 extern
217 void BMSmoveMemory_call(
218  void* ptr, /**< pointer to target memory element */
219  const void* source, /**< pointer to source memory element */
220  size_t size /**< size of memory element to copy */
221  );
222 
223 /** allocates memory and copies the contents of the given memory element into the new memory element */
224 extern
226  const void* source, /**< pointer to source memory element */
227  size_t size, /**< size of memory element to copy */
228  const char* filename, /**< source file where the duplication is performed */
229  int line /**< line number in source file where the duplication is performed */
230  );
231 
232 /** allocates array and copies the contents of the given source array into the new array */
233 extern
235  const void* source, /**< pointer to source memory element */
236  size_t num, /**< number of components of array to allocate */
237  size_t typesize, /**< size of each component */
238  const char* filename, /**< source file where the duplication is performed */
239  int line /**< line number in source file where the duplication is performed */
240  );
241 
242 /** frees an allocated memory element and sets pointer to NULL */
243 extern
244 void BMSfreeMemory_call(
245  void** ptr, /**< pointer to pointer to memory element */
246  const char* filename, /**< source file where the deallocation is performed */
247  int line /**< line number in source file where the deallocation is performed */
248  );
249 
250 /** frees an allocated memory element if pointer is not NULL and sets pointer to NULL */
251 extern
253  void** ptr, /**< pointer to pointer to memory element */
254  const char* filename, /**< source file where the deallocation is performed */
255  int line /**< line number in source file where the deallocation is performed */
256  );
257 
258 /** returns the size of an allocated memory element */
259 extern
261  const void* ptr /**< pointer to allocated memory */
262  );
263 
264 /** outputs information about currently allocated memory to the screen */
265 extern
267  void
268  );
269 
270 /** displays a warning message on the screen, if allocated memory exists */
271 extern
273  void
274  );
275 
276 /** returns total number of allocated bytes */
277 extern
278 long long BMSgetMemoryUsed_call(
279  void
280  );
281 
282 
283 
284 
285 /********************************************************************
286  * Chunk Memory Management
287  *
288  * Efficient memory management for multiple objects of the same size
289  ********************************************************************/
290 
291 typedef struct BMS_ChkMem BMS_CHKMEM; /**< collection of memory chunks of the same element size */
292 
293 
294 #ifndef BMS_NOBLOCKMEM
295 
296 #define BMScreateChunkMemory(sz,isz,gbf) BMScreateChunkMemory_call( (sz), (isz), (gbf), __FILE__, __LINE__ )
297 #define BMSclearChunkMemory(mem) BMSclearChunkMemory_call( (mem), __FILE__, __LINE__ )
298 #define BMSdestroyChunkMemory(mem) BMSdestroyChunkMemory_call( (mem), __FILE__, __LINE__ )
299 
300 #define BMSallocChunkMemory(mem,ptr) ASSIGN((ptr), BMSallocChunkMemory_call((mem), sizeof(**(ptr)), __FILE__, __LINE__))
301 #define BMSduplicateChunkMemory(mem, ptr, source) ASSIGN((ptr), BMSduplicateChunkMemory_call((mem), (const void*)(source), \
302  sizeof(**(ptr)), __FILE__, __LINE__ ))
303 #define BMSfreeChunkMemory(mem,ptr) BMSfreeChunkMemory_call( (mem), (void**)(ptr), sizeof(**(ptr)), __FILE__, __LINE__ )
304 #define BMSfreeChunkMemoryNull(mem,ptr) BMSfreeChunkMemoryNull_call( (mem), (void**)(ptr) )
305 #define BMSgarbagecollectChunkMemory(mem) BMSgarbagecollectChunkMemory_call(mem)
306 #define BMSgetChunkMemoryUsed(mem) BMSgetChunkMemoryUsed_call(mem)
307 
308 #else
309 
310 /* block memory management mapped to standard memory management */
311 
312 #define BMScreateChunkMemory(sz,isz,gbf) (void*)(0x01) /* dummy to not return a NULL pointer */
313 #define BMSclearChunkMemory(mem) /**/
314 #define BMSclearChunkMemoryNull(mem) /**/
315 #define BMSdestroyChunkMemory(mem) /**/
316 #define BMSdestroyChunkMemoryNull(mem) /**/
317 #define BMSallocChunkMemory(mem,ptr) BMSallocMemory(ptr)
318 #define BMSduplicateChunkMemory(mem, ptr, source) BMSduplicateMemory(ptr,source)
319 #define BMSfreeChunkMemory(mem,ptr) BMSfreeMemory(ptr)
320 #define BMSfreeChunkMemoryNull(mem,ptr) BMSfreeMemoryNull(ptr)
321 #define BMSgarbagecollectChunkMemory(mem) /**/
322 #define BMSgetChunkMemoryUsed(mem) 0LL
323 
324 #endif
325 
326 
327 /** aligns the given byte size corresponding to the minimal alignment for chunk and block memory */
328 extern
329 void BMSalignMemsize(
330  size_t* size /**< pointer to the size to align */
331  );
332 
333 /** checks whether the given size meets the alignment conditions for chunk and block memory */
334 extern
335 int BMSisAligned(
336  size_t size /**< size to check for alignment */
337  );
338 
339 /** creates a new chunk block data structure */
340 extern
342  size_t size, /**< element size of the chunk block */
343  int initchunksize, /**< number of elements in the first chunk of the chunk block */
344  int garbagefactor, /**< garbage collector is called, if at least garbagefactor * avg. chunksize
345  * elements are free (-1: disable garbage collection) */
346  const char* filename, /**< source file of the function call */
347  int line /**< line number in source file of the function call */
348  );
349 
350 /** clears a chunk block data structure */
351 extern
353  BMS_CHKMEM* chkmem, /**< chunk block */
354  const char* filename, /**< source file of the function call */
355  int line /**< line number in source file of the function call */
356  );
357 
358 /** destroys and frees a chunk block data structure */
359 extern
361  BMS_CHKMEM** chkmem, /**< pointer to chunk block */
362  const char* filename, /**< source file of the function call */
363  int line /**< line number in source file of the function call */
364  );
365 
366 /** allocates a memory element of the given chunk block */
367 extern
369  BMS_CHKMEM* chkmem, /**< chunk block */
370  size_t size, /**< size of memory element to allocate (only needed for sanity check) */
371  const char* filename, /**< source file of the function call */
372  int line /**< line number in source file of the function call */
373  );
374 
375 /** duplicates a given memory element by allocating a new element of the same chunk block and copying the data */
376 extern
378  BMS_CHKMEM* chkmem, /**< chunk block */
379  const void* source, /**< source memory element */
380  size_t size, /**< size of memory element to allocate (only needed for sanity check) */
381  const char* filename, /**< source file of the function call */
382  int line /**< line number in source file of the function call */
383  );
384 
385 /** frees a memory element of the given chunk block and sets pointer to NULL */
386 extern
388  BMS_CHKMEM* chkmem, /**< chunk block */
389  void** ptr, /**< pointer to pointer to memory element to free */
390  size_t size, /**< size of memory element to allocate (only needed for sanity check) */
391  const char* filename, /**< source file of the function call */
392  int line /**< line number in source file of the function call */
393  );
394 
395 /** frees a memory element of the given chunk block if pointer is not NULL and sets pointer to NULL */
396 extern
398  BMS_CHKMEM* chkmem, /**< chunk block */
399  void** ptr, /**< pointer to pointer to memory element to free */
400  size_t size, /**< size of memory element to allocate (only needed for sanity check) */
401  const char* filename, /**< source file of the function call */
402  int line /**< line number in source file of the function call */
403  );
404 
405 /** calls garbage collection of chunk block and frees chunks without allocated memory elements */
406 extern
408  BMS_CHKMEM* chkmem /**< chunk block */
409  );
410 
411 /** returns the number of allocated bytes in the chunk block */
412 extern
414  const BMS_CHKMEM* chkmem /**< chunk block */
415  );
416 
417 
418 
419 
420 /***********************************************************
421  * Block Memory Management
422  *
423  * Efficient memory management for objects of varying sizes
424  ***********************************************************/
425 
426 typedef struct BMS_BlkMem BMS_BLKMEM; /**< block memory: collection of chunk blocks */
427 
428 #ifndef BMS_NOBLOCKMEM
429 
430 /* block memory methods for faster memory access */
431 
432 /* Note: values that are passed as a size_t parameter are first converted to ptrdiff_t to be sure that negative numbers
433  * are extended to the larger size. Then they are converted to size_t. Thus, negative numbers are converted to very
434  * large size_t values. This is then checked within the functions. */
435 
436 #define BMScreateBlockMemory(csz,gbf) BMScreateBlockMemory_call( (csz), (gbf), __FILE__, __LINE__ )
437 #define BMSclearBlockMemory(mem) BMSclearBlockMemory_call( (mem), __FILE__, __LINE__ )
438 #define BMSdestroyBlockMemory(mem) BMSdestroyBlockMemory_call( (mem), __FILE__, __LINE__ )
439 
440 #define BMSallocBlockMemory(mem,ptr) ASSIGN((ptr), BMSallocBlockMemory_call((mem), sizeof(**(ptr)), __FILE__, __LINE__))
441 #define BMSallocBlockMemorySize(mem,ptr,size) ASSIGN((ptr), BMSallocBlockMemory_call((mem), (size_t)(ptrdiff_t)(size), __FILE__, __LINE__))
442 #define BMSallocBlockMemoryArray(mem,ptr,num) ASSIGN((ptr), BMSallocBlockMemoryArray_call((mem), (size_t)(ptrdiff_t)(num), sizeof(**(ptr)), __FILE__, __LINE__))
443 #define BMSallocClearBlockMemoryArray(mem,ptr,num) ASSIGN((ptr), BMSallocClearBlockMemoryArray_call((mem), (size_t)(ptrdiff_t)(num), sizeof(**(ptr)), __FILE__, __LINE__))
444 #define BMSreallocBlockMemorySize(mem,ptr,oldsize,newsize) ASSIGN((ptr), BMSreallocBlockMemory_call((mem), (void*)(*(ptr)), \
445  (size_t)(ptrdiff_t)(oldsize), (size_t)(ptrdiff_t)(newsize), __FILE__, __LINE__))
446 #define BMSreallocBlockMemoryArray(mem,ptr,oldnum,newnum) ASSIGN((ptr), BMSreallocBlockMemoryArray_call((mem), (void*)(*(ptr)), \
447  (size_t)(ptrdiff_t)(oldnum), (size_t)(ptrdiff_t)(newnum), sizeof(**(ptr)), __FILE__, __LINE__))
448 #define BMSduplicateBlockMemory(mem, ptr, source) ASSIGN((ptr), BMSduplicateBlockMemory_call((mem), (const void*)(source), \
449  sizeof(**(ptr)), __FILE__, __LINE__ ))
450 #define BMSduplicateBlockMemoryArray(mem, ptr, source, num) ASSIGNCHECK((ptr), BMSduplicateBlockMemoryArray_call( (mem), (const void*)(source), \
451  (size_t)(ptrdiff_t)(num), sizeof(**(ptr)), __FILE__, __LINE__ ), source)
452 
453 #define BMSfreeBlockMemory(mem,ptr) BMSfreeBlockMemory_call( (mem), (void**)(ptr), sizeof(**(ptr)), __FILE__, __LINE__ )
454 #define BMSfreeBlockMemoryNull(mem,ptr) BMSfreeBlockMemoryNull_call( (mem), (void**)(ptr), sizeof(**(ptr)), __FILE__, __LINE__ )
455 #define BMSfreeBlockMemoryArray(mem,ptr,num) BMSfreeBlockMemory_call( (mem), (void**)(ptr), (num)*sizeof(**(ptr)), __FILE__, __LINE__ )
456 #define BMSfreeBlockMemoryArrayNull(mem,ptr,num) BMSfreeBlockMemoryNull_call( (mem), (void**)(ptr), (num)*sizeof(**(ptr)), __FILE__, __LINE__ )
457 #define BMSfreeBlockMemorySize(mem,ptr,size) BMSfreeBlockMemory_call( (mem), (void**)(ptr), (size_t)(ptrdiff_t)(size), __FILE__, __LINE__ )
458 #define BMSfreeBlockMemorySizeNull(mem,ptr,size) BMSfreeBlockMemory_call( (mem), (void**)(ptr), (size_t)(ptrdiff_t)(size), __FILE__, __LINE__ )
459 
460 #define BMSgarbagecollectBlockMemory(mem) BMSgarbagecollectBlockMemory_call(mem)
461 #define BMSgetBlockMemoryAllocated(mem) BMSgetBlockMemoryAllocated_call(mem)
462 #define BMSgetBlockMemoryUsed(mem) BMSgetBlockMemoryUsed_call(mem)
463 #define BMSgetBlockMemoryUnused(mem) BMSgetBlockMemoryUnused_call(mem)
464 #define BMSgetBlockMemoryUsedMax(mem) BMSgetBlockMemoryUsedMax_call(mem)
465 #define BMSgetBlockMemoryUnusedMax(mem) BMSgetBlockMemoryUnusedMax_call(mem)
466 #define BMSgetBlockMemoryAllocatedMax(mem) BMSgetBlockMemoryAllocatedMax_call(mem)
467 #define BMSgetBlockPointerSize(mem,ptr) BMSgetBlockPointerSize_call((mem), (ptr))
468 #define BMSdisplayBlockMemory(mem) BMSdisplayBlockMemory_call(mem)
469 #define BMSblockMemoryCheckEmpty(mem) BMScheckEmptyBlockMemory_call(mem)
470 
471 #else
472 
473 /* block memory management mapped to standard memory management */
474 
475 #define BMScreateBlockMemory(csz,gbf) (SCIP_UNUSED(csz), SCIP_UNUSED(gbf), (void*)(0x01)) /* dummy to not return a NULL pointer */
476 #define BMSclearBlockMemory(mem) SCIP_UNUSED(mem)
477 #define BMSclearBlockMemoryNull(mem) SCIP_UNUSED(mem)
478 #define BMSdestroyBlockMemory(mem) SCIP_UNUSED(mem)
479 #define BMSdestroyBlockMemoryNull(mem) SCIP_UNUSED(mem)
480 #define BMSallocBlockMemory(mem,ptr) (SCIP_UNUSED(mem), BMSallocMemory(ptr))
481 #define BMSallocBlockMemoryArray(mem,ptr,num) (SCIP_UNUSED(mem), BMSallocMemoryArray(ptr,num))
482 #define BMSallocClearBlockMemoryArray(mem,ptr,num) (SCIP_UNUSED(mem), BMSallocClearMemoryArray(ptr,num))
483 #define BMSallocBlockMemorySize(mem,ptr,size) (SCIP_UNUSED(mem), BMSallocMemorySize(ptr,size))
484 #define BMSreallocBlockMemoryArray(mem,ptr,oldnum,newnum) (SCIP_UNUSED(mem), SCIP_UNUSED(oldnum), BMSreallocMemoryArray(ptr,newnum))
485 #define BMSreallocBlockMemorySize(mem,ptr,oldsize,newsize) (SCIP_UNUSED(mem), SCIP_UNUSED(oldsize), BMSreallocMemorySize(ptr,newsize))
486 #define BMSduplicateBlockMemory(mem, ptr, source) (SCIP_UNUSED(mem), BMSduplicateMemory(ptr,source))
487 #define BMSduplicateBlockMemoryArray(mem, ptr, source, num) (SCIP_UNUSED(mem), BMSduplicateMemoryArray(ptr,source,num))
488 #define BMSfreeBlockMemory(mem,ptr) (SCIP_UNUSED(mem), BMSfreeMemory(ptr))
489 #define BMSfreeBlockMemoryNull(mem,ptr) (SCIP_UNUSED(mem), BMSfreeMemoryNull(ptr))
490 #define BMSfreeBlockMemoryArray(mem,ptr,num) (SCIP_UNUSED(mem), SCIP_UNUSED(num), BMSfreeMemoryArray(ptr))
491 #define BMSfreeBlockMemoryArrayNull(mem,ptr,num) (SCIP_UNUSED(mem), SCIP_UNUSED(num), BMSfreeMemoryArrayNull(ptr))
492 #define BMSfreeBlockMemorySize(mem,ptr,size) (SCIP_UNUSED(mem), SCIP_UNUSED(size), BMSfreeMemory(ptr))
493 #define BMSfreeBlockMemorySizeNull(mem,ptr,size) (SCIP_UNUSED(mem), SCIP_UNUSED(size), BMSfreeMemoryNull(ptr))
494 #define BMSgarbagecollectBlockMemory(mem) SCIP_UNUSED(mem)
495 #define BMSgetBlockMemoryAllocated(mem) (SCIP_UNUSED(mem), 0LL)
496 #define BMSgetBlockMemoryUsed(mem) (SCIP_UNUSED(mem), 0LL)
497 #define BMSgetBlockMemoryUnused(mem) (SCIP_UNUSED(mem), 0LL)
498 #define BMSgetBlockMemoryUsedMax(mem) (SCIP_UNUSED(mem), 0LL)
499 #define BMSgetBlockMemoryUnusedMax(mem) (SCIP_UNUSED(mem), 0LL)
500 #define BMSgetBlockMemoryAllocatedMax(mem) (SCIP_UNUSED(mem), 0LL)
501 #define BMSgetBlockPointerSize(mem,ptr) (SCIP_UNUSED(mem), SCIP_UNUSED(ptr), 0)
502 #define BMSdisplayBlockMemory(mem) SCIP_UNUSED(mem)
503 #define BMSblockMemoryCheckEmpty(mem) (SCIP_UNUSED(mem), 0LL)
504 
505 #endif
506 
507 
508 /** creates a block memory allocation data structure */
509 extern
511  int initchunksize, /**< number of elements in the first chunk of each chunk block */
512  int garbagefactor, /**< garbage collector is called, if at least garbagefactor * avg. chunksize
513  * elements are free (-1: disable garbage collection) */
514  const char* filename, /**< source file of the function call */
515  int line /**< line number in source file of the function call */
516  );
517 
518 /** frees all chunk blocks in the block memory */
519 extern
521  BMS_BLKMEM* blkmem, /**< block memory */
522  const char* filename, /**< source file of the function call */
523  int line /**< line number in source file of the function call */
524  );
525 
526 /** clears and deletes block memory */
527 extern
529  BMS_BLKMEM** blkmem, /**< pointer to block memory */
530  const char* filename, /**< source file of the function call */
531  int line /**< line number in source file of the function call */
532  );
533 
534 /** allocates memory in the block memory pool */
535 extern
537  BMS_BLKMEM* blkmem, /**< block memory */
538  size_t size, /**< size of memory element to allocate */
539  const char* filename, /**< source file of the function call */
540  int line /**< line number in source file of the function call */
541  );
542 
543 /** allocates array in the block memory pool */
544 extern
546  BMS_BLKMEM* blkmem, /**< block memory */
547  size_t num, /**< size of array to be allocated */
548  size_t typesize, /**< size of each component */
549  const char* filename, /**< source file of the function call */
550  int line /**< line number in source file of the function call */
551  );
552 
553 /** allocates array in the block memory pool and clears it */
554 extern
556  BMS_BLKMEM* blkmem, /**< block memory */
557  size_t num, /**< size of array to be allocated */
558  size_t typesize, /**< size of each component */
559  const char* filename, /**< source file of the function call */
560  int line /**< line number in source file of the function call */
561  );
562 
563 /** resizes memory element in the block memory pool and copies the data */
564 extern
566  BMS_BLKMEM* blkmem, /**< block memory */
567  void* ptr, /**< memory element to reallocated */
568  size_t oldsize, /**< old size of memory element */
569  size_t newsize, /**< new size of memory element */
570  const char* filename, /**< source file of the function call */
571  int line /**< line number in source file of the function call */
572  );
573 
574 /** resizes array in the block memory pool and copies the data */
575 extern
577  BMS_BLKMEM* blkmem, /**< block memory */
578  void* ptr, /**< memory element to reallocated */
579  size_t oldnum, /**< old size of array */
580  size_t newnum, /**< new size of array */
581  size_t typesize, /**< size of each component */
582  const char* filename, /**< source file of the function call */
583  int line /**< line number in source file of the function call */
584  );
585 
586 /** duplicates memory element in the block memory pool and copies the data */
587 extern
589  BMS_BLKMEM* blkmem, /**< block memory */
590  const void* source, /**< memory element to duplicate */
591  size_t size, /**< size of memory elements */
592  const char* filename, /**< source file of the function call */
593  int line /**< line number in source file of the function call */
594  );
595 
596 /** duplicates array in the block memory pool and copies the data */
597 extern
599  BMS_BLKMEM* blkmem, /**< block memory */
600  const void* source, /**< memory element to duplicate */
601  size_t num, /**< size of array to be duplicated */
602  size_t typesize, /**< size of each component */
603  const char* filename, /**< source file of the function call */
604  int line /**< line number in source file of the function call */
605  );
606 
607 /** frees memory element in the block memory pool and sets pointer to NULL */
608 extern
610  BMS_BLKMEM* blkmem, /**< block memory */
611  void** ptr, /**< pointer to pointer to memory element to free */
612  size_t size, /**< size of memory element */
613  const char* filename, /**< source file of the function call */
614  int line /**< line number in source file of the function call */
615  );
616 
617 /** frees memory element in the block memory pool if pointer is not NULL and sets pointer to NULL */
618 extern
620  BMS_BLKMEM* blkmem, /**< block memory */
621  void** ptr, /**< pointer to pointer to memory element to free */
622  size_t size, /**< size of memory element */
623  const char* filename, /**< source file of the function call */
624  int line /**< line number in source file of the function call */
625  );
626 
627 /** calls garbage collection of block memory, frees chunks without allocated memory elements, and frees
628  * chunk blocks without any chunks
629  */
630 extern
632  BMS_BLKMEM* blkmem /**< block memory */
633  );
634 
635 /** returns the number of allocated bytes in the block memory */
636 extern
638  const BMS_BLKMEM* blkmem /**< block memory */
639  );
640 
641 /** returns the number of used bytes in the block memory */
642 extern
644  const BMS_BLKMEM* blkmem /**< block memory */
645  );
646 
647 /** returns the number of allocated but not used bytes in the block memory */
648 extern
650  const BMS_BLKMEM* blkmem /**< block memory */
651  );
652 
653 /** returns the maximal number of used bytes in the block memory */
654 extern
656  const BMS_BLKMEM* blkmem /**< block memory */
657  );
658 
659 /** returns the maximal number of allocated but not used bytes in the block memory */
660 extern
662  const BMS_BLKMEM* blkmem /**< block memory */
663  );
664 
665 /** returns the maximal number of allocated bytes in the block memory */
667  const BMS_BLKMEM* blkmem /**< block memory */
668  );
669 
670 /** returns the size of the given memory element; returns 0, if the element is not member of the block memory */
671 extern
673  const BMS_BLKMEM* blkmem, /**< block memory */
674  const void* ptr /**< memory element */
675  );
676 
677 /** outputs allocation diagnostics of block memory */
678 extern
680  const BMS_BLKMEM* blkmem /**< block memory */
681  );
682 
683 /** outputs error messages, if there are allocated elements in the block memory and returns number of unfreed bytes */
684 extern
686  const BMS_BLKMEM* blkmem /**< block memory */
687  );
688 
689 
690 
691 
692 
693 /***********************************************************
694  * Buffer Memory Management
695  *
696  * Efficient memory management for temporary objects
697  ***********************************************************/
698 
699 typedef struct BMS_BufMem BMS_BUFMEM; /**< buffer memory for temporary objects */
700 
701 /* Note: values that are passed as a size_t parameter are first converted to ptrdiff_t to be sure that negative numbers
702  * are extended to the larger size. Then they are converted to size_t. Thus, negative numbers are converted to very
703  * large size_t values. This is then checked within the functions. */
704 
705 #define BMSallocBufferMemory(mem,ptr) ASSIGN((ptr), BMSallocBufferMemory_call((mem), sizeof(**(ptr)), __FILE__, __LINE__))
706 #define BMSallocBufferMemorySize(mem,ptr,size) ASSIGN((ptr), BMSallocBufferMemory_call((mem), (size_t)(ptrdiff_t)(size), __FILE__, __LINE__))
707 #define BMSreallocBufferMemorySize(mem,ptr,size) \
708  ASSIGN((ptr), BMSreallocBufferMemory_call((mem), (void*)(*(ptr)), (size_t)(ptrdiff_t)(size), __FILE__, __LINE__))
709 #define BMSallocBufferMemoryArray(mem,ptr,num) ASSIGN((ptr), BMSallocBufferMemoryArray_call((mem), (size_t)(ptrdiff_t)(num), sizeof(**(ptr)), __FILE__, __LINE__))
710 #define BMSallocClearBufferMemoryArray(mem,ptr,num) ASSIGN((ptr), BMSallocClearBufferMemoryArray_call((mem), (size_t)(ptrdiff_t)(num), sizeof(**(ptr)), __FILE__, __LINE__))
711 #define BMSreallocBufferMemoryArray(mem,ptr,num) ASSIGN((ptr), BMSreallocBufferMemoryArray_call((mem), (void*)(*(ptr)), (size_t)(ptrdiff_t)(num), \
712  sizeof(**(ptr)), __FILE__, __LINE__))
713 #define BMSduplicateBufferMemory(mem,ptr,source,size) \
714  ASSIGN((ptr), BMSduplicateBufferMemory_call((mem), (const void*)(source), (size_t)(ptrdiff_t)(size), __FILE__, __LINE__))
715 #define BMSduplicateBufferMemoryArray(mem,ptr,source,num) ASSIGNCHECK((ptr), BMSduplicateBufferMemoryArray_call((mem), \
716  (const void*)(source), (size_t)(ptrdiff_t)(num), sizeof(**(ptr)), __FILE__, __LINE__), source)
717 
718 #define BMSfreeBufferMemory(mem,ptr) BMSfreeBufferMemory_call((mem), (void**)(ptr), __FILE__, __LINE__)
719 #define BMSfreeBufferMemoryNull(mem,ptr) BMSfreeBufferMemoryNull_call((mem), (void**)(ptr), __FILE__, __LINE__)
720 #define BMSfreeBufferMemoryArray(mem,ptr) BMSfreeBufferMemory_call((mem), (void**)(ptr), __FILE__, __LINE__)
721 #define BMSfreeBufferMemoryArrayNull(mem,ptr) BMSfreeBufferMemoryNull_call((mem), (void**)(ptr), __FILE__, __LINE__)
722 #define BMSfreeBufferMemorySize(mem,ptr) BMSfreeBufferMemory_call((mem), (void**)(ptr), __FILE__, __LINE__);
723 #define BMSfreeBufferMemorySizeNull(mem,ptr) BMSfreeBufferMemoryNull_call((mem), (void**)(ptr), __FILE__, __LINE__)
724 
725 #define BMScreateBufferMemory(fac,init,clean) BMScreateBufferMemory_call((fac), (init), (clean), __FILE__, __LINE__)
726 #define BMSdestroyBufferMemory(mem) BMSdestroyBufferMemory_call((mem), __FILE__, __LINE__)
727 
728 
729 /** creates memory buffer storage */
730 extern
732  double arraygrowfac, /**< memory growing factor for dynamically allocated arrays */
733  int arraygrowinit, /**< initial size of dynamically allocated arrays */
734  unsigned int clean, /**< should the memory blocks in the buffer be initialized to zero? */
735  const char* filename, /**< source file of the function call */
736  int line /**< line number in source file of the function call */
737  );
738 
739 /** destroys buffer memory */
740 extern
742  BMS_BUFMEM** buffer, /**< pointer to memory buffer storage */
743  const char* filename, /**< source file of the function call */
744  int line /**< line number in source file of the function call */
745  );
746 
747 /** set arraygrowfac */
748 extern
750  BMS_BUFMEM* buffer, /**< pointer to memory buffer storage */
751  double arraygrowfac /**< memory growing factor for dynamically allocated arrays */
752  );
753 
754 /** set arraygrowinit */
755 extern
757  BMS_BUFMEM* buffer, /**< pointer to memory buffer storage */
758  int arraygrowinit /**< initial size of dynamically allocated arrays */
759  );
760 
761 /** allocates the next unused buffer */
762 extern
764  BMS_BUFMEM* buffer, /**< memory buffer storage */
765  size_t size, /**< minimal required size of the buffer */
766  const char* filename, /**< source file of the function call */
767  int line /**< line number in source file of the function call */
768  );
769 
770 /** allocates the next unused buffer array */
771 extern
773  BMS_BUFMEM* buffer, /**< memory buffer storage */
774  size_t num, /**< size of array to be allocated */
775  size_t typesize, /**< size of components */
776  const char* filename, /**< source file of the function call */
777  int line /**< line number in source file of the function call */
778  );
779 
780 /** allocates the next unused buffer and clears it */
781 extern
783  BMS_BUFMEM* buffer, /**< memory buffer storage */
784  size_t num, /**< size of array to be allocated */
785  size_t typesize, /**< size of components */
786  const char* filename, /**< source file of the function call */
787  int line /**< line number in source file of the function call */
788  );
789 
790 /** reallocates the buffer to at least the given size */
791 extern
793  BMS_BUFMEM* buffer, /**< memory buffer storage */
794  void* ptr, /**< pointer to the allocated memory buffer */
795  size_t size, /**< minimal required size of the buffer */
796  const char* filename, /**< source file of the function call */
797  int line /**< line number in source file of the function call */
798  );
799 
800 /** reallocates an array in the buffer to at least the given size */
801 extern
803  BMS_BUFMEM* buffer, /**< memory buffer storage */
804  void* ptr, /**< pointer to the allocated memory buffer */
805  size_t num, /**< size of array to be allocated */
806  size_t typesize, /**< size of components */
807  const char* filename, /**< source file of the function call */
808  int line /**< line number in source file of the function call */
809  );
810 
811 /** allocates the next unused buffer and copies the given memory into the buffer */
812 extern
814  BMS_BUFMEM* buffer, /**< memory buffer storage */
815  const void* source, /**< memory block to copy into the buffer */
816  size_t size, /**< minimal required size of the buffer */
817  const char* filename, /**< source file of the function call */
818  int line /**< line number in source file of the function call */
819  );
820 
821 /** allocates an array in the next unused buffer and copies the given memory into the buffer */
822 extern
824  BMS_BUFMEM* buffer, /**< memory buffer storage */
825  const void* source, /**< memory block to copy into the buffer */
826  size_t num, /**< size of array to be allocated */
827  size_t typesize, /**< size of components */
828  const char* filename, /**< source file of the function call */
829  int line /**< line number in source file of the function call */
830  );
831 
832 /** frees a buffer and sets pointer to NULL */
833 extern
835  BMS_BUFMEM* buffer, /**< memory buffer storage */
836  void** ptr, /**< pointer to pointer to the allocated memory buffer */
837  const char* filename, /**< source file of the function call */
838  int line /**< line number in source file of the function call */
839  );
840 
841 /** frees a buffer if pointer is not NULL and sets pointer to NULL */
842 extern
844  BMS_BUFMEM* buffer, /**< memory buffer storage */
845  void** ptr, /**< pointer to pointer to the allocated memory buffer */
846  const char* filename, /**< source file of the function call */
847  int line /**< line number in source file of the function call */
848  );
849 
850 /** gets number of used buffers */
851 extern
853  BMS_BUFMEM* buffer /**< memory buffer storage */
854  );
855 
856 /** returns the number of allocated bytes in the buffer memory */
857 extern
858 long long BMSgetBufferMemoryUsed(
859  const BMS_BUFMEM* bufmem /**< buffer memory */
860  );
861 
862 /** outputs statistics about currently allocated buffers to the screen */
863 extern
865  BMS_BUFMEM* buffer /**< memory buffer storage */
866  );
867 
868 
869 #ifdef __cplusplus
870 }
871 #endif
872 
873 #endif
void * BMSreallocBufferMemory_call(BMS_BUFMEM *buffer, void *ptr, size_t size, const char *filename, int line)
Definition: memory.c:2889
void BMSfreeBufferMemoryNull_call(BMS_BUFMEM *buffer, void **ptr, const char *filename, int line)
Definition: memory.c:3074
void BMSdestroyChunkMemory_call(BMS_CHKMEM **chkmem, const char *filename, int line)
Definition: memory.c:1496
void * BMSallocBlockMemory_call(BMS_BLKMEM *blkmem, size_t size, const char *filename, int line)
Definition: memory.c:1880
struct BMS_ChkMem BMS_CHKMEM
Definition: memory.h:291
BMS_CHKMEM * BMScreateChunkMemory_call(size_t size, int initchunksize, int garbagefactor, const char *filename, int line)
Definition: memory.c:1454
void BMSfreeMemoryNull_call(void **ptr, const char *filename, int line)
Definition: memory.c:634
void * BMSallocChunkMemory_call(BMS_CHKMEM *chkmem, size_t size, const char *filename, int line)
Definition: memory.c:1516
void * BMSallocBlockMemoryArray_call(BMS_BLKMEM *blkmem, size_t num, size_t typesize, const char *filename, int line)
Definition: memory.c:1900
void * BMSallocClearBlockMemoryArray_call(BMS_BLKMEM *blkmem, size_t num, size_t typesize, const char *filename, int line)
Definition: memory.c:1921
void BMSclearBlockMemory_call(BMS_BLKMEM *blkmem, const char *filename, int line)
Definition: memory.c:1760
double arraygrowfac
Definition: memory.c:2477
void * BMSallocBufferMemoryArray_call(BMS_BUFMEM *buffer, size_t num, size_t typesize, const char *filename, int line)
Definition: memory.c:2777
size_t * size
Definition: memory.c:2471
int BMSisAligned(size_t size)
Definition: memory.c:770
void BMSdestroyBlockMemory_call(BMS_BLKMEM **blkmem, const char *filename, int line)
Definition: memory.c:1794
long long BMScheckEmptyBlockMemory_call(const BMS_BLKMEM *blkmem)
Definition: memory.c:2389
void * BMSreallocBlockMemoryArray_call(BMS_BLKMEM *blkmem, void *ptr, size_t oldnum, size_t newnum, size_t typesize, const char *filename, int line)
Definition: memory.c:1979
size_t BMSgetBlockPointerSize_call(const BMS_BLKMEM *blkmem, const void *ptr)
Definition: memory.c:2245
void * BMSduplicateChunkMemory_call(BMS_CHKMEM *chkmem, const void *source, size_t size, const char *filename, int line)
Definition: memory.c:1543
void BMSfreeChunkMemory_call(BMS_CHKMEM *chkmem, void **ptr, size_t size, const char *filename, int line)
Definition: memory.c:1565
long long BMSgetBlockMemoryUsedMax_call(const BMS_BLKMEM *blkmem)
Definition: memory.c:2215
long long BMSgetBlockMemoryAllocated_call(const BMS_BLKMEM *blkmem)
Definition: memory.c:2185
void * BMSallocBufferMemory_call(BMS_BUFMEM *buffer, size_t size, const char *filename, int line)
Definition: memory.c:2757
void BMSsetBufferMemoryArraygrowinit(BMS_BUFMEM *buffer, int arraygrowinit)
Definition: memory.c:2564
void * BMSallocClearBufferMemoryArray_call(BMS_BUFMEM *buffer, size_t num, size_t typesize, const char *filename, int line)
Definition: memory.c:2798
void * BMSduplicateMemory_call(const void *source, size_t size, const char *filename, int line)
Definition: memory.c:572
void * BMSreallocBlockMemory_call(BMS_BLKMEM *blkmem, void *ptr, size_t oldsize, size_t newsize, const char *filename, int line)
Definition: memory.c:1939
void * BMSreallocMemoryArray_call(void *ptr, size_t num, size_t typesize, const char *filename, int line)
Definition: memory.c:484
void * BMSallocMemoryArray_call(size_t num, size_t typesize, const char *filename, int line)
Definition: memory.c:404
void BMSdestroyBufferMemory_call(BMS_BUFMEM **buffer, const char *filename, int line)
Definition: memory.c:2519
void BMSdisplayMemory_call(void)
Definition: memory.c:297
BMS_BLKMEM * BMScreateBlockMemory_call(int initchunksize, int garbagefactor, const char *filename, int line)
Definition: memory.c:1726
void BMSclearMemory_call(void *ptr, size_t size)
Definition: memory.c:527
void BMSfreeBufferMemory_call(BMS_BUFMEM *buffer, void **ptr, const char *filename, int line)
Definition: memory.c:3051
void * BMSduplicateBlockMemory_call(BMS_BLKMEM *blkmem, const void *source, size_t size, const char *filename, int line)
Definition: memory.c:2018
void BMScheckEmptyMemory_call(void)
Definition: memory.c:307
void BMSgarbagecollectChunkMemory_call(BMS_CHKMEM *chkmem)
Definition: memory.c:1618
void * BMSreallocMemory_call(void *ptr, size_t size, const char *filename, int line)
Definition: memory.c:444
long long BMSgetBlockMemoryUsed_call(const BMS_BLKMEM *blkmem)
Definition: memory.c:2195
long long BMSgetBlockMemoryAllocatedMax_call(const BMS_BLKMEM *blkmem)
Definition: memory.c:2235
void * BMSduplicateBlockMemoryArray_call(BMS_BLKMEM *blkmem, const void *source, size_t num, size_t typesize, const char *filename, int line)
Definition: memory.c:2038
void BMSfreeBlockMemoryNull_call(BMS_BLKMEM *blkmem, void **ptr, size_t size, const char *filename, int line)
Definition: memory.c:2130
long long BMSgetChunkMemoryUsed_call(const BMS_CHKMEM *chkmem)
Definition: memory.c:1628
void BMSgarbagecollectBlockMemory_call(BMS_BLKMEM *blkmem)
Definition: memory.c:2151
void BMSprintBufferMemory(BMS_BUFMEM *buffer)
Definition: memory.c:3122
void * BMSallocMemory_call(size_t size, const char *filename, int line)
Definition: memory.c:368
unsigned int arraygrowinit
Definition: memory.c:2478
void BMSfreeMemory_call(void **ptr, const char *filename, int line)
Definition: memory.c:611
BMS_BUFMEM * BMScreateBufferMemory_call(double arraygrowfac, int arraygrowinit, unsigned int clean, const char *filename, int line)
Definition: memory.c:2483
void * BMSallocClearMemory_call(size_t num, size_t typesize, const char *filename, int line)
Definition: memory.c:327
long long BMSgetBlockMemoryUnusedMax_call(const BMS_BLKMEM *blkmem)
Definition: memory.c:2225
void BMSsetBufferMemoryArraygrowfac(BMS_BUFMEM *buffer, double arraygrowfac)
Definition: memory.c:2552
void * BMSduplicateBufferMemory_call(BMS_BUFMEM *buffer, const void *source, size_t size, const char *filename, int line)
Definition: memory.c:2932
void BMSmoveMemory_call(void *ptr, const void *source, size_t size)
Definition: memory.c:557
void * BMSreallocBufferMemoryArray_call(BMS_BUFMEM *buffer, void *ptr, size_t num, size_t typesize, const char *filename, int line)
Definition: memory.c:2910
void BMSfreeChunkMemoryNull_call(BMS_CHKMEM *chkmem, void **ptr, size_t size, const char *filename, int line)
Definition: memory.c:1594
long long BMSgetBlockMemoryUnused_call(const BMS_BLKMEM *blkmem)
Definition: memory.c:2205
size_t BMSgetNUsedBufferMemory(BMS_BUFMEM *buffer)
Definition: memory.c:3094
void BMSalignMemsize(size_t *size)
Definition: memory.c:761
void BMScopyMemory_call(void *ptr, const void *source, size_t size)
Definition: memory.c:540
void BMSfreeBlockMemory_call(BMS_BLKMEM *blkmem, void **ptr, size_t size, const char *filename, int line)
Definition: memory.c:2108
void BMSdisplayBlockMemory_call(const BMS_BLKMEM *blkmem)
Definition: memory.c:2265
void BMSclearChunkMemory_call(BMS_CHKMEM *chkmem, const char *filename, int line)
Definition: memory.c:1478
size_t BMSgetPointerSize_call(const void *ptr)
Definition: memory.c:289
struct BMS_BlkMem BMS_BLKMEM
Definition: memory.h:426
unsigned int clean
Definition: memory.c:2474
long long BMSgetMemoryUsed_call(void)
Definition: memory.c:317
void * BMSduplicateMemoryArray_call(const void *source, size_t num, size_t typesize, const char *filename, int line)
Definition: memory.c:591
long long BMSgetBufferMemoryUsed(const BMS_BUFMEM *bufmem)
Definition: memory.c:3104
void * BMSduplicateBufferMemoryArray_call(BMS_BUFMEM *buffer, const void *source, size_t num, size_t typesize, const char *filename, int line)
Definition: memory.c:2955