Scippy

SCIP

Solving Constraint Integer Programs

buffer.h
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-2014 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 buffer.h
17  * @brief internal methods for memory buffers for temporary objects
18  * @author Tobias Achterberg
19  */
20 
21 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
22 
23 #ifndef __SCIP_BUFFER_H__
24 #define __SCIP_BUFFER_H__
25 
26 
27 #include "scip/def.h"
28 #include "scip/type_retcode.h"
29 #include "scip/type_set.h"
30 #include "scip/type_buffer.h"
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 /** creates memory buffer storage */
37 extern
39  SCIP_BUFFER** buffer /**< pointer to memory buffer */
40  );
41 
42 /** frees memory buffer storage */
43 extern
44 void SCIPbufferFree(
45  SCIP_BUFFER** buffer /**< pointer to memory buffer */
46  );
47 
48 /** allocates the next unused buffer */
49 extern
51  SCIP_BUFFER* buffer, /**< memory buffer storage */
52  SCIP_SET* set, /**< global SCIP settings */
53  void** ptr, /**< pointer to store the allocated memory buffer */
54  int size /**< minimal required size of the buffer */
55  );
56 
57 /** allocates the next unused buffer and copies the given memory into the buffer */
58 extern
60  SCIP_BUFFER* buffer, /**< memory buffer storage */
61  SCIP_SET* set, /**< global SCIP settings */
62  void** ptr, /**< pointer to store the allocated memory buffer */
63  const void* source, /**< memory block to copy into the buffer */
64  int size /**< minimal required size of the buffer */
65  );
66 
67 /** reallocates the buffer to at least the given size */
68 extern
70  SCIP_BUFFER* buffer, /**< memory buffer storage */
71  SCIP_SET* set, /**< global SCIP settings */
72  void** ptr, /**< pointer to the allocated memory buffer */
73  int size /**< minimal required size of the buffer */
74  );
75 
76 #ifndef NDEBUG
77 /** allocates the next unused buffer; checks for integer overflow */
78 extern
80  SCIP_SET* set, /**< global SCIP settings */
81  void** ptr, /**< pointer to store the allocated memory buffer */
82  int num, /**< number of entries to allocate */
83  size_t elemsize /**< size of one element in the array */
84  );
85 
86 /** allocates the next unused buffer and copies the given memory into the buffer; checks for integer overflows */
87 extern
89  SCIP_SET* set, /**< global SCIP settings */
90  void** ptr, /**< pointer to store the allocated memory buffer */
91  const void* source, /**< memory block to copy into the buffer */
92  int num, /**< number of entries to copy */
93  size_t elemsize /**< size of one element in the array */
94  );
95 
96 /** reallocates the buffer to at least the given size; checks for integer overflows */
97 extern
99  SCIP_SET* set, /**< global SCIP settings */
100  void** ptr, /**< pointer to the allocated memory buffer */
101  int num, /**< number of entries to get memory for */
102  size_t elemsize /**< size of one element in the array */
103  );
104 #endif
105 
106 /** frees a buffer */
107 extern
108 void SCIPbufferFreeMem(
109  SCIP_BUFFER* buffer, /**< memory buffer storage */
110  void** ptr, /**< pointer to the allocated memory buffer */
111  int dummysize /**< used to get a safer define for SCIPsetFreeBufferSize/Array */
112  );
113 
114 /** gets number of used buffers */
115 extern
117  SCIP_BUFFER* buffer /**< memory buffer storage */
118  );
119 
120 /** outputs statistics about currently allocated buffers to the screen */
121 extern
122 void SCIPbufferPrint(
123  SCIP_BUFFER* buffer /**< memory buffer storage */
124  );
125 
126 #ifdef __cplusplus
127 }
128 #endif
129 
130 #endif
131