src/glpdmp.h
changeset 1 c445c931472f
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/glpdmp.h	Mon Dec 06 13:09:21 2010 +0100
     1.3 @@ -0,0 +1,80 @@
     1.4 +/* glpdmp.h (dynamic memory pool) */
     1.5 +
     1.6 +/***********************************************************************
     1.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
     1.8 +*
     1.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
    1.10 +*  2009, 2010 Andrew Makhorin, Department for Applied Informatics,
    1.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
    1.12 +*  E-mail: <mao@gnu.org>.
    1.13 +*
    1.14 +*  GLPK is free software: you can redistribute it and/or modify it
    1.15 +*  under the terms of the GNU General Public License as published by
    1.16 +*  the Free Software Foundation, either version 3 of the License, or
    1.17 +*  (at your option) any later version.
    1.18 +*
    1.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
    1.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
    1.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
    1.22 +*  License for more details.
    1.23 +*
    1.24 +*  You should have received a copy of the GNU General Public License
    1.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
    1.26 +***********************************************************************/
    1.27 +
    1.28 +#ifndef GLPDMP_H
    1.29 +#define GLPDMP_H
    1.30 +
    1.31 +#include "glpenv.h"
    1.32 +
    1.33 +typedef struct DMP DMP;
    1.34 +
    1.35 +#define DMP_BLK_SIZE 8000
    1.36 +/* size of memory blocks, in bytes, allocated for memory pools */
    1.37 +
    1.38 +struct DMP
    1.39 +{     /* dynamic memory pool */
    1.40 +#if 0
    1.41 +      int size;
    1.42 +      /* size of atoms, in bytes, 1 <= size <= 256; if size = 0, atoms
    1.43 +         may have different sizes */
    1.44 +#endif
    1.45 +      void *avail[32];
    1.46 +      /* avail[k], 0 <= k <= 31, is a pointer to the first available
    1.47 +         (free) cell of (k+1)*8 bytes long; in the beginning of each
    1.48 +         free cell there is a pointer to another free cell of the same
    1.49 +         length */
    1.50 +      void *block;
    1.51 +      /* pointer to the most recently allocated memory block; in the
    1.52 +         beginning of each allocated memory block there is a pointer to
    1.53 +         the previously allocated memory block */
    1.54 +      int used;
    1.55 +      /* number of bytes used in the most recently allocated memory
    1.56 +         block */
    1.57 +      glp_long count;
    1.58 +      /* number of atoms which are currently in use */
    1.59 +};
    1.60 +
    1.61 +#define dmp_create_pool _glp_dmp_create_pool
    1.62 +DMP *dmp_create_pool(void);
    1.63 +/* create dynamic memory pool */
    1.64 +
    1.65 +#define dmp_get_atom _glp_dmp_get_atom
    1.66 +void *dmp_get_atom(DMP *pool, int size);
    1.67 +/* get free atom from dynamic memory pool */
    1.68 +
    1.69 +#define dmp_free_atom _glp_dmp_free_atom
    1.70 +void dmp_free_atom(DMP *pool, void *atom, int size);
    1.71 +/* return atom to dynamic memory pool */
    1.72 +
    1.73 +#define dmp_in_use _glp_dmp_in_use
    1.74 +glp_long dmp_in_use(DMP *pool);
    1.75 +/* determine how many atoms are still in use */
    1.76 +
    1.77 +#define dmp_delete_pool _glp_dmp_delete_pool
    1.78 +void dmp_delete_pool(DMP *pool);
    1.79 +/* delete dynamic memory pool */
    1.80 +
    1.81 +#endif
    1.82 +
    1.83 +/* eof */