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