Main Page | Modules | Class List | File List | Class Members | File Members

memory_stack.h

Go to the documentation of this file.
00001 
00014 /* This library is free software; you can redistribute it and/or
00015    modify it under the terms of the GNU Lesser General Public
00016    License as published by the Free Software Foundation; either
00017    version 2.1 of the License, or (at your option) any later version.
00018 
00019    This library is distributed in the hope that it will be useful,
00020    but WITHOUT ANY WARRANTY; without even the implied warranty of
00021    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00022    Lesser General Public License for more details.
00023 
00024    You should have received a copy of the GNU Lesser General Public
00025    License along with this library; if not, write to the Free Software
00026    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00027 */
00028 
00029 #ifndef _GAN_MEMORY_STACK_H
00030 #define _GAN_MEMORY_STACK_H
00031 
00032 #include <gandalf/common/misc_defs.h>
00033 #include <stddef.h> /* defines size_t */
00034 
00035 #ifdef __cplusplus
00036 extern "C" {
00037 #endif
00038 
00052 typedef double Gan_BigType;
00053 
00057 typedef struct Gan_MemoryStack
00058 {
00059    Gan_BigType **block_ptr, *last_free;
00060    size_t tm_bsize, tm_total;
00061    int current_tm_block, next_start, alloc_tm_blocks;
00062    int *block_end, max_tm_blocks;
00063    Gan_Bool squeeze_OK;
00064 
00065    Gan_Bool alloc; /* whether this structure was dynamically allocated */
00066 } Gan_MemoryStack;
00067 
00068  Gan_MemoryStack *gan_memory_stack_form ( Gan_MemoryStack *ms,
00069                                          int nblocks, size_t bsize );
00070  void *gan_ms_malloc ( Gan_MemoryStack *ms, size_t size );
00071  void  gan_ms_free ( Gan_MemoryStack *ms, void *ptr );
00072  void  gan_ms_free_va ( Gan_MemoryStack *ms, void *ptr, ... );
00073  void  gan_memory_stack_free ( Gan_MemoryStack *ms );
00074  void  gan_memory_stack_clean ( Gan_MemoryStack *ms );
00075  size_t gan_memory_stack_total ( Gan_MemoryStack *ms );
00076 
00083  Gan_MemoryStack *gan_memory_stack_alloc ( int nblocks, size_t bsize );
00084 
00097  void *gan_ms_malloc_object ( Gan_MemoryStack *ms, TYPE obj_type );
00098 
00112  void *gan_ms_malloc_array ( Gan_MemoryStack *ms, TYPE obj_type, size_t size );
00113 
00122 #ifdef __cplusplus
00123 }
00124 #endif
00125 
00126 #endif /* #ifndef _GAN_MEMORY_STACK_H */

Generated on Fri Mar 17 12:44:48 2006 by  doxygen 1.3.9.1