00001
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
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>
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;
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