00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef _H5FLprivate_H
00029 #define _H5FLprivate_H
00030
00031
00032 #ifdef LATER
00033 #include "H5FLpublic.h"
00034 #endif
00035
00036
00037
00038
00039
00040 #if defined H5_NO_FREE_LISTS || defined H5_USING_MEMCHECKER
00041 #define H5_NO_REG_FREE_LISTS
00042 #define H5_NO_ARR_FREE_LISTS
00043 #define H5_NO_SEQ_FREE_LISTS
00044 #define H5_NO_BLK_FREE_LISTS
00045 #define H5_NO_FAC_FREE_LISTS
00046 #endif
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056 #ifdef H5FL_TRACK
00057
00058 #define H5FL_TRACK_INFO ,__FILE__, FUNC, __LINE__
00059
00060
00061 #define H5FL_TRACK_INFO_INT ,call_file, call_func, call_line
00062
00063
00064 #define H5FL_TRACK_PARAMS ,const char *call_file, const char *call_func, int call_line
00065
00066
00067 struct H5CS_t;
00068
00069
00070 typedef struct H5FL_track_t {
00071 struct H5CS_t *stack;
00072 char *file;
00073 char *func;
00074 int line;
00075 struct H5FL_track_t *next;
00076 struct H5FL_track_t *prev;
00077 } H5FL_track_t;
00078
00079
00080 #define H5FL_TRACK_SIZE sizeof(H5FL_track_t)
00081
00082 #else
00083 #define H5FL_TRACK_INFO
00084 #define H5FL_TRACK_INFO_INT
00085 #define H5FL_TRACK_PARAMS
00086 #define H5FL_TRACK_SIZE 0
00087 #endif
00088
00089
00090
00091
00092
00093
00094 typedef struct H5FL_reg_node_t {
00095 struct H5FL_reg_node_t *next;
00096 } H5FL_reg_node_t;
00097
00098
00099 typedef struct H5FL_reg_head_t {
00100 unsigned init;
00101 unsigned allocated;
00102 unsigned onlist;
00103 const char *name;
00104 size_t size;
00105 H5FL_reg_node_t *list;
00106 } H5FL_reg_head_t;
00107
00108
00109
00110
00111 #define H5FL_REG_NAME(t) H5_##t##_reg_free_list
00112 #ifndef H5_NO_REG_FREE_LISTS
00113
00114 #define H5FL_DEFINE_COMMON(t) H5FL_reg_head_t H5FL_REG_NAME(t)={0,0,0,#t,sizeof(t),NULL}
00115
00116
00117 #define H5FL_DEFINE(t) H5_DLL H5FL_DEFINE_COMMON(t)
00118
00119
00120 #define H5FL_EXTERN(t) H5_DLLVAR H5FL_reg_head_t H5FL_REG_NAME(t)
00121
00122
00123 #define H5FL_DEFINE_STATIC(t) static H5FL_DEFINE_COMMON(t)
00124
00125
00126 #define H5FL_MALLOC(t) (t *)H5FL_reg_malloc(&(H5FL_REG_NAME(t)) H5FL_TRACK_INFO)
00127
00128
00129 #define H5FL_CALLOC(t) (t *)H5FL_reg_calloc(&(H5FL_REG_NAME(t)) H5FL_TRACK_INFO)
00130
00131
00132 #define H5FL_FREE(t,obj) (t *)H5FL_reg_free(&(H5FL_REG_NAME(t)),obj)
00133
00134
00135
00136
00137
00138 #else
00139 #include "H5MMprivate.h"
00140
00141 #define H5FL_DEFINE_COMMON(t) int UNUSED H5FL_REG_NAME(t)
00142
00143 #define H5FL_DEFINE(t) H5_DLL H5FL_DEFINE_COMMON(t)
00144 #define H5FL_EXTERN(t) H5_DLLVAR H5FL_DEFINE_COMMON(t)
00145 #define H5FL_DEFINE_STATIC(t) static H5FL_DEFINE_COMMON(t)
00146 #define H5FL_MALLOC(t) (t *)H5MM_malloc(sizeof(t))
00147 #define H5FL_CALLOC(t) (t *)H5MM_calloc(sizeof(t))
00148 #define H5FL_FREE(t,obj) H5MM_xfree(obj)
00149 #endif
00150
00151
00152 typedef union H5FL_blk_list_t {
00153 size_t size;
00154 union H5FL_blk_list_t *next;
00155 double unused1;
00156 haddr_t unused2;
00157 } H5FL_blk_list_t;
00158
00159
00160 typedef struct H5FL_blk_node_t {
00161 size_t size;
00162 H5FL_blk_list_t *list;
00163 struct H5FL_blk_node_t *next;
00164 struct H5FL_blk_node_t *prev;
00165 } H5FL_blk_node_t;
00166
00167
00168 typedef struct H5FL_blk_head_t {
00169 unsigned init;
00170 unsigned allocated;
00171 unsigned onlist;
00172 size_t list_mem;
00173 const char *name;
00174 H5FL_blk_node_t *head;
00175 } H5FL_blk_head_t;
00176
00177
00178
00179
00180 #define H5FL_BLK_NAME(t) H5_##t##_blk_free_list
00181 #ifndef H5_NO_BLK_FREE_LISTS
00182
00183 #define H5FL_BLK_DEFINE_COMMON(t) H5FL_blk_head_t H5FL_BLK_NAME(t)={0,0,0,0,#t"_blk",NULL}
00184
00185
00186 #define H5FL_BLK_DEFINE(t) H5_DLL H5FL_BLK_DEFINE_COMMON(t)
00187
00188
00189 #define H5FL_BLK_EXTERN(t) H5_DLLVAR H5FL_blk_head_t H5FL_BLK_NAME(t)
00190
00191
00192 #define H5FL_BLK_DEFINE_STATIC(t) static H5FL_BLK_DEFINE_COMMON(t)
00193
00194
00195 #define H5FL_BLK_MALLOC(t,size) (uint8_t *)H5FL_blk_malloc(&(H5FL_BLK_NAME(t)),size H5FL_TRACK_INFO)
00196
00197
00198 #define H5FL_BLK_CALLOC(t,size) (uint8_t *)H5FL_blk_calloc(&(H5FL_BLK_NAME(t)),size H5FL_TRACK_INFO)
00199
00200
00201 #define H5FL_BLK_FREE(t,blk) (uint8_t *)H5FL_blk_free(&(H5FL_BLK_NAME(t)),blk)
00202
00203
00204 #define H5FL_BLK_REALLOC(t,blk,new_size) (uint8_t *)H5FL_blk_realloc(&(H5FL_BLK_NAME(t)),blk,new_size H5FL_TRACK_INFO)
00205
00206
00207 #define H5FL_BLK_AVAIL(t,size) H5FL_blk_free_block_avail(&(H5FL_BLK_NAME(t)),size)
00208
00209 #else
00210
00211 #define H5FL_BLK_DEFINE_COMMON(t) int UNUSED H5FL_BLK_NAME(t)
00212
00213 #define H5FL_BLK_DEFINE(t) H5_DLL H5FL_BLK_DEFINE_COMMON(t)
00214 #define H5FL_BLK_EXTERN(t) H5_DLLVAR H5FL_BLK_DEFINE_COMMON(t)
00215 #define H5FL_BLK_DEFINE_STATIC(t) static H5FL_BLK_DEFINE_COMMON(t)
00216 #define H5FL_BLK_MALLOC(t,size) (uint8_t *)H5MM_malloc(size)
00217 #define H5FL_BLK_CALLOC(t,size) (uint8_t *)H5MM_calloc(size)
00218 #define H5FL_BLK_FREE(t,blk) H5MM_xfree(blk)
00219 #define H5FL_BLK_REALLOC(t,blk,new_size) (uint8_t *)H5MM_realloc(blk,new_size)
00220 #define H5FL_BLK_AVAIL(t,size) (FALSE)
00221 #endif
00222
00223
00224 typedef union H5FL_arr_list_t {
00225 union H5FL_arr_list_t *next;
00226 size_t nelem;
00227 double unused1;
00228 haddr_t unused2;
00229 } H5FL_arr_list_t;
00230
00231
00232 typedef struct H5FL_arr_node_t {
00233 size_t size;
00234 unsigned onlist;
00235 H5FL_arr_list_t *list;
00236 } H5FL_arr_node_t;
00237
00238
00239 typedef struct H5FL_arr_head_t {
00240 unsigned init;
00241 unsigned allocated;
00242 size_t list_mem;
00243 const char *name;
00244 int maxelem;
00245 size_t base_size;
00246 size_t elem_size;
00247 H5FL_arr_node_t *list_arr;
00248 } H5FL_arr_head_t;
00249
00250
00251
00252
00253 #define H5FL_ARR_NAME(t) H5_##t##_arr_free_list
00254 #ifndef H5_NO_ARR_FREE_LISTS
00255
00256 #define H5FL_ARR_DEFINE_COMMON(b,t,m) H5FL_arr_head_t H5FL_ARR_NAME(t)={0,0,0,#t"_arr",m+1,b,sizeof(t),NULL}
00257
00258
00259 #define H5FL_ARR_DEFINE(t,m) H5_DLL H5FL_ARR_DEFINE_COMMON(0,t,m)
00260
00261
00262 #define H5FL_BARR_DEFINE(b,t,m) H5_DLL H5FL_ARR_DEFINE_COMMON(sizeof(b),t,m)
00263
00264
00265 #define H5FL_ARR_EXTERN(t) H5_DLLVAR H5FL_arr_head_t H5FL_ARR_NAME(t)
00266
00267
00268 #define H5FL_ARR_DEFINE_STATIC(t,m) static H5FL_ARR_DEFINE_COMMON(0,t,m)
00269
00270
00271 #define H5FL_BARR_DEFINE_STATIC(b,t,m) static H5FL_ARR_DEFINE_COMMON(sizeof(b),t,m)
00272
00273
00274 #define H5FL_ARR_MALLOC(t,elem) H5FL_arr_malloc(&(H5FL_ARR_NAME(t)),elem)
00275
00276
00277 #define H5FL_ARR_CALLOC(t,elem) H5FL_arr_calloc(&(H5FL_ARR_NAME(t)),elem)
00278
00279
00280 #define H5FL_ARR_FREE(t,obj) H5FL_arr_free(&(H5FL_ARR_NAME(t)),obj)
00281
00282
00283 #define H5FL_ARR_REALLOC(t,obj,new_elem) H5FL_arr_realloc(&(H5FL_ARR_NAME(t)),obj,new_elem)
00284
00285 #else
00286
00287 #define H5FL_ARR_DEFINE_COMMON(t,m) size_t H5FL_ARR_NAME(t)
00288
00289 #define H5FL_ARR_DEFINE(t,m) H5_DLL H5FL_ARR_DEFINE_COMMON(t,m) = 0
00290 #define H5FL_BARR_DEFINE(b,t,m) H5_DLL H5FL_ARR_DEFINE_COMMON(t,m) = sizeof(b)
00291 #define H5FL_ARR_EXTERN(t) H5_DLLVAR H5FL_ARR_DEFINE_COMMON(t,m)
00292 #define H5FL_ARR_DEFINE_STATIC(t,m) static H5FL_ARR_DEFINE_COMMON(t,m) = 0
00293 #define H5FL_BARR_DEFINE_STATIC(b,t,m) static H5FL_ARR_DEFINE_COMMON(t,m) = sizeof(b)
00294 #define H5FL_ARR_MALLOC(t,elem) H5MM_malloc(H5FL_ARR_NAME(t) + ((elem)*sizeof(t)))
00295 #define H5FL_ARR_CALLOC(t,elem) H5MM_calloc(H5FL_ARR_NAME(t) + ((elem)*sizeof(t)))
00296 #define H5FL_ARR_FREE(t,obj) H5MM_xfree(obj)
00297 #define H5FL_ARR_REALLOC(t,obj,new_elem) H5MM_realloc(obj,H5FL_ARR_NAME(t) + ((new_elem)*sizeof(t)))
00298 #endif
00299
00300
00301 typedef struct H5FL_seq_head_t {
00302 H5FL_blk_head_t queue;
00303 size_t size;
00304 } H5FL_seq_head_t;
00305
00306
00307
00308
00309
00310
00311
00312 #define H5FL_SEQ_NAME(t) H5_##t##_seq_free_list
00313 #ifndef H5_NO_SEQ_FREE_LISTS
00314
00315 #define H5FL_SEQ_DEFINE_COMMON(t) H5FL_seq_head_t H5FL_SEQ_NAME(t)={{0,0,0,0,#t"_seq",NULL},sizeof(t)}
00316
00317
00318 #define H5FL_SEQ_DEFINE(t) H5_DLL H5FL_SEQ_DEFINE_COMMON(t)
00319
00320
00321 #define H5FL_SEQ_EXTERN(t) H5_DLLVAR H5FL_seq_head_t H5FL_SEQ_NAME(t)
00322
00323
00324 #define H5FL_SEQ_DEFINE_STATIC(t) static H5FL_SEQ_DEFINE_COMMON(t)
00325
00326
00327 #define H5FL_SEQ_MALLOC(t,elem) (t *)H5FL_seq_malloc(&(H5FL_SEQ_NAME(t)),elem H5FL_TRACK_INFO)
00328
00329
00330 #define H5FL_SEQ_CALLOC(t,elem) (t *)H5FL_seq_calloc(&(H5FL_SEQ_NAME(t)),elem H5FL_TRACK_INFO)
00331
00332
00333 #define H5FL_SEQ_FREE(t,obj) H5FL_seq_free(&(H5FL_SEQ_NAME(t)),obj)
00334
00335
00336 #define H5FL_SEQ_REALLOC(t,obj,new_elem) (t *)H5FL_seq_realloc(&(H5FL_SEQ_NAME(t)),obj,new_elem H5FL_TRACK_INFO)
00337
00338 #else
00339
00340 #define H5FL_SEQ_DEFINE_COMMON(t) int UNUSED H5FL_SEQ_NAME(t)
00341
00342 #define H5FL_SEQ_DEFINE(t) H5_DLL H5FL_SEQ_DEFINE_COMMON(t)
00343 #define H5FL_SEQ_EXTERN(t) H5_DLLVAR H5FL_SEQ_DEFINE_COMMON(t)
00344 #define H5FL_SEQ_DEFINE_STATIC(t) static H5FL_SEQ_DEFINE_COMMON(t)
00345 #define H5FL_SEQ_MALLOC(t,elem) (t *)H5MM_malloc((elem)*sizeof(t))
00346 #define H5FL_SEQ_CALLOC(t,elem) (t *)H5MM_calloc((elem)*sizeof(t))
00347 #define H5FL_SEQ_FREE(t,obj) H5MM_xfree(obj)
00348 #define H5FL_SEQ_REALLOC(t,obj,new_elem) (t *)H5MM_realloc(obj,(new_elem)*sizeof(t))
00349 #endif
00350
00351
00352 typedef struct H5FL_fac_head_t H5FL_fac_head_t;
00353
00354
00355
00356
00357
00358
00359
00360
00361 #ifndef H5_NO_FAC_FREE_LISTS
00362
00363 #define H5FL_FAC_MALLOC(t) H5FL_fac_malloc(t H5FL_TRACK_INFO)
00364
00365
00366 #define H5FL_FAC_CALLOC(t) H5FL_fac_calloc(t H5FL_TRACK_INFO)
00367
00368
00369 #define H5FL_FAC_FREE(t,obj) H5FL_fac_free(t,obj)
00370
00371 #else
00372 #define H5FL_FAC_MALLOC(t) H5MM_malloc(t->size)
00373 #define H5FL_FAC_CALLOC(t) H5MM_calloc(t->size)
00374 #define H5FL_FAC_FREE(t,obj) H5MM_xfree(obj)
00375 #endif
00376
00377
00378
00379
00380
00381 H5_DLL void * H5FL_blk_malloc(H5FL_blk_head_t *head, size_t size H5FL_TRACK_PARAMS);
00382 H5_DLL void * H5FL_blk_calloc(H5FL_blk_head_t *head, size_t size H5FL_TRACK_PARAMS);
00383 H5_DLL void * H5FL_blk_free(H5FL_blk_head_t *head, void *block);
00384 H5_DLL void * H5FL_blk_realloc(H5FL_blk_head_t *head, void *block, size_t new_size H5FL_TRACK_PARAMS);
00385 H5_DLL htri_t H5FL_blk_free_block_avail(H5FL_blk_head_t *head, size_t size);
00386
00387
00388 H5_DLL void * H5FL_reg_malloc(H5FL_reg_head_t *head H5FL_TRACK_PARAMS);
00389 H5_DLL void * H5FL_reg_calloc(H5FL_reg_head_t *head H5FL_TRACK_PARAMS);
00390 H5_DLL void * H5FL_reg_free(H5FL_reg_head_t *head, void *obj);
00391
00392
00393 H5_DLL void * H5FL_arr_malloc(H5FL_arr_head_t *head, size_t elem);
00394 H5_DLL void * H5FL_arr_calloc(H5FL_arr_head_t *head, size_t elem);
00395 H5_DLL void * H5FL_arr_free(H5FL_arr_head_t *head, void *obj);
00396 H5_DLL void * H5FL_arr_realloc(H5FL_arr_head_t *head, void *obj, size_t new_elem);
00397
00398
00399 H5_DLL void * H5FL_seq_malloc(H5FL_seq_head_t *head, size_t elem H5FL_TRACK_PARAMS);
00400 H5_DLL void * H5FL_seq_calloc(H5FL_seq_head_t *head, size_t elem H5FL_TRACK_PARAMS);
00401 H5_DLL void * H5FL_seq_free(H5FL_seq_head_t *head, void *obj);
00402 H5_DLL void * H5FL_seq_realloc(H5FL_seq_head_t *head, void *obj, size_t new_elem H5FL_TRACK_PARAMS);
00403
00404
00405 H5_DLL H5FL_fac_head_t *H5FL_fac_init(size_t size);
00406 H5_DLL void * H5FL_fac_malloc(H5FL_fac_head_t *head H5FL_TRACK_PARAMS);
00407 H5_DLL void * H5FL_fac_calloc(H5FL_fac_head_t *head H5FL_TRACK_PARAMS);
00408 H5_DLL void * H5FL_fac_free(H5FL_fac_head_t *head, void *obj);
00409 H5_DLL herr_t H5FL_fac_term(H5FL_fac_head_t *head);
00410
00411
00412 H5_DLL herr_t H5FL_garbage_coll(void);
00413 H5_DLL herr_t H5FL_set_free_list_limits(int reg_global_lim, int reg_list_lim,
00414 int arr_global_lim, int arr_list_lim, int blk_global_lim, int blk_list_lim,
00415 int fac_global_lim, int fac_list_lim);
00416 H5_DLL int H5FL_term_interface(void);
00417
00418 #endif