Index: trunk/src_3rd/load_cache/load_cache.c =================================================================== --- trunk/src_3rd/load_cache/load_cache.c (revision 760) +++ trunk/src_3rd/load_cache/load_cache.c (revision 761) @@ -9,8 +9,6 @@ #include "load_cache.h" -static void ldch_free_file_low(ldch_ctx_t *ctx, ldch_file_t *file); - char *ldch_strdup(const char *s) { int l = strlen(s); @@ -75,7 +73,35 @@ return htsp_get(&ctx->high_parsers, name); } +static void ldch_free_data(ldch_ctx_t *ctx, ldch_data_t *data) +{ + if (data->high_parser->free_payload != NULL) + data->high_parser->free_payload(data); + free(data); +} +static void ldch_free_file_low(ldch_ctx_t *ctx, ldch_file_t *file) +{ + long n; + + for(n = 0; n < file->data.used; n++) + ldch_free_data(ctx, file->data.array[n]); + + vtp0_uninit(&file->data); + + if (file->low_parser->free_payload != NULL) + file->low_parser->free_payload(file); +} + +static void ldch_free_file(ldch_ctx_t *ctx, ldch_file_t *file) +{ + ldch_free_file_low(ctx, file); + free(file->name); + free(file); +} + + + ldch_data_t *ldch_load_(ldch_ctx_t *ctx, const char *filename, ldch_low_parser_t *low, ldch_high_parser_t *high, void *low_call_ctx, void *high_call_ctx) { ldch_file_t *file = htsp_get(&ctx->files, filename); @@ -139,33 +165,6 @@ return ldch_load_(ctx, filename, low, high, low_call_ctx, high_call_ctx); } -static void ldch_free_data(ldch_ctx_t *ctx, ldch_data_t *data) -{ - if (data->high_parser->free_payload != NULL) - data->high_parser->free_payload(data); - free(data); -} - -static void ldch_free_file_low(ldch_ctx_t *ctx, ldch_file_t *file) -{ - long n; - - for(n = 0; n < file->data.used; n++) - ldch_free_data(ctx, file->data.array[n]); - - vtp0_uninit(&file->data); - - if (file->low_parser->free_payload != NULL) - file->low_parser->free_payload(file); -} - -static void ldch_free_file(ldch_ctx_t *ctx, ldch_file_t *file) -{ - ldch_free_file_low(ctx, file); - free(file->name); - free(file); -} - void ldch_unload(ldch_ctx_t *ctx, ldch_file_t *file) { htsp_pop(&ctx->files, file->name);