lemon-project-template-glpk
view deps/glpk/src/glpdmp.h @ 9:33de93886c88
Import GLPK 4.47
author | Alpar Juttner <alpar@cs.elte.hu> |
---|---|
date | Sun, 06 Nov 2011 20:59:10 +0100 |
parents | |
children |
line source
1 /* glpdmp.h (dynamic memory pool) */
3 /***********************************************************************
4 * This code is part of GLPK (GNU Linear Programming Kit).
5 *
6 * Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
7 * 2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
8 * Moscow Aviation Institute, Moscow, Russia. All rights reserved.
9 * E-mail: <mao@gnu.org>.
10 *
11 * GLPK is free software: you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by
13 * the Free Software Foundation, either version 3 of the License, or
14 * (at your option) any later version.
15 *
16 * GLPK is distributed in the hope that it will be useful, but WITHOUT
17 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
18 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
19 * License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with GLPK. If not, see <http://www.gnu.org/licenses/>.
23 ***********************************************************************/
25 #ifndef GLPDMP_H
26 #define GLPDMP_H
28 #include "glpenv.h"
30 typedef struct DMP DMP;
32 #define DMP_BLK_SIZE 8000
33 /* size of memory blocks, in bytes, allocated for memory pools */
35 struct DMP
36 { /* dynamic memory pool */
37 #if 0
38 int size;
39 /* size of atoms, in bytes, 1 <= size <= 256; if size = 0, atoms
40 may have different sizes */
41 #endif
42 void *avail[32];
43 /* avail[k], 0 <= k <= 31, is a pointer to the first available
44 (free) cell of (k+1)*8 bytes long; in the beginning of each
45 free cell there is a pointer to another free cell of the same
46 length */
47 void *block;
48 /* pointer to the most recently allocated memory block; in the
49 beginning of each allocated memory block there is a pointer to
50 the previously allocated memory block */
51 int used;
52 /* number of bytes used in the most recently allocated memory
53 block */
54 glp_long count;
55 /* number of atoms which are currently in use */
56 };
58 #define dmp_create_pool _glp_dmp_create_pool
59 DMP *dmp_create_pool(void);
60 /* create dynamic memory pool */
62 #define dmp_get_atom _glp_dmp_get_atom
63 void *dmp_get_atom(DMP *pool, int size);
64 /* get free atom from dynamic memory pool */
66 #define dmp_free_atom _glp_dmp_free_atom
67 void dmp_free_atom(DMP *pool, void *atom, int size);
68 /* return atom to dynamic memory pool */
70 #define dmp_in_use _glp_dmp_in_use
71 glp_long dmp_in_use(DMP *pool);
72 /* determine how many atoms are still in use */
74 #define dmp_delete_pool _glp_dmp_delete_pool
75 void dmp_delete_pool(DMP *pool);
76 /* delete dynamic memory pool */
78 #endif
80 /* eof */