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-2020 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 scipopt.org. */
13 /* */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15 
16 /**@file mem.c
17  * @ingroup OTHER_CFILES
18  * @brief block memory pools and memory buffers
19  * @author Tobias Achterberg
20  * @author Gerald Gamrath
21  */
22 
23 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
24 
25 #include <assert.h>
26 
27 #include "scip/def.h"
28 #include "scip/mem.h"
29 #include "scip/pub_message.h"
30 
31 
32 
33 /** creates block and buffer memory structures */
35  SCIP_MEM** mem /**< pointer to block and buffer memory structure */
36  )
37 {
38  assert(mem != NULL);
39 
40  SCIP_ALLOC( BMSallocMemory(mem) );
41 
42  /* alloc block memory */
43  SCIP_ALLOC( (*mem)->setmem = BMScreateBlockMemory(1, 10) );
44  SCIP_ALLOC( (*mem)->probmem = BMScreateBlockMemory(1, 10) );
45 
46  /* alloc memory buffers */
49 
50  SCIPdebugMessage("created setmem block memory at <%p>\n", (void*)(*mem)->setmem);
51  SCIPdebugMessage("created probmem block memory at <%p>\n", (void*)(*mem)->probmem);
52 
53  SCIPdebugMessage("created buffer memory at <%p>\n", (void*)(*mem)->buffer);
54  SCIPdebugMessage("created clean buffer memory at <%p>\n", (void*)(*mem)->cleanbuffer);
55 
56  return SCIP_OKAY;
57 }
58 
59 /** frees block and buffer memory structures */
61  SCIP_MEM** mem /**< pointer to block and buffer memory structure */
62  )
63 {
64  assert(mem != NULL);
65  if( *mem == NULL )
66  return SCIP_OKAY;
67 
68  /* free memory buffers */
69  BMSdestroyBufferMemory(&(*mem)->cleanbuffer);
70  BMSdestroyBufferMemory(&(*mem)->buffer);
71 
72  /* print unfreed memory */
73 #ifndef NDEBUG
74  (void) BMSblockMemoryCheckEmpty((*mem)->setmem);
75  (void) BMSblockMemoryCheckEmpty((*mem)->probmem);
76 #endif
77 
78  /* free block memory */
79  BMSdestroyBlockMemory(&(*mem)->probmem);
80  BMSdestroyBlockMemory(&(*mem)->setmem);
81 
82  BMSfreeMemory(mem);
83 
84  return SCIP_OKAY;
85 }
86 
87 /** returns the total number of bytes used in block and buffer memory */
89  SCIP_MEM* mem /**< pointer to block and buffer memory structure */
90  )
91 {
92  assert(mem != NULL);
93 
96 }
97 
98 /** returns the total number of bytes in block and buffer memory */
100  SCIP_MEM* mem /**< pointer to block and buffer memory structure */
101  )
102 {
103  assert(mem != NULL);
104 
107 }
108 
109 /** returns the maximal number of used bytes in block memory */
111  SCIP_MEM* mem /**< pointer to block and buffer memory structure */
112  )
113 {
114  assert(mem != NULL);
115 
117 }
118 
119 /** returns the maximal number of allocated but not used bytes in block memory */
121  SCIP_MEM* mem /**< pointer to block and buffer memory structure */
122  )
123 {
124  assert(mem != NULL);
125 
127 }
128 
129 /** returns the maximal number of allocated bytes in block memory */
131  SCIP_MEM* mem /**< pointer to block and buffer memory structure */
132  )
133 {
134  assert(mem != NULL);
135 
137 }
#define BMSgetBlockMemoryUsed(mem)
Definition: memory.h:465
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:88
#define BMScreateBlockMemory(csz, gbf)
Definition: memory.h:439
#define FALSE
Definition: def.h:73
#define TRUE
Definition: def.h:72
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:54
#define SCIPdebugMessage
Definition: pub_message.h:87
#define BMSfreeMemory(ptr)
Definition: memory.h:137
#define BMScreateBufferMemory(fac, init, clean)
Definition: memory.h:728
SCIP_Longint SCIPmemGetAllocatedBlockmemoryMax(SCIP_MEM *mem)
Definition: mem.c:130
long long BMSgetBufferMemoryUsed(const BMS_BUFMEM *buffer)
Definition: memory.c:3106
#define BMSblockMemoryCheckEmpty(mem)
Definition: memory.h:472
methods for block memory pools and memory buffers
#define NULL
Definition: lpi_spx1.cpp:155
#define BMSgetBlockMemoryAllocatedMax(mem)
Definition: memory.h:469
BMS_BLKMEM * setmem
Definition: struct_mem.h:39
SCIP_Longint SCIPmemGetUnusedBlockmemoryMax(SCIP_MEM *mem)
Definition: mem.c:120
SCIP_RETCODE SCIPmemCreate(SCIP_MEM **mem)
Definition: mem.c:34
#define BMSgetBlockMemoryUsedMax(mem)
Definition: memory.h:467
#define SCIP_DEFAULT_MEM_ARRAYGROWFAC
Definition: def.h:291
#define BMSdestroyBufferMemory(mem)
Definition: memory.h:729
BMS_BLKMEM * probmem
Definition: struct_mem.h:40
SCIP_Longint SCIPmemGetTotal(SCIP_MEM *mem)
Definition: mem.c:99
SCIP_Longint SCIPmemGetUsedBlockmemoryMax(SCIP_MEM *mem)
Definition: mem.c:110
public methods for message output
SCIP_RETCODE SCIPmemFree(SCIP_MEM **mem)
Definition: mem.c:60
#define BMSallocMemory(ptr)
Definition: memory.h:111
#define SCIP_Longint
Definition: def.h:148
#define BMSgetBlockMemoryUnusedMax(mem)
Definition: memory.h:468
#define BMSgetBlockMemoryAllocated(mem)
Definition: memory.h:464
common defines and data types used in all packages of SCIP
#define SCIP_ALLOC(x)
Definition: def.h:375
#define SCIP_DEFAULT_MEM_ARRAYGROWINIT
Definition: def.h:292
#define BMSdestroyBlockMemory(mem)
Definition: memory.h:441