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-2017 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 email to 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 
65  /* free memory buffers */
66  BMSdestroyBufferMemory(&(*mem)->cleanbuffer);
67  BMSdestroyBufferMemory(&(*mem)->buffer);
68 
69  /* print unfreed memory */
70 #ifndef NDEBUG
71  (void) BMSblockMemoryCheckEmpty((*mem)->setmem);
72  (void) BMSblockMemoryCheckEmpty((*mem)->probmem);
73 #endif
74 
75  /* free block memory */
76  BMSdestroyBlockMemory(&(*mem)->probmem);
77  BMSdestroyBlockMemory(&(*mem)->setmem);
78 
79  BMSfreeMemory(mem);
80 
81  return SCIP_OKAY;
82 }
83 
84 /** returns the total number of bytes used in block and buffer memory */
86  SCIP_MEM* mem /**< pointer to block and buffer memory structure */
87  )
88 {
89  assert(mem != NULL);
90 
93 }
94 
95 /** returns the total number of bytes in block and buffer memory */
97  SCIP_MEM* mem /**< pointer to block and buffer memory structure */
98  )
99 {
100  assert(mem != NULL);
101 
104 }
105 
106 /** returns the maximal number of used bytes in block memory */
108  SCIP_MEM* mem /**< pointer to block and buffer memory structure */
109  )
110 {
111  assert(mem != NULL);
112 
114 }
115 
116 /** returns the maximal number of allocated but not used bytes in block memory */
118  SCIP_MEM* mem /**< pointer to block and buffer memory structure */
119  )
120 {
121  assert(mem != NULL);
122 
124 }
125 
126 /** returns the maximal number of allocated bytes in block memory */
128  SCIP_MEM* mem /**< pointer to block and buffer memory structure */
129  )
130 {
131  assert(mem != NULL);
132 
134 }
#define BMSgetBlockMemoryUsed(mem)
Definition: memory.h:428
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:85
#define BMScreateBlockMemory(csz, gbf)
Definition: memory.h:402
#define FALSE
Definition: def.h:64
#define TRUE
Definition: def.h:63
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:53
#define SCIPdebugMessage
Definition: pub_message.h:77
#define BMSfreeMemory(ptr)
Definition: memory.h:100
#define BMScreateBufferMemory(fac, init, clean)
Definition: memory.h:691
SCIP_Longint SCIPmemGetAllocatedBlockmemoryMax(SCIP_MEM *mem)
Definition: mem.c:127
long long BMSgetBufferMemoryUsed(const BMS_BUFMEM *buffer)
Definition: memory.c:3172
#define BMSblockMemoryCheckEmpty(mem)
Definition: memory.h:435
methods for block memory pools and memory buffers
#define NULL
Definition: lpi_spx1.cpp:137
#define BMSgetBlockMemoryAllocatedMax(mem)
Definition: memory.h:432
BMS_BLKMEM * setmem
Definition: struct_mem.h:39
SCIP_Longint SCIPmemGetUnusedBlockmemoryMax(SCIP_MEM *mem)
Definition: mem.c:117
SCIP_RETCODE SCIPmemCreate(SCIP_MEM **mem)
Definition: mem.c:33
#define BMSgetBlockMemoryUsedMax(mem)
Definition: memory.h:430
#define SCIP_DEFAULT_MEM_ARRAYGROWFAC
Definition: def.h:233
#define BMSdestroyBufferMemory(mem)
Definition: memory.h:692
BMS_BLKMEM * probmem
Definition: struct_mem.h:40
SCIP_Longint SCIPmemGetTotal(SCIP_MEM *mem)
Definition: mem.c:96
SCIP_Longint SCIPmemGetUsedBlockmemoryMax(SCIP_MEM *mem)
Definition: mem.c:107
public methods for message output
SCIP_RETCODE SCIPmemFree(SCIP_MEM **mem)
Definition: mem.c:59
#define BMSallocMemory(ptr)
Definition: memory.h:74
#define SCIP_Longint
Definition: def.h:120
#define BMSgetBlockMemoryUnusedMax(mem)
Definition: memory.h:431
#define BMSgetBlockMemoryAllocated(mem)
Definition: memory.h:427
common defines and data types used in all packages of SCIP
#define SCIP_ALLOC(x)
Definition: def.h:317
#define SCIP_DEFAULT_MEM_ARRAYGROWINIT
Definition: def.h:234
#define BMSdestroyBlockMemory(mem)
Definition: memory.h:404