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-2016 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  /* free block memory */
70  BMSdestroyBlockMemory(&(*mem)->probmem);
71  BMSdestroyBlockMemory(&(*mem)->setmem);
72 
73  BMSfreeMemory(mem);
74 
75  return SCIP_OKAY;
76 }
77 
78 /** returns the total number of bytes used in block and buffer memory */
80  SCIP_MEM* mem /**< pointer to block and buffer memory structure */
81  )
82 {
83  assert(mem != NULL);
84 
87 }
BMS_BUFMEM * cleanbuffer
Definition: struct_mem.h:41
BMS_BUFMEM * buffer
Definition: struct_mem.h:40
SCIP_Longint SCIPmemGetUsed(SCIP_MEM *mem)
Definition: mem.c:79
#define NULL
Definition: lpi_spx.cpp:130
#define FALSE
Definition: def.h:56
#define TRUE
Definition: def.h:55
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:53
#define SCIPdebugMessage
Definition: pub_message.h:77
#define BMSdestroyBlockMemory(mem)
Definition: memory.h:404
#define BMScreateBufferMemory(fac, init, clean)
Definition: memory.h:652
long long BMSgetBufferMemoryUsed(const BMS_BUFMEM *buffer)
Definition: memory.c:3041
methods for block memory pools and memory buffers
#define BMSallocMemory(ptr)
Definition: memory.h:74
#define BMSdestroyBufferMemory(mem)
Definition: memory.h:653
BMS_BLKMEM * setmem
Definition: struct_mem.h:38
#define BMSfreeMemory(ptr)
Definition: memory.h:100
SCIP_RETCODE SCIPmemCreate(SCIP_MEM **mem)
Definition: mem.c:33
#define BMScreateBlockMemory(csz, gbf)
Definition: memory.h:402
#define SCIP_DEFAULT_MEM_ARRAYGROWFAC
Definition: def.h:219
#define BMSgetBlockMemoryUsed(mem)
Definition: memory.h:427
BMS_BLKMEM * probmem
Definition: struct_mem.h:39
public methods for message output
SCIP_RETCODE SCIPmemFree(SCIP_MEM **mem)
Definition: mem.c:59
#define SCIP_Longint
Definition: def.h:112
common defines and data types used in all packages of SCIP
#define SCIP_ALLOC(x)
Definition: def.h:277
#define SCIP_DEFAULT_MEM_ARRAYGROWINIT
Definition: def.h:220