Index: trunk/src_3rd/load_cache/load_cache.c =================================================================== --- trunk/src_3rd/load_cache/load_cache.c (revision 758) +++ trunk/src_3rd/load_cache/load_cache.c (revision 759) @@ -142,6 +142,39 @@ ldch_free_file(ctx, file); } +void ldch_unreg_low_parser(ldch_ctx_t *ctx, ldch_low_parser_t *low) +{ + if (low->unreg != NULL) + low->unreg(ctx, low); + free(low->name); + free(low); +} + +void ldch_unreg_high_parser(ldch_ctx_t *ctx, ldch_high_parser_t *high) +{ + if (high->unreg != NULL) + high->unreg(ctx, high); + free(high->name); + free(high); +} + +void ldch_uninit(ldch_ctx_t *ctx) +{ + htsp_entry_t *e; + + for(e = htsp_first(&ctx->files); e != NULL; e = htsp_next(&ctx->files, e)) + ldch_unload(ctx, e->value); + htsp_uninit(&ctx->files); + + for(e = htsp_first(&ctx->low_parsers); e != NULL; e = htsp_next(&ctx->low_parsers, e)) + ldch_unreg_low_parser(ctx, e->value); + htsp_uninit(&ctx->low_parsers); + + for(e = htsp_first(&ctx->high_parsers); e != NULL; e = htsp_next(&ctx->high_parsers, e)) + ldch_unreg_high_parser(ctx, e->value); + htsp_uninit(&ctx->high_parsers); +} + ldch_data_t *ldch_data_alloc(ldch_file_t *file, ldch_high_parser_t *high_parser, size_t payload_size) { ldch_data_t *data = calloc(sizeof(ldch_data_t) - 1 + payload_size, 1); Index: trunk/src_3rd/load_cache/load_cache.h =================================================================== --- trunk/src_3rd/load_cache/load_cache.h (revision 758) +++ trunk/src_3rd/load_cache/load_cache.h (revision 759) @@ -13,6 +13,7 @@ ldch_uid_t uid; ldch_file_t *(*parse)(ldch_low_parser_t *parser, void *call_ctx, const char *fn); void (*free_payload)(ldch_file_t *file); + void (*unreg)(ldch_ctx_t *ctx, ldch_low_parser_t *low); void *used_data; }; @@ -20,6 +21,7 @@ char *name; ldch_data_t *(*parse)(ldch_high_parser_t *parser, void *call_ctx, ldch_file_t *file, const char *fn); void (*free_payload)(ldch_data_t *data); + void (*unreg)(ldch_ctx_t *ctx, ldch_high_parser_t *high); void *used_data; }; @@ -50,6 +52,7 @@ void ldch_init(ldch_ctx_t *ctx); +void ldch_uninit(ldch_ctx_t *ctx); ldch_low_parser_t *ldch_reg_low_parser(ldch_ctx_t *ctx, const char *name); ldch_high_parser_t *ldch_reg_high_parser(ldch_ctx_t *ctx, const char *name);