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 2002-2022 Zuse Institute Berlin */
7 /* */
8 /* Licensed under the Apache License, Version 2.0 (the "License"); */
9 /* you may not use this file except in compliance with the License. */
10 /* You may obtain a copy of the License at */
11 /* */
12 /* http://www.apache.org/licenses/LICENSE-2.0 */
13 /* */
14 /* Unless required by applicable law or agreed to in writing, software */
15 /* distributed under the License is distributed on an "AS IS" BASIS, */
16 /* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
17 /* See the License for the specific language governing permissions and */
18 /* limitations under the License. */
19 /* */
20 /* You should have received a copy of the Apache-2.0 license */
21 /* along with SCIP; see the file LICENSE. If not visit scipopt.org. */
22 /* */
23 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
24 
25 /**@file memory.h
26  * @brief memory allocation routines
27  * @author Tobias Achterberg
28  * @author Gerald Gamrath
29  * @author Marc Pfetsch
30  */
31 
32 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
33 
34 #ifndef __BMS_MEMORY_H__
35 #define __BMS_MEMORY_H__
36 
37 #include <limits.h>
38 #include <stdlib.h>
39 #include <stddef.h>
40 
41 /*
42  * include build configuration flags
43  */
44 #ifndef NO_CONFIG_HEADER
45 #include "scip/config.h"
46 #include "scip/scip_export.h"
47 #endif
48 
49 #ifdef __cplusplus
50 
51 
52 /* special thanks to Daniel Junglas for following template and macros */
53 
54 template<typename T> T* docast(T*, void *v);
55 template<typename T> T* docast(T*, void *v) { return reinterpret_cast<T*>(v); }
56 
57 /* For C++11, we can easily check whether the types for memory functions like BMSduplicateXYZArray() are equal. */
58 #if __cplusplus > 199711L
59 #include <type_traits>
60 
61 /* the following adds a type check for the parameters, used in ASSIGNCHECK below */
62 template<typename T1, typename T2> T1* docastcheck(T1* v1, void* v, T2* v2)
63 {
64  typedef typename std::remove_const<T1>::type t1;
65  typedef typename std::remove_const<T2>::type t2;
66  static_assert(std::is_same<t1, t2>::value, "need equal types");
67  return reinterpret_cast<T1*>(v);
68 }
69 #else
70 /* for older compilers do nothing */
71 template<typename T1, typename T2> T1* docastcheck(T1* v1, void* v, T2* v2) { return reinterpret_cast<T1*>(v); }
72 #endif
73 
74 
75 extern "C" {
76 
77 #define ASSIGN(pointerstarstar, voidstarfunction) (*(pointerstarstar) = docast(*(pointerstarstar), (voidstarfunction)))
78 #define ASSIGNCHECK(pointerstarstar, voidstarfunction, origpointer) (*(pointerstarstar) = docastcheck(*(pointerstarstar), (voidstarfunction), (origpointer)))
79 
80 #else
81 
82 #define ASSIGN(pointerstarstar, voidstarfunction) (*(pointerstarstar) = (voidstarfunction))
83 #define ASSIGNCHECK(pointerstarstar, voidstarfunction, origpointer) (*(pointerstarstar) = (voidstarfunction))
84 
85 #endif
86 
87 /*
88  * Define the macro SCIP_EXPORT depending if the OS is Windows or not
89  */
90 #ifndef SCIP_EXPORT
91 
92 #if defined(_WIN32) || defined(_WIN64)
93 #define SCIP_EXPORT __declspec(dllexport)
94 #elif defined(__GNUC__) && __GNUC__ >= 4
95 #define SCIP_EXPORT __attribute__((__visibility__("default")))
96 #else
97 #define SCIP_EXPORT
98 #endif
99 
100 #endif
101 
102 /* define if not already existing to make file independent from def.h */
103 #ifndef SCIP_UNUSED
104 #define SCIP_UNUSED(x) ((void) (x))
105 #endif
106 
107 
108 /*************************************************************************************
109  * Standard Memory Management
110  *
111  * In debug mode, these methods extend malloc() and free() by logging all currently
112  * allocated memory elements in an allocation list. This can be used as a simple leak
113  * detection.
114  *************************************************************************************/
115 
116 /* Note: values that are passed as a size_t parameter are first converted to ptrdiff_t to be sure that negative numbers
117  * are extended to the larger size. Then they are converted to size_t. Thus, negative numbers are converted to very
118  * large size_t values. This is then checked within the functions. */
119 
120 #define BMSallocMemory(ptr) ASSIGN((ptr), BMSallocMemory_call( sizeof(**(ptr)), __FILE__, __LINE__ ))
121 #define BMSallocClearMemory(ptr) ASSIGN((ptr), BMSallocClearMemory_call((size_t)(1), sizeof(**(ptr)), __FILE__, __LINE__ ))
122 #define BMSallocMemorySize(ptr,size) ASSIGN((ptr), BMSallocMemory_call( (size_t)(ptrdiff_t)(size), __FILE__, __LINE__ ))
123 #define BMSallocMemoryCPP(size) BMSallocMemory_call( (size_t)(ptrdiff_t)(size), __FILE__, __LINE__ )
124 #define BMSallocClearMemorySize(ptr,size) ASSIGN((ptr), BMSallocClearMemory_call((size_t)(1), (size_t)(ptrdiff_t)(size), __FILE__, __LINE__ ))
125 #define BMSallocMemoryArray(ptr,num) ASSIGN((ptr), BMSallocMemoryArray_call((size_t)(ptrdiff_t)(num), sizeof(**(ptr)), __FILE__, __LINE__ ))
126 #define BMSallocMemoryArrayCPP(num,size) BMSallocMemoryArray_call( (size_t)(ptrdiff_t)(num), (size_t)(ptrdiff_t)(size), __FILE__, __LINE__ )
127 #define BMSallocClearMemoryArray(ptr,num) ASSIGN((ptr), BMSallocClearMemory_call((size_t)(ptrdiff_t)(num), sizeof(**(ptr)), __FILE__, __LINE__ ))
128 #define BMSreallocMemorySize(ptr,size) ASSIGN((ptr), BMSreallocMemory_call((void*)(*(ptr)), (size_t)(ptrdiff_t)(size), __FILE__, __LINE__ ))
129 #define BMSreallocMemoryArray(ptr,num) ASSIGN((ptr), BMSreallocMemoryArray_call( *(ptr), (size_t)(ptrdiff_t)(num), sizeof(**(ptr)), __FILE__, __LINE__ ))
130 
131 #define BMSclearMemory(ptr) BMSclearMemory_call( (void*)(ptr), sizeof(*(ptr)) )
132 #define BMSclearMemoryArray(ptr, num) BMSclearMemory_call( (void*)(ptr), (size_t)(ptrdiff_t)(num)*sizeof(*(ptr)) )
133 #define BMSclearMemorySize(ptr, size) BMSclearMemory_call( (void*)(ptr), (size_t)(ptrdiff_t)(size) )
134 
135 #define BMScopyMemory(ptr, source) BMScopyMemory_call( (void*)(ptr), (const void*)(source), sizeof(*(ptr)) )
136 #define BMScopyMemoryArray(ptr, source, num) BMScopyMemory_call( (void*)(ptr), (const void*)(source), (size_t)(ptrdiff_t)(num)*sizeof(*(ptr)) )
137 #define BMScopyMemorySize(ptr, source, size) BMScopyMemory_call( (void*)(ptr), (const void*)(source), (size_t)(ptrdiff_t)(size) )
138 
139 #define BMSmoveMemory(ptr, source) BMSmoveMemory_call( (void*)(ptr), (const void*)(source), sizeof(*(ptr)) )
140 #define BMSmoveMemoryArray(ptr, source, num) BMSmoveMemory_call( (void*)(ptr), (const void*)(source), (size_t)(ptrdiff_t)(num) * sizeof(*(ptr)) )
141 #define BMSmoveMemorySize(ptr, source, size) BMSmoveMemory_call( (void*)(ptr), (const void*)(source), (size_t)(ptrdiff_t)(size) )
142 
143 #define BMSduplicateMemory(ptr, source) ASSIGN((ptr), BMSduplicateMemory_call( (const void*)(source), sizeof(**(ptr)), __FILE__, __LINE__ ))
144 #define BMSduplicateMemorySize(ptr, source, size) ASSIGN((ptr), BMSduplicateMemory_call( (const void*)(source), (size_t)(ptrdiff_t)(size), __FILE__, __LINE__ ))
145 #define BMSduplicateMemoryArray(ptr, source, num) ASSIGNCHECK((ptr), BMSduplicateMemoryArray_call( (const void*)(source), (size_t)(ptrdiff_t)(num), \
146  sizeof(**(ptr)), __FILE__, __LINE__ ), source)
147 #define BMSfreeMemory(ptr) BMSfreeMemory_call( (void**)(ptr), __FILE__, __LINE__ )
148 #define BMSfreeMemoryNull(ptr) BMSfreeMemoryNull_call( (void**)(ptr), __FILE__, __LINE__ )
149 #define BMSfreeMemoryArray(ptr) BMSfreeMemory_call( (void**)(ptr), __FILE__, __LINE__ )
150 #define BMSfreeMemoryArrayNull(ptr) BMSfreeMemoryNull_call( (void**)(ptr), __FILE__, __LINE__ )
151 #define BMSfreeMemorySize(ptr) BMSfreeMemory_call( (void**)(ptr), __FILE__, __LINE__ )
152 #define BMSfreeMemorySizeNull(ptr) BMSfreeMemoryNull_call( (void**)(ptr), __FILE__, __LINE__ )
153 
154 #ifndef NDEBUG
155 #define BMSgetPointerSize(ptr) BMSgetPointerSize_call(ptr)
156 #define BMSdisplayMemory() BMSdisplayMemory_call()
157 #define BMScheckEmptyMemory() BMScheckEmptyMemory_call()
158 #define BMSgetMemoryUsed() BMSgetMemoryUsed_call()
159 #else
160 #define BMSgetPointerSize(ptr) 0
161 #define BMSdisplayMemory() /**/
162 #define BMScheckEmptyMemory() /**/
163 #define BMSgetMemoryUsed() 0LL
164 #endif
165 
166 /** allocates array and initializes it with 0; returns NULL if memory allocation failed */
167 SCIP_EXPORT
169  size_t num, /**< number of memory element to allocate */
170  size_t typesize, /**< size of memory element to allocate */
171  const char* filename, /**< source file where the allocation is performed */
172  int line /**< line number in source file where the allocation is performed */
173  );
174 
175 /** allocates memory; returns NULL if memory allocation failed */
176 SCIP_EXPORT
177 void* BMSallocMemory_call(
178  size_t size, /**< size of memory element to allocate */
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 array; returns NULL if memory allocation failed */
184 SCIP_EXPORT
186  size_t num, /**< number of components of array to allocate */
187  size_t typesize, /**< size of each component */
188  const char* filename, /**< source file where the allocation is performed */
189  int line /**< line number in source file where the allocation is performed */
190  );
191 
192 /** allocates memory; returns NULL if memory allocation failed */
193 SCIP_EXPORT
195  void* ptr, /**< pointer to memory to reallocate */
196  size_t size, /**< new size of memory element */
197  const char* filename, /**< source file where the reallocation is performed */
198  int line /**< line number in source file where the reallocation is performed */
199  );
200 
201 /** reallocates array; returns NULL if memory allocation failed */
202 SCIP_EXPORT
204  void* ptr, /**< pointer to memory to reallocate */
205  size_t num, /**< number of components of array to allocate */
206  size_t typesize, /**< size of each component */
207  const char* filename, /**< source file where the reallocation is performed */
208  int line /**< line number in source file where the reallocation is performed */
209  );
210 
211 /** clears a memory element (i.e. fills it with zeros) */
212 SCIP_EXPORT
214  void* ptr, /**< pointer to memory element */
215  size_t size /**< size of memory element */
216  );
217 
218 /** copies the contents of one memory element into another memory element */
219 SCIP_EXPORT
220 void BMScopyMemory_call(
221  void* ptr, /**< pointer to target memory element */
222  const void* source, /**< pointer to source memory element */
223  size_t size /**< size of memory element to copy */
224  );
225 
226 /** moves the contents of one memory element into another memory element, should be used if both elements overlap,
227  * otherwise BMScopyMemory is faster
228  */
229 SCIP_EXPORT
230 void BMSmoveMemory_call(
231  void* ptr, /**< pointer to target memory element */
232  const void* source, /**< pointer to source memory element */
233  size_t size /**< size of memory element to copy */
234  );
235 
236 /** allocates memory and copies the contents of the given memory element into the new memory element */
237 SCIP_EXPORT
239  const void* source, /**< pointer to source memory element */
240  size_t size, /**< size of memory element to copy */
241  const char* filename, /**< source file where the duplication is performed */
242  int line /**< line number in source file where the duplication is performed */
243  );
244 
245 /** allocates array and copies the contents of the given source array into the new array */
246 SCIP_EXPORT
248  const void* source, /**< pointer to source memory element */
249  size_t num, /**< number of components of array to allocate */
250  size_t typesize, /**< size of each component */
251  const char* filename, /**< source file where the duplication is performed */
252  int line /**< line number in source file where the duplication is performed */
253  );
254 
255 /** frees an allocated memory element and sets pointer to NULL */
256 SCIP_EXPORT
257 void BMSfreeMemory_call(
258  void** ptr, /**< pointer to pointer to memory element */
259  const char* filename, /**< source file where the deallocation is performed */
260  int line /**< line number in source file where the deallocation is performed */
261  );
262 
263 /** frees an allocated memory element if pointer is not NULL and sets pointer to NULL */
264 SCIP_EXPORT
266  void** ptr, /**< pointer to pointer to memory element */
267  const char* filename, /**< source file where the deallocation is performed */
268  int line /**< line number in source file where the deallocation is performed */
269  );
270 
271 /** returns the size of an allocated memory element */
272 SCIP_EXPORT
274  const void* ptr /**< pointer to allocated memory */
275  );
276 
277 /** outputs information about currently allocated memory to the screen */
278 SCIP_EXPORT
280  void
281  );
282 
283 /** displays a warning message on the screen, if allocated memory exists */
284 SCIP_EXPORT
286  void
287  );
288 
289 /** returns total number of allocated bytes */
290 SCIP_EXPORT
291 long long BMSgetMemoryUsed_call(
292  void
293  );
294 
295 
296 
297 
298 /********************************************************************
299  * Chunk Memory Management
300  *
301  * Efficient memory management for multiple objects of the same size
302  ********************************************************************/
303 
304 typedef struct BMS_ChkMem BMS_CHKMEM; /**< collection of memory chunks of the same element size */
305 
306 
307 #ifndef BMS_NOBLOCKMEM
308 
309 #define BMScreateChunkMemory(sz,isz,gbf) BMScreateChunkMemory_call( (sz), (isz), (gbf), __FILE__, __LINE__ )
310 #define BMSclearChunkMemory(mem) BMSclearChunkMemory_call( (mem), __FILE__, __LINE__ )
311 #define BMSdestroyChunkMemory(mem) BMSdestroyChunkMemory_call( (mem), __FILE__, __LINE__ )
312 
313 #define BMSallocChunkMemory(mem,ptr) ASSIGN((ptr), BMSallocChunkMemory_call((mem), sizeof(**(ptr)), __FILE__, __LINE__))
314 #define BMSduplicateChunkMemory(mem, ptr, source) ASSIGN((ptr), BMSduplicateChunkMemory_call((mem), (const void*)(source), \
315  sizeof(**(ptr)), __FILE__, __LINE__ ))
316 #define BMSfreeChunkMemory(mem,ptr) BMSfreeChunkMemory_call( (mem), (void**)(ptr), sizeof(**(ptr)), __FILE__, __LINE__ )
317 #define BMSfreeChunkMemoryNull(mem,ptr) BMSfreeChunkMemoryNull_call( (mem), (void**)(ptr), sizeof(**(ptr)), __FILE__, __LINE__ )
318 #define BMSgarbagecollectChunkMemory(mem) BMSgarbagecollectChunkMemory_call(mem)
319 #define BMSgetChunkMemoryUsed(mem) BMSgetChunkMemoryUsed_call(mem)
320 
321 #else
322 
323 /* block memory management mapped to standard memory management */
324 
325 #define BMScreateChunkMemory(sz,isz,gbf) (void*)(0x01) /* dummy to not return a NULL pointer */
326 #define BMSclearChunkMemory(mem) /**/
327 #define BMSclearChunkMemoryNull(mem) /**/
328 #define BMSdestroyChunkMemory(mem) /**/
329 #define BMSdestroyChunkMemoryNull(mem) /**/
330 #define BMSallocChunkMemory(mem,ptr) BMSallocMemory(ptr)
331 #define BMSduplicateChunkMemory(mem, ptr, source) BMSduplicateMemory(ptr,source)
332 #define BMSfreeChunkMemory(mem,ptr) BMSfreeMemory(ptr)
333 #define BMSfreeChunkMemoryNull(mem,ptr) BMSfreeMemoryNull(ptr)
334 #define BMSgarbagecollectChunkMemory(mem) /**/
335 #define BMSgetChunkMemoryUsed(mem) 0LL
336 
337 #endif
338 
339 
340 /** aligns the given byte size corresponding to the minimal alignment for chunk and block memory */
341 SCIP_EXPORT
342 void BMSalignMemsize(
343  size_t* size /**< pointer to the size to align */
344  );
345 
346 /** checks whether the given size meets the alignment conditions for chunk and block memory */
347 SCIP_EXPORT
348 int BMSisAligned(
349  size_t size /**< size to check for alignment */
350  );
351 
352 /** creates a new chunk block data structure */
353 SCIP_EXPORT
355  size_t size, /**< element size of the chunk block */
356  int initchunksize, /**< number of elements in the first chunk of the chunk block */
357  int garbagefactor, /**< garbage collector is called, if at least garbagefactor * avg. chunksize
358  * elements are free (-1: disable garbage collection) */
359  const char* filename, /**< source file of the function call */
360  int line /**< line number in source file of the function call */
361  );
362 
363 /** clears a chunk block data structure */
364 SCIP_EXPORT
366  BMS_CHKMEM* chkmem, /**< chunk block */
367  const char* filename, /**< source file of the function call */
368  int line /**< line number in source file of the function call */
369  );
370 
371 /** destroys and frees a chunk block data structure */
372 SCIP_EXPORT
374  BMS_CHKMEM** chkmem, /**< pointer to chunk block */
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 /** allocates a memory element of the given chunk block */
380 SCIP_EXPORT
382  BMS_CHKMEM* chkmem, /**< chunk block */
383  size_t size, /**< size of memory element to allocate (only needed for sanity check) */
384  const char* filename, /**< source file of the function call */
385  int line /**< line number in source file of the function call */
386  );
387 
388 /** duplicates a given memory element by allocating a new element of the same chunk block and copying the data */
389 SCIP_EXPORT
391  BMS_CHKMEM* chkmem, /**< chunk block */
392  const void* source, /**< source memory element */
393  size_t size, /**< size of memory element to allocate (only needed for sanity check) */
394  const char* filename, /**< source file of the function call */
395  int line /**< line number in source file of the function call */
396  );
397 
398 /** frees a memory element of the given chunk block and sets pointer to NULL */
399 SCIP_EXPORT
401  BMS_CHKMEM* chkmem, /**< chunk block */
402  void** ptr, /**< pointer to pointer to memory element to free */
403  size_t size, /**< size of memory element to allocate (only needed for sanity check) */
404  const char* filename, /**< source file of the function call */
405  int line /**< line number in source file of the function call */
406  );
407 
408 /** frees a memory element of the given chunk block if pointer is not NULL and sets pointer to NULL */
409 SCIP_EXPORT
411  BMS_CHKMEM* chkmem, /**< chunk block */
412  void** ptr, /**< pointer to pointer to memory element to free */
413  size_t size, /**< size of memory element to allocate (only needed for sanity check) */
414  const char* filename, /**< source file of the function call */
415  int line /**< line number in source file of the function call */
416  );
417 
418 /** calls garbage collection of chunk block and frees chunks without allocated memory elements */
419 SCIP_EXPORT
421  BMS_CHKMEM* chkmem /**< chunk block */
422  );
423 
424 /** returns the number of allocated bytes in the chunk block */
425 SCIP_EXPORT
427  const BMS_CHKMEM* chkmem /**< chunk block */
428  );
429 
430 
431 
432 
433 /***********************************************************
434  * Block Memory Management
435  *
436  * Efficient memory management for objects of varying sizes
437  ***********************************************************/
438 
439 typedef struct BMS_BlkMem BMS_BLKMEM; /**< block memory: collection of chunk blocks */
440 
441 #ifndef BMS_NOBLOCKMEM
442 
443 /* block memory methods for faster memory access */
444 
445 /* Note: values that are passed as a size_t parameter are first converted to ptrdiff_t to be sure that negative numbers
446  * are extended to the larger size. Then they are converted to size_t. Thus, negative numbers are converted to very
447  * large size_t values. This is then checked within the functions. */
448 
449 #define BMScreateBlockMemory(csz,gbf) BMScreateBlockMemory_call( (csz), (gbf), __FILE__, __LINE__ )
450 #define BMSclearBlockMemory(mem) BMSclearBlockMemory_call( (mem), __FILE__, __LINE__ )
451 #define BMSdestroyBlockMemory(mem) BMSdestroyBlockMemory_call( (mem), __FILE__, __LINE__ )
452 
453 #define BMSallocBlockMemory(mem,ptr) ASSIGN((ptr), BMSallocBlockMemory_call((mem), sizeof(**(ptr)), __FILE__, __LINE__))
454 #define BMSallocClearBlockMemory(mem,ptr) ASSIGN((ptr), BMSallocClearBlockMemory_call((mem), sizeof(**(ptr)), __FILE__, __LINE__))
455 #define BMSallocBlockMemorySize(mem,ptr,size) ASSIGN((ptr), BMSallocBlockMemory_call((mem), (size_t)(ptrdiff_t)(size), __FILE__, __LINE__))
456 #define BMSallocBlockMemoryArray(mem,ptr,num) ASSIGN((ptr), BMSallocBlockMemoryArray_call((mem), (size_t)(ptrdiff_t)(num), sizeof(**(ptr)), __FILE__, __LINE__))
457 #define BMSallocClearBlockMemoryArray(mem,ptr,num) ASSIGN((ptr), BMSallocClearBlockMemoryArray_call((mem), (size_t)(ptrdiff_t)(num), sizeof(**(ptr)), __FILE__, __LINE__))
458 #define BMSreallocBlockMemorySize(mem,ptr,oldsize,newsize) ASSIGN((ptr), BMSreallocBlockMemory_call((mem), (void*)(*(ptr)), \
459  (size_t)(ptrdiff_t)(oldsize), (size_t)(ptrdiff_t)(newsize), __FILE__, __LINE__))
460 #define BMSreallocBlockMemoryArray(mem,ptr,oldnum,newnum) ASSIGN((ptr), BMSreallocBlockMemoryArray_call((mem), (void*)(*(ptr)), \
461  (size_t)(ptrdiff_t)(oldnum), (size_t)(ptrdiff_t)(newnum), sizeof(**(ptr)), __FILE__, __LINE__))
462 #define BMSduplicateBlockMemory(mem, ptr, source) ASSIGN((ptr), BMSduplicateBlockMemory_call((mem), (const void*)(source), \
463  sizeof(**(ptr)), __FILE__, __LINE__ ))
464 #define BMSduplicateBlockMemoryArray(mem, ptr, source, num) ASSIGNCHECK((ptr), BMSduplicateBlockMemoryArray_call( (mem), (const void*)(source), \
465  (size_t)(ptrdiff_t)(num), sizeof(**(ptr)), __FILE__, __LINE__ ), source)
466 
467 #define BMSfreeBlockMemory(mem,ptr) BMSfreeBlockMemory_call( (mem), (void**)(ptr), sizeof(**(ptr)), __FILE__, __LINE__ )
468 #define BMSfreeBlockMemoryNull(mem,ptr) BMSfreeBlockMemoryNull_call( (mem), (void**)(ptr), sizeof(**(ptr)), __FILE__, __LINE__ )
469 #define BMSfreeBlockMemoryArray(mem,ptr,num) BMSfreeBlockMemory_call( (mem), (void**)(ptr), (num)*sizeof(**(ptr)), __FILE__, __LINE__ )
470 #define BMSfreeBlockMemoryArrayNull(mem,ptr,num) BMSfreeBlockMemoryNull_call( (mem), (void**)(ptr), (num)*sizeof(**(ptr)), __FILE__, __LINE__ )
471 #define BMSfreeBlockMemorySize(mem,ptr,size) BMSfreeBlockMemory_call( (mem), (void**)(ptr), (size_t)(ptrdiff_t)(size), __FILE__, __LINE__ )
472 #define BMSfreeBlockMemorySizeNull(mem,ptr,size) BMSfreeBlockMemory_call( (mem), (void**)(ptr), (size_t)(ptrdiff_t)(size), __FILE__, __LINE__ )
473 
474 #define BMSgarbagecollectBlockMemory(mem) BMSgarbagecollectBlockMemory_call(mem)
475 #define BMSgetBlockMemoryAllocated(mem) BMSgetBlockMemoryAllocated_call(mem)
476 #define BMSgetBlockMemoryUsed(mem) BMSgetBlockMemoryUsed_call(mem)
477 #define BMSgetBlockMemoryUnused(mem) BMSgetBlockMemoryUnused_call(mem)
478 #define BMSgetBlockMemoryUsedMax(mem) BMSgetBlockMemoryUsedMax_call(mem)
479 #define BMSgetBlockMemoryUnusedMax(mem) BMSgetBlockMemoryUnusedMax_call(mem)
480 #define BMSgetBlockMemoryAllocatedMax(mem) BMSgetBlockMemoryAllocatedMax_call(mem)
481 #define BMSgetBlockPointerSize(mem,ptr) BMSgetBlockPointerSize_call((mem), (ptr))
482 #define BMSdisplayBlockMemory(mem) BMSdisplayBlockMemory_call(mem)
483 #define BMSblockMemoryCheckEmpty(mem) BMScheckEmptyBlockMemory_call(mem)
484 
485 #else
486 
487 /* block memory management mapped to standard memory management */
488 
489 #define BMScreateBlockMemory(csz,gbf) (SCIP_UNUSED(csz), SCIP_UNUSED(gbf), (void*)(0x01)) /* dummy to not return a NULL pointer */
490 #define BMSclearBlockMemory(mem) SCIP_UNUSED(mem)
491 #define BMSclearBlockMemoryNull(mem) SCIP_UNUSED(mem)
492 #define BMSdestroyBlockMemory(mem) SCIP_UNUSED(mem)
493 #define BMSdestroyBlockMemoryNull(mem) SCIP_UNUSED(mem)
494 #define BMSallocBlockMemory(mem,ptr) (SCIP_UNUSED(mem), BMSallocMemory(ptr))
495 #define BMSallocClearBlockMemory(mem,ptr) (SCIP_UNUSED(mem), BMSallocClearMemory(ptr))
496 #define BMSallocBlockMemoryArray(mem,ptr,num) (SCIP_UNUSED(mem), BMSallocMemoryArray(ptr,num))
497 #define BMSallocClearBlockMemoryArray(mem,ptr,num) (SCIP_UNUSED(mem), BMSallocClearMemoryArray(ptr,num))
498 #define BMSallocBlockMemorySize(mem,ptr,size) (SCIP_UNUSED(mem), BMSallocMemorySize(ptr,size))
499 #define BMSreallocBlockMemoryArray(mem,ptr,oldnum,newnum) (SCIP_UNUSED(mem), SCIP_UNUSED(oldnum), BMSreallocMemoryArray(ptr,newnum))
500 #define BMSreallocBlockMemorySize(mem,ptr,oldsize,newsize) (SCIP_UNUSED(mem), SCIP_UNUSED(oldsize), BMSreallocMemorySize(ptr,newsize))
501 #define BMSduplicateBlockMemory(mem, ptr, source) (SCIP_UNUSED(mem), BMSduplicateMemory(ptr,source))
502 #define BMSduplicateBlockMemoryArray(mem, ptr, source, num) (SCIP_UNUSED(mem), BMSduplicateMemoryArray(ptr,source,num))
503 #define BMSfreeBlockMemory(mem,ptr) (SCIP_UNUSED(mem), BMSfreeMemory(ptr))
504 #define BMSfreeBlockMemoryNull(mem,ptr) (SCIP_UNUSED(mem), BMSfreeMemoryNull(ptr))
505 #define BMSfreeBlockMemoryArray(mem,ptr,num) (SCIP_UNUSED(mem), SCIP_UNUSED(num), BMSfreeMemoryArray(ptr))
506 #define BMSfreeBlockMemoryArrayNull(mem,ptr,num) (SCIP_UNUSED(mem), SCIP_UNUSED(num), BMSfreeMemoryArrayNull(ptr))
507 #define BMSfreeBlockMemorySize(mem,ptr,size) (SCIP_UNUSED(mem), SCIP_UNUSED(size), BMSfreeMemory(ptr))
508 #define BMSfreeBlockMemorySizeNull(mem,ptr,size) (SCIP_UNUSED(mem), SCIP_UNUSED(size), BMSfreeMemoryNull(ptr))
509 #define BMSgarbagecollectBlockMemory(mem) SCIP_UNUSED(mem)
510 #define BMSgetBlockMemoryAllocated(mem) (SCIP_UNUSED(mem), 0LL)
511 #define BMSgetBlockMemoryUsed(mem) (SCIP_UNUSED(mem), 0LL)
512 #define BMSgetBlockMemoryUnused(mem) (SCIP_UNUSED(mem), 0LL)
513 #define BMSgetBlockMemoryUsedMax(mem) (SCIP_UNUSED(mem), 0LL)
514 #define BMSgetBlockMemoryUnusedMax(mem) (SCIP_UNUSED(mem), 0LL)
515 #define BMSgetBlockMemoryAllocatedMax(mem) (SCIP_UNUSED(mem), 0LL)
516 #define BMSgetBlockPointerSize(mem,ptr) (SCIP_UNUSED(mem), SCIP_UNUSED(ptr), 0)
517 #define BMSdisplayBlockMemory(mem) SCIP_UNUSED(mem)
518 #define BMSblockMemoryCheckEmpty(mem) (SCIP_UNUSED(mem), 0LL)
519 
520 #endif
521 
522 
523 /** creates a block memory allocation data structure */
524 SCIP_EXPORT
526  int initchunksize, /**< number of elements in the first chunk of each chunk block */
527  int garbagefactor, /**< garbage collector is called, if at least garbagefactor * avg. chunksize
528  * elements are free (-1: disable garbage collection) */
529  const char* filename, /**< source file of the function call */
530  int line /**< line number in source file of the function call */
531  );
532 
533 /** frees all chunk blocks in the block memory */
534 SCIP_EXPORT
536  BMS_BLKMEM* blkmem, /**< block memory */
537  const char* filename, /**< source file of the function call */
538  int line /**< line number in source file of the function call */
539  );
540 
541 /** clears and deletes block memory */
542 SCIP_EXPORT
544  BMS_BLKMEM** blkmem, /**< pointer to block memory */
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 */
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 memory in the block memory pool and clears it */
559 SCIP_EXPORT
561  BMS_BLKMEM* blkmem, /**< block memory */
562  size_t size, /**< size of memory element to allocate */
563  const char* filename, /**< source file of the function call */
564  int line /**< line number in source file of the function call */
565  );
566 
567 /** allocates array in the block memory pool */
568 SCIP_EXPORT
570  BMS_BLKMEM* blkmem, /**< block memory */
571  size_t num, /**< size of array to be allocated */
572  size_t typesize, /**< size of each component */
573  const char* filename, /**< source file of the function call */
574  int line /**< line number in source file of the function call */
575  );
576 
577 /** allocates array in the block memory pool and clears it */
578 SCIP_EXPORT
580  BMS_BLKMEM* blkmem, /**< block memory */
581  size_t num, /**< size of array to be allocated */
582  size_t typesize, /**< size of each component */
583  const char* filename, /**< source file of the function call */
584  int line /**< line number in source file of the function call */
585  );
586 
587 /** resizes memory element in the block memory pool and copies the data */
588 SCIP_EXPORT
590  BMS_BLKMEM* blkmem, /**< block memory */
591  void* ptr, /**< memory element to reallocated */
592  size_t oldsize, /**< old size of memory element */
593  size_t newsize, /**< new size of memory element */
594  const char* filename, /**< source file of the function call */
595  int line /**< line number in source file of the function call */
596  );
597 
598 /** resizes array in the block memory pool and copies the data */
599 SCIP_EXPORT
601  BMS_BLKMEM* blkmem, /**< block memory */
602  void* ptr, /**< memory element to reallocated */
603  size_t oldnum, /**< old size of array */
604  size_t newnum, /**< new size of array */
605  size_t typesize, /**< size of each component */
606  const char* filename, /**< source file of the function call */
607  int line /**< line number in source file of the function call */
608  );
609 
610 /** duplicates memory element in the block memory pool and copies the data */
611 SCIP_EXPORT
613  BMS_BLKMEM* blkmem, /**< block memory */
614  const void* source, /**< memory element to duplicate */
615  size_t size, /**< size of memory elements */
616  const char* filename, /**< source file of the function call */
617  int line /**< line number in source file of the function call */
618  );
619 
620 /** duplicates array in the block memory pool and copies the data */
621 SCIP_EXPORT
623  BMS_BLKMEM* blkmem, /**< block memory */
624  const void* source, /**< memory element to duplicate */
625  size_t num, /**< size of array to be duplicated */
626  size_t typesize, /**< size of each component */
627  const char* filename, /**< source file of the function call */
628  int line /**< line number in source file of the function call */
629  );
630 
631 /** frees memory element in the block memory pool and sets pointer to NULL */
632 SCIP_EXPORT
634  BMS_BLKMEM* blkmem, /**< block memory */
635  void** ptr, /**< pointer to pointer to memory element to free */
636  size_t size, /**< size of memory element */
637  const char* filename, /**< source file of the function call */
638  int line /**< line number in source file of the function call */
639  );
640 
641 /** frees memory element in the block memory pool if pointer is not NULL and sets pointer to NULL */
642 SCIP_EXPORT
644  BMS_BLKMEM* blkmem, /**< block memory */
645  void** ptr, /**< pointer to pointer to memory element to free */
646  size_t size, /**< size of memory element */
647  const char* filename, /**< source file of the function call */
648  int line /**< line number in source file of the function call */
649  );
650 
651 /** calls garbage collection of block memory, frees chunks without allocated memory elements, and frees
652  * chunk blocks without any chunks
653  */
654 SCIP_EXPORT
656  BMS_BLKMEM* blkmem /**< block memory */
657  );
658 
659 /** returns the number of allocated bytes in the block memory */
660 SCIP_EXPORT
662  const BMS_BLKMEM* blkmem /**< block memory */
663  );
664 
665 /** returns the number of used bytes in the block memory */
666 SCIP_EXPORT
668  const BMS_BLKMEM* blkmem /**< block memory */
669  );
670 
671 /** returns the number of allocated but not used bytes in the block memory */
672 SCIP_EXPORT
674  const BMS_BLKMEM* blkmem /**< block memory */
675  );
676 
677 /** returns the maximal number of used bytes in the block memory */
678 SCIP_EXPORT
680  const BMS_BLKMEM* blkmem /**< block memory */
681  );
682 
683 /** returns the maximal number of allocated but not used bytes in the block memory */
684 SCIP_EXPORT
686  const BMS_BLKMEM* blkmem /**< block memory */
687  );
688 
689 /** returns the maximal number of allocated bytes in the block memory */
691  const BMS_BLKMEM* blkmem /**< block memory */
692  );
693 
694 /** returns the size of the given memory element; returns 0, if the element is not member of the block memory */
695 SCIP_EXPORT
697  const BMS_BLKMEM* blkmem, /**< block memory */
698  const void* ptr /**< memory element */
699  );
700 
701 /** outputs allocation diagnostics of block memory */
702 SCIP_EXPORT
704  const BMS_BLKMEM* blkmem /**< block memory */
705  );
706 
707 /** outputs error messages, if there are allocated elements in the block memory and returns number of unfreed bytes */
708 SCIP_EXPORT
710  const BMS_BLKMEM* blkmem /**< block memory */
711  );
712 
713 
714 
715 
716 
717 /***********************************************************
718  * Buffer Memory Management
719  *
720  * Efficient memory management for temporary objects
721  ***********************************************************/
722 
723 typedef struct BMS_BufMem BMS_BUFMEM; /**< buffer memory for temporary objects */
724 
725 /* Note: values that are passed as a size_t parameter are first converted to ptrdiff_t to be sure that negative numbers
726  * are extended to the larger size. Then they are converted to size_t. Thus, negative numbers are converted to very
727  * large size_t values. This is then checked within the functions. */
728 
729 #define BMSallocBufferMemory(mem,ptr) ASSIGN((ptr), BMSallocBufferMemory_call((mem), sizeof(**(ptr)), __FILE__, __LINE__))
730 #define BMSallocBufferMemorySize(mem,ptr,size) ASSIGN((ptr), BMSallocBufferMemory_call((mem), (size_t)(ptrdiff_t)(size), __FILE__, __LINE__))
731 #define BMSreallocBufferMemorySize(mem,ptr,size) \
732  ASSIGN((ptr), BMSreallocBufferMemory_call((mem), (void*)(*(ptr)), (size_t)(ptrdiff_t)(size), __FILE__, __LINE__))
733 #define BMSallocBufferMemoryArray(mem,ptr,num) ASSIGN((ptr), BMSallocBufferMemoryArray_call((mem), (size_t)(ptrdiff_t)(num), sizeof(**(ptr)), __FILE__, __LINE__))
734 #define BMSallocClearBufferMemoryArray(mem,ptr,num) ASSIGN((ptr), BMSallocClearBufferMemoryArray_call((mem), (size_t)(ptrdiff_t)(num), sizeof(**(ptr)), __FILE__, __LINE__))
735 #define BMSreallocBufferMemoryArray(mem,ptr,num) ASSIGN((ptr), BMSreallocBufferMemoryArray_call((mem), (void*)(*(ptr)), (size_t)(ptrdiff_t)(num), \
736  sizeof(**(ptr)), __FILE__, __LINE__))
737 #define BMSduplicateBufferMemory(mem,ptr,source,size) \
738  ASSIGN((ptr), BMSduplicateBufferMemory_call((mem), (const void*)(source), (size_t)(ptrdiff_t)(size), __FILE__, __LINE__))
739 #define BMSduplicateBufferMemoryArray(mem,ptr,source,num) ASSIGNCHECK((ptr), BMSduplicateBufferMemoryArray_call((mem), \
740  (const void*)(source), (size_t)(ptrdiff_t)(num), sizeof(**(ptr)), __FILE__, __LINE__), source)
741 
742 #define BMSfreeBufferMemory(mem,ptr) BMSfreeBufferMemory_call((mem), (void**)(ptr), __FILE__, __LINE__)
743 #define BMSfreeBufferMemoryNull(mem,ptr) BMSfreeBufferMemoryNull_call((mem), (void**)(ptr), __FILE__, __LINE__)
744 #define BMSfreeBufferMemoryArray(mem,ptr) BMSfreeBufferMemory_call((mem), (void**)(ptr), __FILE__, __LINE__)
745 #define BMSfreeBufferMemoryArrayNull(mem,ptr) BMSfreeBufferMemoryNull_call((mem), (void**)(ptr), __FILE__, __LINE__)
746 #define BMSfreeBufferMemorySize(mem,ptr) BMSfreeBufferMemory_call((mem), (void**)(ptr), __FILE__, __LINE__);
747 #define BMSfreeBufferMemorySizeNull(mem,ptr) BMSfreeBufferMemoryNull_call((mem), (void**)(ptr), __FILE__, __LINE__)
748 
749 #define BMScreateBufferMemory(fac,init,clean) BMScreateBufferMemory_call((fac), (init), (clean), __FILE__, __LINE__)
750 #define BMSdestroyBufferMemory(mem) BMSdestroyBufferMemory_call((mem), __FILE__, __LINE__)
751 
752 
753 /** creates memory buffer storage */
754 SCIP_EXPORT
756  double arraygrowfac, /**< memory growing factor for dynamically allocated arrays */
757  int arraygrowinit, /**< initial size of dynamically allocated arrays */
758  unsigned int clean, /**< should the memory blocks in the buffer be initialized to zero? */
759  const char* filename, /**< source file of the function call */
760  int line /**< line number in source file of the function call */
761  );
762 
763 /** destroys buffer memory */
764 SCIP_EXPORT
766  BMS_BUFMEM** buffer, /**< pointer to memory buffer storage */
767  const char* filename, /**< source file of the function call */
768  int line /**< line number in source file of the function call */
769  );
770 
771 /** set arraygrowfac */
772 SCIP_EXPORT
774  BMS_BUFMEM* buffer, /**< pointer to memory buffer storage */
775  double arraygrowfac /**< memory growing factor for dynamically allocated arrays */
776  );
777 
778 /** set arraygrowinit */
779 SCIP_EXPORT
781  BMS_BUFMEM* buffer, /**< pointer to memory buffer storage */
782  int arraygrowinit /**< initial size of dynamically allocated arrays */
783  );
784 
785 /** allocates the next unused buffer */
786 SCIP_EXPORT
788  BMS_BUFMEM* buffer, /**< memory buffer storage */
789  size_t size, /**< minimal required size of the buffer */
790  const char* filename, /**< source file of the function call */
791  int line /**< line number in source file of the function call */
792  );
793 
794 /** allocates the next unused buffer array */
795 SCIP_EXPORT
797  BMS_BUFMEM* buffer, /**< memory buffer storage */
798  size_t num, /**< size of array to be allocated */
799  size_t typesize, /**< size of components */
800  const char* filename, /**< source file of the function call */
801  int line /**< line number in source file of the function call */
802  );
803 
804 /** allocates the next unused buffer and clears it */
805 SCIP_EXPORT
807  BMS_BUFMEM* buffer, /**< memory buffer storage */
808  size_t num, /**< size of array to be allocated */
809  size_t typesize, /**< size of components */
810  const char* filename, /**< source file of the function call */
811  int line /**< line number in source file of the function call */
812  );
813 
814 /** reallocates the buffer to at least the given size */
815 SCIP_EXPORT
817  BMS_BUFMEM* buffer, /**< memory buffer storage */
818  void* ptr, /**< pointer to the allocated memory buffer */
819  size_t size, /**< minimal required size of the buffer */
820  const char* filename, /**< source file of the function call */
821  int line /**< line number in source file of the function call */
822  );
823 
824 /** reallocates an array in the buffer to at least the given size */
825 SCIP_EXPORT
827  BMS_BUFMEM* buffer, /**< memory buffer storage */
828  void* ptr, /**< pointer to the allocated memory buffer */
829  size_t num, /**< size of array to be allocated */
830  size_t typesize, /**< size of components */
831  const char* filename, /**< source file of the function call */
832  int line /**< line number in source file of the function call */
833  );
834 
835 /** allocates the next unused buffer and copies the given memory into the buffer */
836 SCIP_EXPORT
838  BMS_BUFMEM* buffer, /**< memory buffer storage */
839  const void* source, /**< memory block to copy into the buffer */
840  size_t size, /**< minimal required size of the buffer */
841  const char* filename, /**< source file of the function call */
842  int line /**< line number in source file of the function call */
843  );
844 
845 /** allocates an array in the next unused buffer and copies the given memory into the buffer */
846 SCIP_EXPORT
848  BMS_BUFMEM* buffer, /**< memory buffer storage */
849  const void* source, /**< memory block to copy into the buffer */
850  size_t num, /**< size of array to be allocated */
851  size_t typesize, /**< size of components */
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 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 /** frees a buffer if pointer is not NULL and sets pointer to NULL */
866 SCIP_EXPORT
868  BMS_BUFMEM* buffer, /**< memory buffer storage */
869  void** ptr, /**< pointer to pointer to the allocated memory buffer */
870  const char* filename, /**< source file of the function call */
871  int line /**< line number in source file of the function call */
872  );
873 
874 /** gets number of used buffers */
875 SCIP_EXPORT
877  BMS_BUFMEM* buffer /**< memory buffer storage */
878  );
879 
880 /** returns the number of allocated bytes in the buffer memory */
881 SCIP_EXPORT
882 long long BMSgetBufferMemoryUsed(
883  const BMS_BUFMEM* bufmem /**< buffer memory */
884  );
885 
886 /** outputs statistics about currently allocated buffers to the screen */
887 SCIP_EXPORT
889  BMS_BUFMEM* buffer /**< memory buffer storage */
890  );
891 
892 
893 #ifdef __cplusplus
894 }
895 #endif
896 
897 #endif
void * BMSreallocBufferMemory_call(BMS_BUFMEM *buffer, void *ptr, size_t size, const char *filename, int line)
Definition: memory.c:2917
void BMSfreeBufferMemoryNull_call(BMS_BUFMEM *buffer, void **ptr, const char *filename, int line)
Definition: memory.c:3102
void BMSdestroyChunkMemory_call(BMS_CHKMEM **chkmem, const char *filename, int line)
Definition: memory.c:1507
void * BMSallocBlockMemory_call(BMS_BLKMEM *blkmem, size_t size, const char *filename, int line)
Definition: memory.c:1891
struct BMS_ChkMem BMS_CHKMEM
Definition: memory.h:304
BMS_CHKMEM * BMScreateChunkMemory_call(size_t size, int initchunksize, int garbagefactor, const char *filename, int line)
Definition: memory.c:1465
void BMSfreeMemoryNull_call(void **ptr, const char *filename, int line)
Definition: memory.c:644
void * BMSallocChunkMemory_call(BMS_CHKMEM *chkmem, size_t size, const char *filename, int line)
Definition: memory.c:1527
void * BMSallocBlockMemoryArray_call(BMS_BLKMEM *blkmem, size_t num, size_t typesize, const char *filename, int line)
Definition: memory.c:1928
void * BMSallocClearBlockMemoryArray_call(BMS_BLKMEM *blkmem, size_t num, size_t typesize, const char *filename, int line)
Definition: memory.c:1949
void BMSclearBlockMemory_call(BMS_BLKMEM *blkmem, const char *filename, int line)
Definition: memory.c:1771
double arraygrowfac
Definition: memory.c:2505
void * BMSallocBufferMemoryArray_call(BMS_BUFMEM *buffer, size_t num, size_t typesize, const char *filename, int line)
Definition: memory.c:2805
size_t * size
Definition: memory.c:2499
int BMSisAligned(size_t size)
Definition: memory.c:779
void BMSdestroyBlockMemory_call(BMS_BLKMEM **blkmem, const char *filename, int line)
Definition: memory.c:1805
long long BMScheckEmptyBlockMemory_call(const BMS_BLKMEM *blkmem)
Definition: memory.c:2417
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:2007
size_t BMSgetBlockPointerSize_call(const BMS_BLKMEM *blkmem, const void *ptr)
Definition: memory.c:2273
void * BMSduplicateChunkMemory_call(BMS_CHKMEM *chkmem, const void *source, size_t size, const char *filename, int line)
Definition: memory.c:1554
void BMSfreeChunkMemory_call(BMS_CHKMEM *chkmem, void **ptr, size_t size, const char *filename, int line)
Definition: memory.c:1576
void * BMSallocClearBlockMemory_call(BMS_BLKMEM *blkmem, size_t size, const char *filename, int line)
Definition: memory.c:1911
long long BMSgetBlockMemoryUsedMax_call(const BMS_BLKMEM *blkmem)
Definition: memory.c:2243
long long BMSgetBlockMemoryAllocated_call(const BMS_BLKMEM *blkmem)
Definition: memory.c:2213
void * BMSallocBufferMemory_call(BMS_BUFMEM *buffer, size_t size, const char *filename, int line)
Definition: memory.c:2785
void BMSsetBufferMemoryArraygrowinit(BMS_BUFMEM *buffer, int arraygrowinit)
Definition: memory.c:2592
void * BMSallocClearBufferMemoryArray_call(BMS_BUFMEM *buffer, size_t num, size_t typesize, const char *filename, int line)
Definition: memory.c:2826
void * BMSduplicateMemory_call(const void *source, size_t size, const char *filename, int line)
Definition: memory.c:583
void * BMSreallocBlockMemory_call(BMS_BLKMEM *blkmem, void *ptr, size_t oldsize, size_t newsize, const char *filename, int line)
Definition: memory.c:1967
void * BMSreallocMemoryArray_call(void *ptr, size_t num, size_t typesize, const char *filename, int line)
Definition: memory.c:499
void * BMSallocMemoryArray_call(size_t num, size_t typesize, const char *filename, int line)
Definition: memory.c:425
void BMSdestroyBufferMemory_call(BMS_BUFMEM **buffer, const char *filename, int line)
Definition: memory.c:2547
void BMSdisplayMemory_call(void)
Definition: memory.c:327
BMS_BLKMEM * BMScreateBlockMemory_call(int initchunksize, int garbagefactor, const char *filename, int line)
Definition: memory.c:1737
void BMSclearMemory_call(void *ptr, size_t size)
Definition: memory.c:538
void BMSfreeBufferMemory_call(BMS_BUFMEM *buffer, void **ptr, const char *filename, int line)
Definition: memory.c:3079
void * BMSduplicateBlockMemory_call(BMS_BLKMEM *blkmem, const void *source, size_t size, const char *filename, int line)
Definition: memory.c:2046
void BMScheckEmptyMemory_call(void)
Definition: memory.c:335
void BMSgarbagecollectChunkMemory_call(BMS_CHKMEM *chkmem)
Definition: memory.c:1629
void * BMSreallocMemory_call(void *ptr, size_t size, const char *filename, int line)
Definition: memory.c:463
long long BMSgetBlockMemoryUsed_call(const BMS_BLKMEM *blkmem)
Definition: memory.c:2223
long long BMSgetBlockMemoryAllocatedMax_call(const BMS_BLKMEM *blkmem)
Definition: memory.c:2263
void * BMSduplicateBlockMemoryArray_call(BMS_BLKMEM *blkmem, const void *source, size_t num, size_t typesize, const char *filename, int line)
Definition: memory.c:2066
void BMSfreeBlockMemoryNull_call(BMS_BLKMEM *blkmem, void **ptr, size_t size, const char *filename, int line)
Definition: memory.c:2158
long long BMSgetChunkMemoryUsed_call(const BMS_CHKMEM *chkmem)
Definition: memory.c:1639
void BMSgarbagecollectBlockMemory_call(BMS_BLKMEM *blkmem)
Definition: memory.c:2179
void BMSprintBufferMemory(BMS_BUFMEM *buffer)
Definition: memory.c:3150
void * BMSallocMemory_call(size_t size, const char *filename, int line)
Definition: memory.c:391
unsigned int arraygrowinit
Definition: memory.c:2506
void BMSfreeMemory_call(void **ptr, const char *filename, int line)
Definition: memory.c:622
BMS_BUFMEM * BMScreateBufferMemory_call(double arraygrowfac, int arraygrowinit, unsigned int clean, const char *filename, int line)
Definition: memory.c:2511
void * BMSallocClearMemory_call(size_t num, size_t typesize, const char *filename, int line)
Definition: memory.c:352
long long BMSgetBlockMemoryUnusedMax_call(const BMS_BLKMEM *blkmem)
Definition: memory.c:2253
void BMSsetBufferMemoryArraygrowfac(BMS_BUFMEM *buffer, double arraygrowfac)
Definition: memory.c:2580
void * BMSduplicateBufferMemory_call(BMS_BUFMEM *buffer, const void *source, size_t size, const char *filename, int line)
Definition: memory.c:2960
void BMSmoveMemory_call(void *ptr, const void *source, size_t size)
Definition: memory.c:568
void * BMSreallocBufferMemoryArray_call(BMS_BUFMEM *buffer, void *ptr, size_t num, size_t typesize, const char *filename, int line)
Definition: memory.c:2938
void BMSfreeChunkMemoryNull_call(BMS_CHKMEM *chkmem, void **ptr, size_t size, const char *filename, int line)
Definition: memory.c:1605
long long BMSgetBlockMemoryUnused_call(const BMS_BLKMEM *blkmem)
Definition: memory.c:2233
size_t BMSgetNUsedBufferMemory(BMS_BUFMEM *buffer)
Definition: memory.c:3122
void BMSalignMemsize(size_t *size)
Definition: memory.c:770
void BMScopyMemory_call(void *ptr, const void *source, size_t size)
Definition: memory.c:551
void BMSfreeBlockMemory_call(BMS_BLKMEM *blkmem, void **ptr, size_t size, const char *filename, int line)
Definition: memory.c:2136
void BMSdisplayBlockMemory_call(const BMS_BLKMEM *blkmem)
Definition: memory.c:2293
void BMSclearChunkMemory_call(BMS_CHKMEM *chkmem, const char *filename, int line)
Definition: memory.c:1489
size_t BMSgetPointerSize_call(const void *ptr)
Definition: memory.c:318
struct BMS_BlkMem BMS_BLKMEM
Definition: memory.h:439
unsigned int clean
Definition: memory.c:2502
long long BMSgetMemoryUsed_call(void)
Definition: memory.c:342
void * BMSduplicateMemoryArray_call(const void *source, size_t num, size_t typesize, const char *filename, int line)
Definition: memory.c:602
long long BMSgetBufferMemoryUsed(const BMS_BUFMEM *bufmem)
Definition: memory.c:3132
void * BMSduplicateBufferMemoryArray_call(BMS_BUFMEM *buffer, const void *source, size_t num, size_t typesize, const char *filename, int line)
Definition: memory.c:2983