Scippy

SCIP

Solving Constraint Integer Programs

mem.c
Go to the documentation of this file.
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2 /* */
3 /* This file is part of the program and library */
4 /* SCIP --- Solving Constraint Integer Programs */
5 /* */
6 /* Copyright (C) 2002-2019 Konrad-Zuse-Zentrum */
7 /* fuer Informationstechnik Berlin */
8 /* */
9 /* SCIP 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 SCIP; see the file COPYING. If not visit scip.zib.de. */
13 /* */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15 
16 /**@file mem.c
17  * @brief block memory pools and memory buffers
18  * @author Tobias Achterberg
19  * @author Gerald Gamrath
20  */
21 
22 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
23 
24 #include <assert.h>
25 
26 #include "scip/def.h"
27 #include "scip/mem.h"
28 #include "scip/pub_message.h"
29 
30 
31 
32 /** creates block and buffer memory structures */
34  SCIP_MEM** mem /**< pointer to block and buffer memory structure */
35  )
36 {
37  assert(mem != NULL);
38 
39  SCIP_ALLOC( BMSallocMemory(mem) );
40 
41  /* alloc block memory */
42  SCIP_ALLOC( (*mem)->setmem = BMScreateBlockMemory(1, 10) );
43  SCIP_ALLOC( (*mem)->probmem = BMScreateBlockMemory(1, 10) );
44 
45  /* alloc memory buffers */
48 
49  SCIPdebugMessage("created setmem block memory at <%p>\n", (void*)(*mem)->setmem);
50  SCIPdebugMessage("created probmem block memory at <%p>\n", (void*)(*mem)->probmem);
51 
52  SCIPdebugMessage("created buffer memory at <%p>\n", (void*)(*mem)->buffer);
53  SCIPdebugMessage("created clean buffer memory at <%p>\n", (void*)(*mem)->cleanbuffer);
54 
55  return SCIP_OKAY;
56 }
57 
58 /** frees block and buffer memory structures */
60  SCIP_MEM** mem /**< pointer to block and buffer memory structure */
61  )
62 {
63  assert(mem != NULL);
64  if( *mem == NULL )
65  return SCIP_OKAY;
66 
67  /* free memory buffers */
68  BMSdestroyBufferMemory(&(*mem)->cleanbuffer);
69  BMSdestroyBufferMemory(&(*mem)->buffer);
70 
71  /* print unfreed memory */
72 #ifndef NDEBUG
73  (void) BMSblockMemoryCheckEmpty((*mem)->setmem);
74  (void) BMSblockMemoryCheckEmpty((*mem)->probmem);
75 #endif
76 
77  /* free block memory */
78  BMSdestroyBlockMemory(&(*mem)->probmem);
79  BMSdestroyBlockMemory(&(*mem)->setmem);
80 
81  BMSfreeMemory(mem);
82 
83  return SCIP_OKAY;
84 }
85 
86 /** returns the total number of bytes used in block and buffer memory */
88  SCIP_MEM* mem /**< pointer to block and buffer memory structure */
89  )
90 {
91  assert(mem != NULL);
92 
95 }
96 
97 /** returns the total number of bytes in block and buffer memory */
99  SCIP_MEM* mem /**< pointer to block and buffer memory structure */
100  )
101 {
102  assert(mem != NULL);
103 
106 }
107 
108 /** returns the maximal number of used bytes in block memory */
110  SCIP_MEM* mem /**< pointer to block and buffer memory structure */
111  )
112 {
113  assert(mem != NULL);
114 
116 }
117 
118 /** returns the maximal number of allocated but not used bytes in block memory */
120  SCIP_MEM* mem /**< pointer to block and buffer memory structure */
121  )
122 {
123  assert(mem != NULL);
124 
126 }
127 
128 /** returns the maximal number of allocated bytes in block memory */
130  SCIP_MEM* mem /**< pointer to block and buffer memory structure */
131  )
132 {
133  assert(mem != NULL);
134 
136 }
#define NULL
Definition: def.h:246
#define BMSgetBlockMemoryUsed(mem)
Definition: memory.h:462
BMS_BUFMEM * cleanbuffer
Definition: struct_mem.h:42
BMS_BUFMEM * buffer
Definition: struct_mem.h:41
SCIP_Longint SCIPmemGetUsed(SCIP_MEM *mem)
Definition: mem.c:87
#define BMScreateBlockMemory(csz, gbf)
Definition: memory.h:436
#define FALSE
Definition: def.h:72
#define TRUE
Definition: def.h:71
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:53
#define SCIPdebugMessage
Definition: pub_message.h:77
#define BMSfreeMemory(ptr)
Definition: memory.h:134
#define BMScreateBufferMemory(fac, init, clean)
Definition: memory.h:725
SCIP_Longint SCIPmemGetAllocatedBlockmemoryMax(SCIP_MEM *mem)
Definition: mem.c:129
long long BMSgetBufferMemoryUsed(const BMS_BUFMEM *buffer)
Definition: memory.c:3104
#define BMSblockMemoryCheckEmpty(mem)
Definition: memory.h:469
methods for block memory pools and memory buffers
#define BMSgetBlockMemoryAllocatedMax(mem)
Definition: memory.h:466
BMS_BLKMEM * setmem
Definition: struct_mem.h:39
SCIP_Longint SCIPmemGetUnusedBlockmemoryMax(SCIP_MEM *mem)
Definition: mem.c:119
SCIP_RETCODE SCIPmemCreate(SCIP_MEM **mem)
Definition: mem.c:33
#define BMSgetBlockMemoryUsedMax(mem)
Definition: memory.h:464
#define SCIP_DEFAULT_MEM_ARRAYGROWFAC
Definition: def.h:285
#define BMSdestroyBufferMemory(mem)
Definition: memory.h:726
BMS_BLKMEM * probmem
Definition: struct_mem.h:40
SCIP_Longint SCIPmemGetTotal(SCIP_MEM *mem)
Definition: mem.c:98
SCIP_Longint SCIPmemGetUsedBlockmemoryMax(SCIP_MEM *mem)
Definition: mem.c:109
public methods for message output
SCIP_RETCODE SCIPmemFree(SCIP_MEM **mem)
Definition: mem.c:59
#define BMSallocMemory(ptr)
Definition: memory.h:108
#define SCIP_Longint
Definition: def.h:142
#define BMSgetBlockMemoryUnusedMax(mem)
Definition: memory.h:465
#define BMSgetBlockMemoryAllocated(mem)
Definition: memory.h:461
common defines and data types used in all packages of SCIP
#define SCIP_ALLOC(x)
Definition: def.h:369
#define SCIP_DEFAULT_MEM_ARRAYGROWINIT
Definition: def.h:286
#define BMSdestroyBlockMemory(mem)
Definition: memory.h:438