src/glpdmp.h
author Alpar Juttner <alpar@cs.elte.hu>
Mon, 06 Dec 2010 13:09:21 +0100
changeset 1 c445c931472f
permissions -rw-r--r--
Import glpk-4.45

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