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-2021 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 #include "scip/scip_export.h"
38 #endif
39 
40 #ifdef __cplusplus
41 
42 
43 /* special thanks to Daniel Junglas for following template and macros */
44 
45 template<typename T> T* docast(T*, void *v);
46 template<typename T> T* docast(T*, void *v) { return reinterpret_cast<T*>(v); }
47 
48 /* For C++11, we can easily check whether the types for memory functions like BMSduplicateXYZArray() are equal. */
49 #if __cplusplus > 199711L
50 #include <type_traits>
51 
52 /* the following adds a type check for the parameters, used in ASSIGNCHECK below */
53 template<typename T1, typename T2> T1* docastcheck(T1* v1, void* v, T2* v2)
54 {
55  typedef typename std::remove_const<T1>::type t1;
56  typedef typename std::remove_const<T2>::type t2;
57  static_assert(std::is_same<t1, t2>::value, "need equal types");
58  return reinterpret_cast<T1*>(v);
59 }
60 #else
61 /* for older compilers do nothing */
62 template<typename T1, typename T2> T1* docastcheck(T1* v1, void* v, T2* v2) { return reinterpret_cast<T1*>(v); }
63 #endif
64 
65 
66 extern "C" {
67 
68 #define ASSIGN(pointerstarstar, voidstarfunction) (*(pointerstarstar) = docast(*(pointerstarstar), (voidstarfunction)))
69 #define ASSIGNCHECK(pointerstarstar, voidstarfunction, origpointer) (*(pointerstarstar) = docastcheck(*(pointerstarstar), (voidstarfunction), (origpointer)))
70 
71 #else
72 
73 #define ASSIGN(pointerstarstar, voidstarfunction) (*(pointerstarstar) = (voidstarfunction))
74 #define ASSIGNCHECK(pointerstarstar, voidstarfunction, origpointer) (*(pointerstarstar) = (voidstarfunction))
75 
76 #endif
77 
78 /*
79  * Define the macro SCIP_EXPORT depending if the OS is Windows or not
80  */
81 #ifndef SCIP_EXPORT
82 
83 #if defined(_WIN32) || defined(_WIN64)
84 #define SCIP_EXPORT __declspec(dllexport)
85 #elif defined(__GNUC__) && __GNUC__ >= 4
86 #define SCIP_EXPORT __attribute__((__visibility__("default")))
87 #else
88 #define SCIP_EXPORT
89 #endif
90 
91 #endif
92 
93 /* define if not already existing to make file independent from def.h */
94 #ifndef SCIP_UNUSED
95 #define SCIP_UNUSED(x) ((void) (x))
96 #endif
97 
98 
99 /*************************************************************************************
100  * Standard Memory Management
101  *
102  * In debug mode, these methods extend malloc() and free() by logging all currently
103  * allocated memory elements in an allocation list. This can be used as a simple leak
104  * detection.
105  *************************************************************************************/
106 
107 /* Note: values that are passed as a size_t parameter are first converted to ptrdiff_t to be sure that negative numbers
108  * are extended to the larger size. Then they are converted to size_t. Thus, negative numbers are converted to very
109  * large size_t values. This is then checked within the functions. */
110 
111 #define BMSallocMemory(ptr) ASSIGN((ptr), BMSallocMemory_call( sizeof(**(ptr)), __FILE__, __LINE__ ))
112 #define BMSallocClearMemory(ptr) ASSIGN((ptr), BMSallocClearMemory_call((size_t)(1), sizeof(**(ptr)), __FILE__, __LINE__ ))
113 #define BMSallocMemorySize(ptr,size) ASSIGN((ptr), BMSallocMemory_call( (size_t)(ptrdiff_t)(size), __FILE__, __LINE__ ))
114 #define BMSallocMemoryCPP(size) BMSallocMemory_call( (size_t)(ptrdiff_t)(size), __FILE__, __LINE__ )
115 #define BMSallocClearMemorySize(ptr,size) ASSIGN((ptr), BMSallocClearMemory_call((size_t)(1), (size_t)(ptrdiff_t)(size), __FILE__, __LINE__ ))
116 #define BMSallocMemoryArray(ptr,num) ASSIGN((ptr), BMSallocMemoryArray_call((size_t)(ptrdiff_t)(num), sizeof(**(ptr)), __FILE__, __LINE__ ))
117 #define BMSallocMemoryArrayCPP(num,size) BMSallocMemoryArray_call( (size_t)(ptrdiff_t)(num), (size_t)(ptrdiff_t)(size), __FILE__, __LINE__ )
118 #define BMSallocClearMemoryArray(ptr,num) ASSIGN((ptr), BMSallocClearMemory_call((size_t)(ptrdiff_t)(num), sizeof(**(ptr)), __FILE__, __LINE__ ))
119 #define BMSreallocMemorySize(ptr,size) ASSIGN((ptr), BMSreallocMemory_call((void*)(*(ptr)), (size_t)(ptrdiff_t)(size), __FILE__, __LINE__ ))
120 #define BMSreallocMemoryArray(ptr,num) ASSIGN((ptr), BMSreallocMemoryArray_call( *(ptr), (size_t)(ptrdiff_t)(num), sizeof(**(ptr)), __FILE__, __LINE__ ))
121 
122 #define BMSclearMemory(ptr) BMSclearMemory_call( (void*)(ptr), sizeof(*(ptr)) )
123 #define BMSclearMemoryArray(ptr, num) BMSclearMemory_call( (void*)(ptr), (size_t)(ptrdiff_t)(num)*sizeof(*(ptr)) )
124 #define BMSclearMemorySize(ptr, size) BMSclearMemory_call( (void*)(ptr), (size_t)(ptrdiff_t)(size) )
125 
126 #define BMScopyMemory(ptr, source) BMScopyMemory_call( (void*)(ptr), (const void*)(source), sizeof(*(ptr)) )
127 #define BMScopyMemoryArray(ptr, source, num) BMScopyMemory_call( (void*)(ptr), (const void*)(source), (size_t)(ptrdiff_t)(num)*sizeof(*(ptr)) )
128 #define BMScopyMemorySize(ptr, source, size) BMScopyMemory_call( (void*)(ptr), (const void*)(source), (size_t)(ptrdiff_t)(size) )
129 
130 #define BMSmoveMemory(ptr, source) BMSmoveMemory_call( (void*)(ptr), (const void*)(source), sizeof(*(ptr)) )
131 #define BMSmoveMemoryArray(ptr, source, num) BMSmoveMemory_call( (void*)(ptr), (const void*)(source), (size_t)(ptrdiff_t)(num) * sizeof(*(ptr)) )
132 #define BMSmoveMemorySize(ptr, source, size) BMSmoveMemory_call( (void*)(ptr), (const void*)(source), (size_t)(ptrdiff_t)(size) )
133 
134 #define BMSduplicateMemory(ptr, source) ASSIGN((ptr), BMSduplicateMemory_call( (const void*)(source), sizeof(**(ptr)), __FILE__, __LINE__ ))
135 #define BMSduplicateMemorySize(ptr, source, size) ASSIGN((ptr), BMSduplicateMemory_call( (const void*)(source), (size_t)(ptrdiff_t)(size), __FILE__, __LINE__ ))
136 #define BMSduplicateMemoryArray(ptr, source, num) ASSIGNCHECK((ptr), BMSduplicateMemoryArray_call( (const void*)(source), (size_t)(ptrdiff_t)(num), \
137  sizeof(**(ptr)), __FILE__, __LINE__ ), source)
138 #define BMSfreeMemory(ptr) BMSfreeMemory_call( (void**)(ptr), __FILE__, __LINE__ )
139 #define BMSfreeMemoryNull(ptr) BMSfreeMemoryNull_call( (void**)(ptr), __FILE__, __LINE__ )
140 #define BMSfreeMemoryArray(ptr) BMSfreeMemory_call( (void**)(ptr), __FILE__, __LINE__ )
141 #define BMSfreeMemoryArrayNull(ptr) BMSfreeMemoryNull_call( (void**)(ptr), __FILE__, __LINE__ )
142 #define BMSfreeMemorySize(ptr) BMSfreeMemory_call( (void**)(ptr), __FILE__, __LINE__ )
143 #define BMSfreeMemorySizeNull(ptr) BMSfreeMemoryNull_call( (void**)(ptr), __FILE__, __LINE__ )
144 
145 #ifndef NDEBUG
146 #define BMSgetPointerSize(ptr) BMSgetPointerSize_call(ptr)
147 #define BMSdisplayMemory() BMSdisplayMemory_call()
148 #define BMScheckEmptyMemory() BMScheckEmptyMemory_call()
149 #define BMSgetMemoryUsed() BMSgetMemoryUsed_call()
150 #else
151 #define BMSgetPointerSize(ptr) 0
152 #define BMSdisplayMemory() /**/
153 #define BMScheckEmptyMemory() /**/
154 #define BMSgetMemoryUsed() 0LL
155 #endif
156 
157 /** allocates array and initializes it with 0; returns NULL if memory allocation failed */
158 SCIP_EXPORT
160  size_t num, /**< number of memory element to allocate */
161  size_t typesize, /**< size of memory element to allocate */
162  const char* filename, /**< source file where the allocation is performed */
163  int line /**< line number in source file where the allocation is performed */
164  );
165 
166 /** allocates memory; returns NULL if memory allocation failed */
167 SCIP_EXPORT
168 void* BMSallocMemory_call(
169  size_t size, /**< size of memory element to allocate */
170  const char* filename, /**< source file where the allocation is performed */
171  int line /**< line number in source file where the allocation is performed */
172  );
173 
174 /** allocates array; returns NULL if memory allocation failed */
175 SCIP_EXPORT
177  size_t num, /**< number of components of array to allocate */
178  size_t typesize, /**< size of each component */
179  const char* filename, /**< source file where the allocation is performed */
180  int line /**< line number in source file where the allocation is performed */
181  );
182 
183 /** allocates memory; returns NULL if memory allocation failed */
184 SCIP_EXPORT
186  void* ptr, /**< pointer to memory to reallocate */
187  size_t size, /**< new size of memory element */
188  const char* filename, /**< source file where the reallocation is performed */
189  int line /**< line number in source file where the reallocation is performed */
190  );
191 
192 /** reallocates array; returns NULL if memory allocation failed */
193 SCIP_EXPORT
195  void* ptr, /**< pointer to memory to reallocate */
196  size_t num, /**< number of components of array to allocate */
197  size_t typesize, /**< size of each component */
198  const char* filename, /**< source file where the reallocation is performed */
199  int line /**< line number in source file where the reallocation is performed */
200  );
201 
202 /** clears a memory element (i.e. fills it with zeros) */
203 SCIP_EXPORT
205  void* ptr, /**< pointer to memory element */
206  size_t size /**< size of memory element */
207  );
208 
209 /** copies the contents of one memory element into another memory element */
210 SCIP_EXPORT
211 void BMScopyMemory_call(
212  void* ptr, /**< pointer to target memory element */
213  const void* source, /**< pointer to source memory element */
214  size_t size /**< size of memory element to copy */
215  );
216 
217 /** moves the contents of one memory element into another memory element, should be used if both elements overlap,
218  * otherwise BMScopyMemory is faster
219  */
220 SCIP_EXPORT
221 void BMSmoveMemory_call(
222  void* ptr, /**< pointer to target memory element */
223  const void* source, /**< pointer to source memory element */
224  size_t size /**< size of memory element to copy */
225  );
226 
227 /** allocates memory and copies the contents of the given memory element into the new memory element */
228 SCIP_EXPORT
230  const void* source, /**< pointer to source memory element */
231  size_t size, /**< size of memory element to copy */
232  const char* filename, /**< source file where the duplication is performed */
233  int line /**< line number in source file where the duplication is performed */
234  );
235 
236 /** allocates array and copies the contents of the given source array into the new array */
237 SCIP_EXPORT
239  const void* source, /**< pointer to source memory element */
240  size_t num, /**< number of components of array to allocate */
241  size_t typesize, /**< size of each component */
242  const char* filename, /**< source file where the duplication is performed */
243  int line /**< line number in source file where the duplication is performed */
244  );
245 
246 /** frees an allocated memory element and sets pointer to NULL */
247 SCIP_EXPORT
248 void BMSfreeMemory_call(
249  void** ptr, /**< pointer to pointer to memory element */
250  const char* filename, /**< source file where the deallocation is performed */
251  int line /**< line number in source file where the deallocation is performed */
252  );
253 
254 /** frees an allocated memory element if pointer is not NULL and sets pointer to NULL */
255 SCIP_EXPORT
257  void** ptr, /**< pointer to pointer to memory element */
258  const char* filename, /**< source file where the deallocation is performed */
259  int line /**< line number in source file where the deallocation is performed */
260  );
261 
262 /** returns the size of an allocated memory element */
263 SCIP_EXPORT
265  const void* ptr /**< pointer to allocated memory */
266  );
267 
268 /** outputs information about currently allocated memory to the screen */
269 SCIP_EXPORT
271  void
272  );
273 
274 /** displays a warning message on the screen, if allocated memory exists */
275 SCIP_EXPORT
277  void
278  );
279 
280 /** returns total number of allocated bytes */
281 SCIP_EXPORT
282 long long BMSgetMemoryUsed_call(
283  void
284  );
285 
286 
287 
288 
289 /********************************************************************
290  * Chunk Memory Management
291  *
292  * Efficient memory management for multiple objects of the same size
293  ********************************************************************/
294 
295 typedef struct BMS_ChkMem BMS_CHKMEM; /**< collection of memory chunks of the same element size */
296 
297 
298 #ifndef BMS_NOBLOCKMEM
299 
300 #define BMScreateChunkMemory(sz,isz,gbf) BMScreateChunkMemory_call( (sz), (isz), (gbf), __FILE__, __LINE__ )
301 #define BMSclearChunkMemory(mem) BMSclearChunkMemory_call( (mem), __FILE__, __LINE__ )
302 #define BMSdestroyChunkMemory(mem) BMSdestroyChunkMemory_call( (mem), __FILE__, __LINE__ )
303 
304 #define BMSallocChunkMemory(mem,ptr) ASSIGN((ptr), BMSallocChunkMemory_call((mem), sizeof(**(ptr)), __FILE__, __LINE__))
305 #define BMSduplicateChunkMemory(mem, ptr, source) ASSIGN((ptr), BMSduplicateChunkMemory_call((mem), (const void*)(source), \
306  sizeof(**(ptr)), __FILE__, __LINE__ ))
307 #define BMSfreeChunkMemory(mem,ptr) BMSfreeChunkMemory_call( (mem), (void**)(ptr), sizeof(**(ptr)), __FILE__, __LINE__ )
308 #define BMSfreeChunkMemoryNull(mem,ptr) BMSfreeChunkMemoryNull_call( (mem), (void**)(ptr), sizeof(**(ptr)), __FILE__, __LINE__ )
309 #define BMSgarbagecollectChunkMemory(mem) BMSgarbagecollectChunkMemory_call(mem)
310 #define BMSgetChunkMemoryUsed(mem) BMSgetChunkMemoryUsed_call(mem)
311 
312 #else
313 
314 /* block memory management mapped to standard memory management */
315 
316 #define BMScreateChunkMemory(sz,isz,gbf) (void*)(0x01) /* dummy to not return a NULL pointer */
317 #define BMSclearChunkMemory(mem) /**/
318 #define BMSclearChunkMemoryNull(mem) /**/
319 #define BMSdestroyChunkMemory(mem) /**/
320 #define BMSdestroyChunkMemoryNull(mem) /**/
321 #define BMSallocChunkMemory(mem,ptr) BMSallocMemory(ptr)
322 #define BMSduplicateChunkMemory(mem, ptr, source) BMSduplicateMemory(ptr,source)
323 #define BMSfreeChunkMemory(mem,ptr) BMSfreeMemory(ptr)
324 #define BMSfreeChunkMemoryNull(mem,ptr) BMSfreeMemoryNull(ptr)
325 #define BMSgarbagecollectChunkMemory(mem) /**/
326 #define BMSgetChunkMemoryUsed(mem) 0LL
327 
328 #endif
329 
330 
331 /** aligns the given byte size corresponding to the minimal alignment for chunk and block memory */
332 SCIP_EXPORT
333 void BMSalignMemsize(
334  size_t* size /**< pointer to the size to align */
335  );
336 
337 /** checks whether the given size meets the alignment conditions for chunk and block memory */
338 SCIP_EXPORT
339 int BMSisAligned(
340  size_t size /**< size to check for alignment */
341  );
342 
343 /** creates a new chunk block data structure */
344 SCIP_EXPORT
346  size_t size, /**< element size of the chunk block */
347  int initchunksize, /**< number of elements in the first chunk of the chunk block */
348  int garbagefactor, /**< garbage collector is called, if at least garbagefactor * avg. chunksize
349  * elements are free (-1: disable garbage collection) */
350  const char* filename, /**< source file of the function call */
351  int line /**< line number in source file of the function call */
352  );
353 
354 /** clears a chunk block data structure */
355 SCIP_EXPORT
357  BMS_CHKMEM* chkmem, /**< chunk block */
358  const char* filename, /**< source file of the function call */
359  int line /**< line number in source file of the function call */
360  );
361 
362 /** destroys and frees a chunk block data structure */
363 SCIP_EXPORT
365  BMS_CHKMEM** chkmem, /**< pointer to chunk block */
366  const char* filename, /**< source file of the function call */
367  int line /**< line number in source file of the function call */
368  );
369 
370 /** allocates a memory element of the given chunk block */
371 SCIP_EXPORT
373  BMS_CHKMEM* chkmem, /**< chunk block */
374  size_t size, /**< size of memory element to allocate (only needed for sanity check) */
375  const char* filename, /**< source file of the function call */
376  int line /**< line number in source file of the function call */
377  );
378 
379 /** duplicates a given memory element by allocating a new element of the same chunk block and copying the data */
380 SCIP_EXPORT
382  BMS_CHKMEM* chkmem, /**< chunk block */
383  const void* source, /**< source memory element */
384  size_t size, /**< size of memory element to allocate (only needed for sanity check) */
385  const char* filename, /**< source file of the function call */
386  int line /**< line number in source file of the function call */
387  );
388 
389 /** frees a memory element of the given chunk block and sets pointer to NULL */
390 SCIP_EXPORT
392  BMS_CHKMEM* chkmem, /**< chunk block */
393  void** ptr, /**< pointer to pointer to memory element to free */
394  size_t size, /**< size of memory element to allocate (only needed for sanity check) */
395  const char* filename, /**< source file of the function call */
396  int line /**< line number in source file of the function call */
397  );
398 
399 /** frees a memory element of the given chunk block if pointer is not NULL and sets pointer to NULL */
400 SCIP_EXPORT
402  BMS_CHKMEM* chkmem, /**< chunk block */
403  void** ptr, /**< pointer to pointer to memory element to free */
404  size_t size, /**< size of memory element to allocate (only needed for sanity check) */
405  const char* filename, /**< source file of the function call */
406  int line /**< line number in source file of the function call */
407  );
408 
409 /** calls garbage collection of chunk block and frees chunks without allocated memory elements */
410 SCIP_EXPORT
412  BMS_CHKMEM* chkmem /**< chunk block */
413  );
414 
415 /** returns the number of allocated bytes in the chunk block */
416 SCIP_EXPORT
418  const BMS_CHKMEM* chkmem /**< chunk block */
419  );
420 
421 
422 
423 
424 /***********************************************************
425  * Block Memory Management
426  *
427  * Efficient memory management for objects of varying sizes
428  ***********************************************************/
429 
430 typedef struct BMS_BlkMem BMS_BLKMEM; /**< block memory: collection of chunk blocks */
431 
432 #ifndef BMS_NOBLOCKMEM
433 
434 /* block memory methods for faster memory access */
435 
436 /* Note: values that are passed as a size_t parameter are first converted to ptrdiff_t to be sure that negative numbers
437  * are extended to the larger size. Then they are converted to size_t. Thus, negative numbers are converted to very
438  * large size_t values. This is then checked within the functions. */
439 
440 #define BMScreateBlockMemory(csz,gbf) BMScreateBlockMemory_call( (csz), (gbf), __FILE__, __LINE__ )
441 #define BMSclearBlockMemory(mem) BMSclearBlockMemory_call( (mem), __FILE__, __LINE__ )
442 #define BMSdestroyBlockMemory(mem) BMSdestroyBlockMemory_call( (mem), __FILE__, __LINE__ )
443 
444 #define BMSallocBlockMemory(mem,ptr) ASSIGN((ptr), BMSallocBlockMemory_call((mem), sizeof(**(ptr)), __FILE__, __LINE__))
445 #define BMSallocClearBlockMemory(mem,ptr) ASSIGN((ptr), BMSallocClearBlockMemory_call((mem), sizeof(**(ptr)), __FILE__, __LINE__))
446 #define BMSallocBlockMemorySize(mem,ptr,size) ASSIGN((ptr), BMSallocBlockMemory_call((mem), (size_t)(ptrdiff_t)(size), __FILE__, __LINE__))
447 #define BMSallocBlockMemoryArray(mem,ptr,num) ASSIGN((ptr), BMSallocBlockMemoryArray_call((mem), (size_t)(ptrdiff_t)(num), sizeof(**(ptr)), __FILE__, __LINE__))
448 #define BMSallocClearBlockMemoryArray(mem,ptr,num) ASSIGN((ptr), BMSallocClearBlockMemoryArray_call((mem), (size_t)(ptrdiff_t)(num), sizeof(**(ptr)), __FILE__, __LINE__))
449 #define BMSreallocBlockMemorySize(mem,ptr,oldsize,newsize) ASSIGN((ptr), BMSreallocBlockMemory_call((mem), (void*)(*(ptr)), \
450  (size_t)(ptrdiff_t)(oldsize), (size_t)(ptrdiff_t)(newsize), __FILE__, __LINE__))
451 #define BMSreallocBlockMemoryArray(mem,ptr,oldnum,newnum) ASSIGN((ptr), BMSreallocBlockMemoryArray_call((mem), (void*)(*(ptr)), \
452  (size_t)(ptrdiff_t)(oldnum), (size_t)(ptrdiff_t)(newnum), sizeof(**(ptr)), __FILE__, __LINE__))
453 #define BMSduplicateBlockMemory(mem, ptr, source) ASSIGN((ptr), BMSduplicateBlockMemory_call((mem), (const void*)(source), \
454  sizeof(**(ptr)), __FILE__, __LINE__ ))
455 #define BMSduplicateBlockMemoryArray(mem, ptr, source, num) ASSIGNCHECK((ptr), BMSduplicateBlockMemoryArray_call( (mem), (const void*)(source), \
456  (size_t)(ptrdiff_t)(num), sizeof(**(ptr)), __FILE__, __LINE__ ), source)
457 
458 #define BMSfreeBlockMemory(mem,ptr) BMSfreeBlockMemory_call( (mem), (void**)(ptr), sizeof(**(ptr)), __FILE__, __LINE__ )
459 #define BMSfreeBlockMemoryNull(mem,ptr) BMSfreeBlockMemoryNull_call( (mem), (void**)(ptr), sizeof(**(ptr)), __FILE__, __LINE__ )
460 #define BMSfreeBlockMemoryArray(mem,ptr,num) BMSfreeBlockMemory_call( (mem), (void**)(ptr), (num)*sizeof(**(ptr)), __FILE__, __LINE__ )
461 #define BMSfreeBlockMemoryArrayNull(mem,ptr,num) BMSfreeBlockMemoryNull_call( (mem), (void**)(ptr), (num)*sizeof(**(ptr)), __FILE__, __LINE__ )
462 #define BMSfreeBlockMemorySize(mem,ptr,size) BMSfreeBlockMemory_call( (mem), (void**)(ptr), (size_t)(ptrdiff_t)(size), __FILE__, __LINE__ )
463 #define BMSfreeBlockMemorySizeNull(mem,ptr,size) BMSfreeBlockMemory_call( (mem), (void**)(ptr), (size_t)(ptrdiff_t)(size), __FILE__, __LINE__ )
464 
465 #define BMSgarbagecollectBlockMemory(mem) BMSgarbagecollectBlockMemory_call(mem)
466 #define BMSgetBlockMemoryAllocated(mem) BMSgetBlockMemoryAllocated_call(mem)
467 #define BMSgetBlockMemoryUsed(mem) BMSgetBlockMemoryUsed_call(mem)
468 #define BMSgetBlockMemoryUnused(mem) BMSgetBlockMemoryUnused_call(mem)
469 #define BMSgetBlockMemoryUsedMax(mem) BMSgetBlockMemoryUsedMax_call(mem)
470 #define BMSgetBlockMemoryUnusedMax(mem) BMSgetBlockMemoryUnusedMax_call(mem)
471 #define BMSgetBlockMemoryAllocatedMax(mem) BMSgetBlockMemoryAllocatedMax_call(mem)
472 #define BMSgetBlockPointerSize(mem,ptr) BMSgetBlockPointerSize_call((mem), (ptr))
473 #define BMSdisplayBlockMemory(mem) BMSdisplayBlockMemory_call(mem)
474 #define BMSblockMemoryCheckEmpty(mem) BMScheckEmptyBlockMemory_call(mem)
475 
476 #else
477 
478 /* block memory management mapped to standard memory management */
479 
480 #define BMScreateBlockMemory(csz,gbf) (SCIP_UNUSED(csz), SCIP_UNUSED(gbf), (void*)(0x01)) /* dummy to not return a NULL pointer */
481 #define BMSclearBlockMemory(mem) SCIP_UNUSED(mem)
482 #define BMSclearBlockMemoryNull(mem) SCIP_UNUSED(mem)
483 #define BMSdestroyBlockMemory(mem) SCIP_UNUSED(mem)
484 #define BMSdestroyBlockMemoryNull(mem) SCIP_UNUSED(mem)
485 #define BMSallocBlockMemory(mem,ptr) (SCIP_UNUSED(mem), BMSallocMemory(ptr))
486 #define BMSallocClearBlockMemory(mem,ptr) (SCIP_UNUSED(mem), BMSallocClearMemory(ptr))
487 #define BMSallocBlockMemoryArray(mem,ptr,num) (SCIP_UNUSED(mem), BMSallocMemoryArray(ptr,num))
488 #define BMSallocClearBlockMemoryArray(mem,ptr,num) (SCIP_UNUSED(mem), BMSallocClearMemoryArray(ptr,num))
489 #define BMSallocBlockMemorySize(mem,ptr,size) (SCIP_UNUSED(mem), BMSallocMemorySize(ptr,size))
490 #define BMSreallocBlockMemoryArray(mem,ptr,oldnum,newnum) (SCIP_UNUSED(mem), SCIP_UNUSED(oldnum), BMSreallocMemoryArray(ptr,newnum))
491 #define BMSreallocBlockMemorySize(mem,ptr,oldsize,newsize) (SCIP_UNUSED(mem), SCIP_UNUSED(oldsize), BMSreallocMemorySize(ptr,newsize))
492 #define BMSduplicateBlockMemory(mem, ptr, source) (SCIP_UNUSED(mem), BMSduplicateMemory(ptr,source))
493 #define BMSduplicateBlockMemoryArray(mem, ptr, source, num) (SCIP_UNUSED(mem), BMSduplicateMemoryArray(ptr,source,num))
494 #define BMSfreeBlockMemory(mem,ptr) (SCIP_UNUSED(mem), BMSfreeMemory(ptr))
495 #define BMSfreeBlockMemoryNull(mem,ptr) (SCIP_UNUSED(mem), BMSfreeMemoryNull(ptr))
496 #define BMSfreeBlockMemoryArray(mem,ptr,num) (SCIP_UNUSED(mem), SCIP_UNUSED(num), BMSfreeMemoryArray(ptr))
497 #define BMSfreeBlockMemoryArrayNull(mem,ptr,num) (SCIP_UNUSED(mem), SCIP_UNUSED(num), BMSfreeMemoryArrayNull(ptr))
498 #define BMSfreeBlockMemorySize(mem,ptr,size) (SCIP_UNUSED(mem), SCIP_UNUSED(size), BMSfreeMemory(ptr))
499 #define BMSfreeBlockMemorySizeNull(mem,ptr,size) (SCIP_UNUSED(mem), SCIP_UNUSED(size), BMSfreeMemoryNull(ptr))
500 #define BMSgarbagecollectBlockMemory(mem) SCIP_UNUSED(mem)
501 #define BMSgetBlockMemoryAllocated(mem) (SCIP_UNUSED(mem), 0LL)
502 #define BMSgetBlockMemoryUsed(mem) (SCIP_UNUSED(mem), 0LL)
503 #define BMSgetBlockMemoryUnused(mem) (SCIP_UNUSED(mem), 0LL)
504 #define BMSgetBlockMemoryUsedMax(mem) (SCIP_UNUSED(mem), 0LL)
505 #define BMSgetBlockMemoryUnusedMax(mem) (SCIP_UNUSED(mem), 0LL)
506 #define BMSgetBlockMemoryAllocatedMax(mem) (SCIP_UNUSED(mem), 0LL)
507 #define BMSgetBlockPointerSize(mem,ptr) (SCIP_UNUSED(mem), SCIP_UNUSED(ptr), 0)
508 #define BMSdisplayBlockMemory(mem) SCIP_UNUSED(mem)
509 #define BMSblockMemoryCheckEmpty(mem) (SCIP_UNUSED(mem), 0LL)
510 
511 #endif
512 
513 
514 /** creates a block memory allocation data structure */
515 SCIP_EXPORT
517  int initchunksize, /**< number of elements in the first chunk of each chunk block */
518  int garbagefactor, /**< garbage collector is called, if at least garbagefactor * avg. chunksize
519  * elements are free (-1: disable garbage collection) */
520  const char* filename, /**< source file of the function call */
521  int line /**< line number in source file of the function call */
522  );
523 
524 /** frees all chunk blocks in the block memory */
525 SCIP_EXPORT
527  BMS_BLKMEM* blkmem, /**< block memory */
528  const char* filename, /**< source file of the function call */
529  int line /**< line number in source file of the function call */
530  );
531 
532 /** clears and deletes block memory */
533 SCIP_EXPORT
535  BMS_BLKMEM** blkmem, /**< pointer to block memory */
536  const char* filename, /**< source file of the function call */
537  int line /**< line number in source file of the function call */
538  );
539 
540 /** allocates memory in the block memory pool */
541 SCIP_EXPORT
543  BMS_BLKMEM* blkmem, /**< block memory */
544  size_t size, /**< size of memory element to allocate */
545  const char* filename, /**< source file of the function call */
546  int line /**< line number in source file of the function call */
547  );
548 
549 /** allocates memory in the block memory pool and clears it */
550 SCIP_EXPORT
552  BMS_BLKMEM* blkmem, /**< block memory */
553  size_t size, /**< size of memory element to allocate */
554  const char* filename, /**< source file of the function call */
555  int line /**< line number in source file of the function call */
556  );
557 
558 /** allocates array in the block memory pool */
559 SCIP_EXPORT
561  BMS_BLKMEM* blkmem, /**< block memory */
562  size_t num, /**< size of array to be allocated */
563  size_t typesize, /**< size of each component */
564  const char* filename, /**< source file of the function call */
565  int line /**< line number in source file of the function call */
566  );
567 
568 /** allocates array in the block memory pool and clears it */
569 SCIP_EXPORT
571  BMS_BLKMEM* blkmem, /**< block memory */
572  size_t num, /**< size of array to be allocated */
573  size_t typesize, /**< size of each component */
574  const char* filename, /**< source file of the function call */
575  int line /**< line number in source file of the function call */
576  );
577 
578 /** resizes memory element in the block memory pool and copies the data */
579 SCIP_EXPORT
581  BMS_BLKMEM* blkmem, /**< block memory */
582  void* ptr, /**< memory element to reallocated */
583  size_t oldsize, /**< old size of memory element */
584  size_t newsize, /**< new size of memory element */
585  const char* filename, /**< source file of the function call */
586  int line /**< line number in source file of the function call */
587  );
588 
589 /** resizes array in the block memory pool and copies the data */
590 SCIP_EXPORT
592  BMS_BLKMEM* blkmem, /**< block memory */
593  void* ptr, /**< memory element to reallocated */
594  size_t oldnum, /**< old size of array */
595  size_t newnum, /**< new size of array */
596  size_t typesize, /**< size of each component */
597  const char* filename, /**< source file of the function call */
598  int line /**< line number in source file of the function call */
599  );
600 
601 /** duplicates memory element in the block memory pool and copies the data */
602 SCIP_EXPORT
604  BMS_BLKMEM* blkmem, /**< block memory */
605  const void* source, /**< memory element to duplicate */
606  size_t size, /**< size of memory elements */
607  const char* filename, /**< source file of the function call */
608  int line /**< line number in source file of the function call */
609  );
610 
611 /** duplicates array in the block memory pool and copies the data */
612 SCIP_EXPORT
614  BMS_BLKMEM* blkmem, /**< block memory */
615  const void* source, /**< memory element to duplicate */
616  size_t num, /**< size of array to be duplicated */
617  size_t typesize, /**< size of each component */
618  const char* filename, /**< source file of the function call */
619  int line /**< line number in source file of the function call */
620  );
621 
622 /** frees memory element in the block memory pool and sets pointer to NULL */
623 SCIP_EXPORT
625  BMS_BLKMEM* blkmem, /**< block memory */
626  void** ptr, /**< pointer to pointer to memory element to free */
627  size_t size, /**< size of memory element */
628  const char* filename, /**< source file of the function call */
629  int line /**< line number in source file of the function call */
630  );
631 
632 /** frees memory element in the block memory pool if pointer is not NULL and sets pointer to NULL */
633 SCIP_EXPORT
635  BMS_BLKMEM* blkmem, /**< block memory */
636  void** ptr, /**< pointer to pointer to memory element to free */
637  size_t size, /**< size of memory element */
638  const char* filename, /**< source file of the function call */
639  int line /**< line number in source file of the function call */
640  );
641 
642 /** calls garbage collection of block memory, frees chunks without allocated memory elements, and frees
643  * chunk blocks without any chunks
644  */
645 SCIP_EXPORT
647  BMS_BLKMEM* blkmem /**< block memory */
648  );
649 
650 /** returns the number of allocated bytes in the block memory */
651 SCIP_EXPORT
653  const BMS_BLKMEM* blkmem /**< block memory */
654  );
655 
656 /** returns the number of used bytes in the block memory */
657 SCIP_EXPORT
659  const BMS_BLKMEM* blkmem /**< block memory */
660  );
661 
662 /** returns the number of allocated but not used bytes in the block memory */
663 SCIP_EXPORT
665  const BMS_BLKMEM* blkmem /**< block memory */
666  );
667 
668 /** returns the maximal number of used bytes in the block memory */
669 SCIP_EXPORT
671  const BMS_BLKMEM* blkmem /**< block memory */
672  );
673 
674 /** returns the maximal number of allocated but not used bytes in the block memory */
675 SCIP_EXPORT
677  const BMS_BLKMEM* blkmem /**< block memory */
678  );
679 
680 /** returns the maximal number of allocated bytes in the block memory */
682  const BMS_BLKMEM* blkmem /**< block memory */
683  );
684 
685 /** returns the size of the given memory element; returns 0, if the element is not member of the block memory */
686 SCIP_EXPORT
688  const BMS_BLKMEM* blkmem, /**< block memory */
689  const void* ptr /**< memory element */
690  );
691 
692 /** outputs allocation diagnostics of block memory */
693 SCIP_EXPORT
695  const BMS_BLKMEM* blkmem /**< block memory */
696  );
697 
698 /** outputs error messages, if there are allocated elements in the block memory and returns number of unfreed bytes */
699 SCIP_EXPORT
701  const BMS_BLKMEM* blkmem /**< block memory */
702  );
703 
704 
705 
706 
707 
708 /***********************************************************
709  * Buffer Memory Management
710  *
711  * Efficient memory management for temporary objects
712  ***********************************************************/
713 
714 typedef struct BMS_BufMem BMS_BUFMEM; /**< buffer memory for temporary objects */
715 
716 /* Note: values that are passed as a size_t parameter are first converted to ptrdiff_t to be sure that negative numbers
717  * are extended to the larger size. Then they are converted to size_t. Thus, negative numbers are converted to very
718  * large size_t values. This is then checked within the functions. */
719 
720 #define BMSallocBufferMemory(mem,ptr) ASSIGN((ptr), BMSallocBufferMemory_call((mem), sizeof(**(ptr)), __FILE__, __LINE__))
721 #define BMSallocBufferMemorySize(mem,ptr,size) ASSIGN((ptr), BMSallocBufferMemory_call((mem), (size_t)(ptrdiff_t)(size), __FILE__, __LINE__))
722 #define BMSreallocBufferMemorySize(mem,ptr,size) \
723  ASSIGN((ptr), BMSreallocBufferMemory_call((mem), (void*)(*(ptr)), (size_t)(ptrdiff_t)(size), __FILE__, __LINE__))
724 #define BMSallocBufferMemoryArray(mem,ptr,num) ASSIGN((ptr), BMSallocBufferMemoryArray_call((mem), (size_t)(ptrdiff_t)(num), sizeof(**(ptr)), __FILE__, __LINE__))
725 #define BMSallocClearBufferMemoryArray(mem,ptr,num) ASSIGN((ptr), BMSallocClearBufferMemoryArray_call((mem), (size_t)(ptrdiff_t)(num), sizeof(**(ptr)), __FILE__, __LINE__))
726 #define BMSreallocBufferMemoryArray(mem,ptr,num) ASSIGN((ptr), BMSreallocBufferMemoryArray_call((mem), (void*)(*(ptr)), (size_t)(ptrdiff_t)(num), \
727  sizeof(**(ptr)), __FILE__, __LINE__))
728 #define BMSduplicateBufferMemory(mem,ptr,source,size) \
729  ASSIGN((ptr), BMSduplicateBufferMemory_call((mem), (const void*)(source), (size_t)(ptrdiff_t)(size), __FILE__, __LINE__))
730 #define BMSduplicateBufferMemoryArray(mem,ptr,source,num) ASSIGNCHECK((ptr), BMSduplicateBufferMemoryArray_call((mem), \
731  (const void*)(source), (size_t)(ptrdiff_t)(num), sizeof(**(ptr)), __FILE__, __LINE__), source)
732 
733 #define BMSfreeBufferMemory(mem,ptr) BMSfreeBufferMemory_call((mem), (void**)(ptr), __FILE__, __LINE__)
734 #define BMSfreeBufferMemoryNull(mem,ptr) BMSfreeBufferMemoryNull_call((mem), (void**)(ptr), __FILE__, __LINE__)
735 #define BMSfreeBufferMemoryArray(mem,ptr) BMSfreeBufferMemory_call((mem), (void**)(ptr), __FILE__, __LINE__)
736 #define BMSfreeBufferMemoryArrayNull(mem,ptr) BMSfreeBufferMemoryNull_call((mem), (void**)(ptr), __FILE__, __LINE__)
737 #define BMSfreeBufferMemorySize(mem,ptr) BMSfreeBufferMemory_call((mem), (void**)(ptr), __FILE__, __LINE__);
738 #define BMSfreeBufferMemorySizeNull(mem,ptr) BMSfreeBufferMemoryNull_call((mem), (void**)(ptr), __FILE__, __LINE__)
739 
740 #define BMScreateBufferMemory(fac,init,clean) BMScreateBufferMemory_call((fac), (init), (clean), __FILE__, __LINE__)
741 #define BMSdestroyBufferMemory(mem) BMSdestroyBufferMemory_call((mem), __FILE__, __LINE__)
742 
743 
744 /** creates memory buffer storage */
745 SCIP_EXPORT
747  double arraygrowfac, /**< memory growing factor for dynamically allocated arrays */
748  int arraygrowinit, /**< initial size of dynamically allocated arrays */
749  unsigned int clean, /**< should the memory blocks in the buffer be initialized to zero? */
750  const char* filename, /**< source file of the function call */
751  int line /**< line number in source file of the function call */
752  );
753 
754 /** destroys buffer memory */
755 SCIP_EXPORT
757  BMS_BUFMEM** buffer, /**< pointer to memory buffer storage */
758  const char* filename, /**< source file of the function call */
759  int line /**< line number in source file of the function call */
760  );
761 
762 /** set arraygrowfac */
763 SCIP_EXPORT
765  BMS_BUFMEM* buffer, /**< pointer to memory buffer storage */
766  double arraygrowfac /**< memory growing factor for dynamically allocated arrays */
767  );
768 
769 /** set arraygrowinit */
770 SCIP_EXPORT
772  BMS_BUFMEM* buffer, /**< pointer to memory buffer storage */
773  int arraygrowinit /**< initial size of dynamically allocated arrays */
774  );
775 
776 /** allocates the next unused buffer */
777 SCIP_EXPORT
779  BMS_BUFMEM* buffer, /**< memory buffer storage */
780  size_t size, /**< minimal required size of the buffer */
781  const char* filename, /**< source file of the function call */
782  int line /**< line number in source file of the function call */
783  );
784 
785 /** allocates the next unused buffer array */
786 SCIP_EXPORT
788  BMS_BUFMEM* buffer, /**< memory buffer storage */
789  size_t num, /**< size of array to be allocated */
790  size_t typesize, /**< size of components */
791  const char* filename, /**< source file of the function call */
792  int line /**< line number in source file of the function call */
793  );
794 
795 /** allocates the next unused buffer and clears it */
796 SCIP_EXPORT
798  BMS_BUFMEM* buffer, /**< memory buffer storage */
799  size_t num, /**< size of array to be allocated */
800  size_t typesize, /**< size of components */
801  const char* filename, /**< source file of the function call */
802  int line /**< line number in source file of the function call */
803  );
804 
805 /** reallocates the buffer to at least the given size */
806 SCIP_EXPORT
808  BMS_BUFMEM* buffer, /**< memory buffer storage */
809  void* ptr, /**< pointer to the allocated memory buffer */
810  size_t size, /**< minimal required size of the buffer */
811  const char* filename, /**< source file of the function call */
812  int line /**< line number in source file of the function call */
813  );
814 
815 /** reallocates an array in the buffer to at least the given size */
816 SCIP_EXPORT
818  BMS_BUFMEM* buffer, /**< memory buffer storage */
819  void* ptr, /**< pointer to the allocated memory buffer */
820  size_t num, /**< size of array to be allocated */
821  size_t typesize, /**< size of components */
822  const char* filename, /**< source file of the function call */
823  int line /**< line number in source file of the function call */
824  );
825 
826 /** allocates the next unused buffer and copies the given memory into the buffer */
827 SCIP_EXPORT
829  BMS_BUFMEM* buffer, /**< memory buffer storage */
830  const void* source, /**< memory block to copy into the buffer */
831  size_t size, /**< minimal required size of the buffer */
832  const char* filename, /**< source file of the function call */
833  int line /**< line number in source file of the function call */
834  );
835 
836 /** allocates an array in the next unused buffer and copies the given memory into the buffer */
837 SCIP_EXPORT
839  BMS_BUFMEM* buffer, /**< memory buffer storage */
840  const void* source, /**< memory block to copy into the buffer */
841  size_t num, /**< size of array to be allocated */
842  size_t typesize, /**< size of components */
843  const char* filename, /**< source file of the function call */
844  int line /**< line number in source file of the function call */
845  );
846 
847 /** frees a buffer and sets pointer to NULL */
848 SCIP_EXPORT
850  BMS_BUFMEM* buffer, /**< memory buffer storage */
851  void** ptr, /**< pointer to pointer to the allocated memory buffer */
852  const char* filename, /**< source file of the function call */
853  int line /**< line number in source file of the function call */
854  );
855 
856 /** frees a buffer if pointer is not NULL and sets pointer to NULL */
857 SCIP_EXPORT
859  BMS_BUFMEM* buffer, /**< memory buffer storage */
860  void** ptr, /**< pointer to pointer to the allocated memory buffer */
861  const char* filename, /**< source file of the function call */
862  int line /**< line number in source file of the function call */
863  );
864 
865 /** gets number of used buffers */
866 SCIP_EXPORT
868  BMS_BUFMEM* buffer /**< memory buffer storage */
869  );
870 
871 /** returns the number of allocated bytes in the buffer memory */
872 SCIP_EXPORT
873 long long BMSgetBufferMemoryUsed(
874  const BMS_BUFMEM* bufmem /**< buffer memory */
875  );
876 
877 /** outputs statistics about currently allocated buffers to the screen */
878 SCIP_EXPORT
880  BMS_BUFMEM* buffer /**< memory buffer storage */
881  );
882 
883 
884 #ifdef __cplusplus
885 }
886 #endif
887 
888 #endif
void * BMSreallocBufferMemory_call(BMS_BUFMEM *buffer, void *ptr, size_t size, const char *filename, int line)
Definition: memory.c:2908
void BMSfreeBufferMemoryNull_call(BMS_BUFMEM *buffer, void **ptr, const char *filename, int line)
Definition: memory.c:3093
void BMSdestroyChunkMemory_call(BMS_CHKMEM **chkmem, const char *filename, int line)
Definition: memory.c:1498
void * BMSallocBlockMemory_call(BMS_BLKMEM *blkmem, size_t size, const char *filename, int line)
Definition: memory.c:1882
struct BMS_ChkMem BMS_CHKMEM
Definition: memory.h:295
BMS_CHKMEM * BMScreateChunkMemory_call(size_t size, int initchunksize, int garbagefactor, const char *filename, int line)
Definition: memory.c:1456
void BMSfreeMemoryNull_call(void **ptr, const char *filename, int line)
Definition: memory.c:635
void * BMSallocChunkMemory_call(BMS_CHKMEM *chkmem, size_t size, const char *filename, int line)
Definition: memory.c:1518
void * BMSallocBlockMemoryArray_call(BMS_BLKMEM *blkmem, size_t num, size_t typesize, const char *filename, int line)
Definition: memory.c:1919
void * BMSallocClearBlockMemoryArray_call(BMS_BLKMEM *blkmem, size_t num, size_t typesize, const char *filename, int line)
Definition: memory.c:1940
void BMSclearBlockMemory_call(BMS_BLKMEM *blkmem, const char *filename, int line)
Definition: memory.c:1762
double arraygrowfac
Definition: memory.c:2496
void * BMSallocBufferMemoryArray_call(BMS_BUFMEM *buffer, size_t num, size_t typesize, const char *filename, int line)
Definition: memory.c:2796
size_t * size
Definition: memory.c:2490
int BMSisAligned(size_t size)
Definition: memory.c:770
void BMSdestroyBlockMemory_call(BMS_BLKMEM **blkmem, const char *filename, int line)
Definition: memory.c:1796
long long BMScheckEmptyBlockMemory_call(const BMS_BLKMEM *blkmem)
Definition: memory.c:2408
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:1998
size_t BMSgetBlockPointerSize_call(const BMS_BLKMEM *blkmem, const void *ptr)
Definition: memory.c:2264
void * BMSduplicateChunkMemory_call(BMS_CHKMEM *chkmem, const void *source, size_t size, const char *filename, int line)
Definition: memory.c:1545
void BMSfreeChunkMemory_call(BMS_CHKMEM *chkmem, void **ptr, size_t size, const char *filename, int line)
Definition: memory.c:1567
void * BMSallocClearBlockMemory_call(BMS_BLKMEM *blkmem, size_t size, const char *filename, int line)
Definition: memory.c:1902
long long BMSgetBlockMemoryUsedMax_call(const BMS_BLKMEM *blkmem)
Definition: memory.c:2234
long long BMSgetBlockMemoryAllocated_call(const BMS_BLKMEM *blkmem)
Definition: memory.c:2204
void * BMSallocBufferMemory_call(BMS_BUFMEM *buffer, size_t size, const char *filename, int line)
Definition: memory.c:2776
void BMSsetBufferMemoryArraygrowinit(BMS_BUFMEM *buffer, int arraygrowinit)
Definition: memory.c:2583
void * BMSallocClearBufferMemoryArray_call(BMS_BUFMEM *buffer, size_t num, size_t typesize, const char *filename, int line)
Definition: memory.c:2817
void * BMSduplicateMemory_call(const void *source, size_t size, const char *filename, int line)
Definition: memory.c:574
void * BMSreallocBlockMemory_call(BMS_BLKMEM *blkmem, void *ptr, size_t oldsize, size_t newsize, const char *filename, int line)
Definition: memory.c:1958
void * BMSreallocMemoryArray_call(void *ptr, size_t num, size_t typesize, const char *filename, int line)
Definition: memory.c:490
void * BMSallocMemoryArray_call(size_t num, size_t typesize, const char *filename, int line)
Definition: memory.c:416
void BMSdestroyBufferMemory_call(BMS_BUFMEM **buffer, const char *filename, int line)
Definition: memory.c:2538
void BMSdisplayMemory_call(void)
Definition: memory.c:318
BMS_BLKMEM * BMScreateBlockMemory_call(int initchunksize, int garbagefactor, const char *filename, int line)
Definition: memory.c:1728
void BMSclearMemory_call(void *ptr, size_t size)
Definition: memory.c:529
void BMSfreeBufferMemory_call(BMS_BUFMEM *buffer, void **ptr, const char *filename, int line)
Definition: memory.c:3070
void * BMSduplicateBlockMemory_call(BMS_BLKMEM *blkmem, const void *source, size_t size, const char *filename, int line)
Definition: memory.c:2037
void BMScheckEmptyMemory_call(void)
Definition: memory.c:326
void BMSgarbagecollectChunkMemory_call(BMS_CHKMEM *chkmem)
Definition: memory.c:1620
void * BMSreallocMemory_call(void *ptr, size_t size, const char *filename, int line)
Definition: memory.c:454
long long BMSgetBlockMemoryUsed_call(const BMS_BLKMEM *blkmem)
Definition: memory.c:2214
long long BMSgetBlockMemoryAllocatedMax_call(const BMS_BLKMEM *blkmem)
Definition: memory.c:2254
void * BMSduplicateBlockMemoryArray_call(BMS_BLKMEM *blkmem, const void *source, size_t num, size_t typesize, const char *filename, int line)
Definition: memory.c:2057
void BMSfreeBlockMemoryNull_call(BMS_BLKMEM *blkmem, void **ptr, size_t size, const char *filename, int line)
Definition: memory.c:2149
long long BMSgetChunkMemoryUsed_call(const BMS_CHKMEM *chkmem)
Definition: memory.c:1630
void BMSgarbagecollectBlockMemory_call(BMS_BLKMEM *blkmem)
Definition: memory.c:2170
void BMSprintBufferMemory(BMS_BUFMEM *buffer)
Definition: memory.c:3141
void * BMSallocMemory_call(size_t size, const char *filename, int line)
Definition: memory.c:382
unsigned int arraygrowinit
Definition: memory.c:2497
void BMSfreeMemory_call(void **ptr, const char *filename, int line)
Definition: memory.c:613
BMS_BUFMEM * BMScreateBufferMemory_call(double arraygrowfac, int arraygrowinit, unsigned int clean, const char *filename, int line)
Definition: memory.c:2502
void * BMSallocClearMemory_call(size_t num, size_t typesize, const char *filename, int line)
Definition: memory.c:343
long long BMSgetBlockMemoryUnusedMax_call(const BMS_BLKMEM *blkmem)
Definition: memory.c:2244
void BMSsetBufferMemoryArraygrowfac(BMS_BUFMEM *buffer, double arraygrowfac)
Definition: memory.c:2571
void * BMSduplicateBufferMemory_call(BMS_BUFMEM *buffer, const void *source, size_t size, const char *filename, int line)
Definition: memory.c:2951
void BMSmoveMemory_call(void *ptr, const void *source, size_t size)
Definition: memory.c:559
void * BMSreallocBufferMemoryArray_call(BMS_BUFMEM *buffer, void *ptr, size_t num, size_t typesize, const char *filename, int line)
Definition: memory.c:2929
void BMSfreeChunkMemoryNull_call(BMS_CHKMEM *chkmem, void **ptr, size_t size, const char *filename, int line)
Definition: memory.c:1596
long long BMSgetBlockMemoryUnused_call(const BMS_BLKMEM *blkmem)
Definition: memory.c:2224
size_t BMSgetNUsedBufferMemory(BMS_BUFMEM *buffer)
Definition: memory.c:3113
void BMSalignMemsize(size_t *size)
Definition: memory.c:761
void BMScopyMemory_call(void *ptr, const void *source, size_t size)
Definition: memory.c:542
void BMSfreeBlockMemory_call(BMS_BLKMEM *blkmem, void **ptr, size_t size, const char *filename, int line)
Definition: memory.c:2127
void BMSdisplayBlockMemory_call(const BMS_BLKMEM *blkmem)
Definition: memory.c:2284
void BMSclearChunkMemory_call(BMS_CHKMEM *chkmem, const char *filename, int line)
Definition: memory.c:1480
size_t BMSgetPointerSize_call(const void *ptr)
Definition: memory.c:309
struct BMS_BlkMem BMS_BLKMEM
Definition: memory.h:430
unsigned int clean
Definition: memory.c:2493
long long BMSgetMemoryUsed_call(void)
Definition: memory.c:333
void * BMSduplicateMemoryArray_call(const void *source, size_t num, size_t typesize, const char *filename, int line)
Definition: memory.c:593
long long BMSgetBufferMemoryUsed(const BMS_BUFMEM *bufmem)
Definition: memory.c:3123
void * BMSduplicateBufferMemoryArray_call(BMS_BUFMEM *buffer, const void *source, size_t num, size_t typesize, const char *filename, int line)
Definition: memory.c:2974