1 /* glpdmp.h (dynamic memory pool) */
3 /***********************************************************************
4 * This code is part of GLPK (GNU Linear Programming Kit).
6 * Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
7 * 2009, 2010 Andrew Makhorin, Department for Applied Informatics,
8 * Moscow Aviation Institute, Moscow, Russia. All rights reserved.
9 * E-mail: <mao@gnu.org>.
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.
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.
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 ***********************************************************************/
30 typedef struct DMP DMP;
32 #define DMP_BLK_SIZE 8000
33 /* size of memory blocks, in bytes, allocated for memory pools */
36 { /* dynamic memory pool */
39 /* size of atoms, in bytes, 1 <= size <= 256; if size = 0, atoms
40 may have different sizes */
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
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 */
52 /* number of bytes used in the most recently allocated memory
55 /* number of atoms which are currently in use */
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 */