alpar@9: /* glpdmp.h (dynamic memory pool) */ alpar@9: alpar@9: /*********************************************************************** alpar@9: * This code is part of GLPK (GNU Linear Programming Kit). alpar@9: * alpar@9: * Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, alpar@9: * 2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics, alpar@9: * Moscow Aviation Institute, Moscow, Russia. All rights reserved. alpar@9: * E-mail: . alpar@9: * alpar@9: * GLPK is free software: you can redistribute it and/or modify it alpar@9: * under the terms of the GNU General Public License as published by alpar@9: * the Free Software Foundation, either version 3 of the License, or alpar@9: * (at your option) any later version. alpar@9: * alpar@9: * GLPK is distributed in the hope that it will be useful, but WITHOUT alpar@9: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY alpar@9: * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public alpar@9: * License for more details. alpar@9: * alpar@9: * You should have received a copy of the GNU General Public License alpar@9: * along with GLPK. If not, see . alpar@9: ***********************************************************************/ alpar@9: alpar@9: #ifndef GLPDMP_H alpar@9: #define GLPDMP_H alpar@9: alpar@9: #include "glpenv.h" alpar@9: alpar@9: typedef struct DMP DMP; alpar@9: alpar@9: #define DMP_BLK_SIZE 8000 alpar@9: /* size of memory blocks, in bytes, allocated for memory pools */ alpar@9: alpar@9: struct DMP alpar@9: { /* dynamic memory pool */ alpar@9: #if 0 alpar@9: int size; alpar@9: /* size of atoms, in bytes, 1 <= size <= 256; if size = 0, atoms alpar@9: may have different sizes */ alpar@9: #endif alpar@9: void *avail[32]; alpar@9: /* avail[k], 0 <= k <= 31, is a pointer to the first available alpar@9: (free) cell of (k+1)*8 bytes long; in the beginning of each alpar@9: free cell there is a pointer to another free cell of the same alpar@9: length */ alpar@9: void *block; alpar@9: /* pointer to the most recently allocated memory block; in the alpar@9: beginning of each allocated memory block there is a pointer to alpar@9: the previously allocated memory block */ alpar@9: int used; alpar@9: /* number of bytes used in the most recently allocated memory alpar@9: block */ alpar@9: glp_long count; alpar@9: /* number of atoms which are currently in use */ alpar@9: }; alpar@9: alpar@9: #define dmp_create_pool _glp_dmp_create_pool alpar@9: DMP *dmp_create_pool(void); alpar@9: /* create dynamic memory pool */ alpar@9: alpar@9: #define dmp_get_atom _glp_dmp_get_atom alpar@9: void *dmp_get_atom(DMP *pool, int size); alpar@9: /* get free atom from dynamic memory pool */ alpar@9: alpar@9: #define dmp_free_atom _glp_dmp_free_atom alpar@9: void dmp_free_atom(DMP *pool, void *atom, int size); alpar@9: /* return atom to dynamic memory pool */ alpar@9: alpar@9: #define dmp_in_use _glp_dmp_in_use alpar@9: glp_long dmp_in_use(DMP *pool); alpar@9: /* determine how many atoms are still in use */ alpar@9: alpar@9: #define dmp_delete_pool _glp_dmp_delete_pool alpar@9: void dmp_delete_pool(DMP *pool); alpar@9: /* delete dynamic memory pool */ alpar@9: alpar@9: #endif alpar@9: alpar@9: /* eof */