Index: load_cache/load_cache.c =================================================================== --- load_cache/load_cache.c (revision 795) +++ load_cache/load_cache.c (revision 796) @@ -43,6 +43,7 @@ return NULL; p = calloc(sizeof(ldch_low_parser_t), 1); + p->ctx = ctx; p->name = ldch_strdup(name); p->uid = ctx->next_low_uid++; htsp_set(&ctx->low_parsers, p->name, p); @@ -58,6 +59,7 @@ return NULL; p = calloc(sizeof(ldch_high_parser_t), 1); + p->ctx = ctx; p->name = ldch_strdup(name); htsp_set(&ctx->high_parsers, p->name, p); return p; @@ -90,7 +92,7 @@ vtp0_uninit(&file->data); if (file->low_parser->free_payload != NULL) - file->low_parser->free_payload(file); + file->low_parser->free_payload(file->low_parser, file); } static void ldch_free_file(ldch_ctx_t *ctx, ldch_file_t *file) @@ -187,10 +189,10 @@ ldch_free_file(ctx, file); } -void ldch_unreg_low_parser(ldch_ctx_t *ctx, ldch_low_parser_t *low) +void ldch_unreg_low_parser(ldch_low_parser_t *low) { if (low->unreg != NULL) - low->unreg(ctx, low); + low->unreg(low); free(low->name); free(low); } @@ -198,7 +200,7 @@ void ldch_unreg_high_parser(ldch_ctx_t *ctx, ldch_high_parser_t *high) { if (high->unreg != NULL) - high->unreg(ctx, high); + high->unreg(high); free(high->name); free(high); } @@ -212,7 +214,7 @@ 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); + ldch_unreg_low_parser(e->value); htsp_uninit(&ctx->low_parsers); for(e = htsp_first(&ctx->high_parsers); e != NULL; e = htsp_next(&ctx->high_parsers, e)) Index: load_cache/load_cache.h =================================================================== --- load_cache/load_cache.h (revision 795) +++ load_cache/load_cache.h (revision 796) @@ -13,8 +13,9 @@ ldch_uid_t uid; ldch_file_t *(*parse_alloc)(ldch_low_parser_t *parser, void *call_ctx, const char *fn); /* called when the file is first loaded; should allocate (ldch_file_t *) */ int (*parse)(ldch_low_parser_t *parser, void *call_ctx, ldch_file_t *file, const char *fn); /* called after parse_alloc() on initial load or after free_payload() on reload */ - void (*free_payload)(ldch_file_t *file); /* should free the in-memory document/parse-tree; a call to parse() may follow when reloading */ - void (*unreg)(ldch_ctx_t *ctx, ldch_low_parser_t *low); + void (*free_payload)(ldch_low_parser_t *low, ldch_file_t *file); /* should free the in-memory document/parse-tree; a call to parse() may follow when reloading */ + void (*unreg)(ldch_low_parser_t *low); + ldch_ctx_t *ctx; void *used_data; }; @@ -22,7 +23,8 @@ char *name; ldch_data_t *(*parse)(ldch_high_parser_t *parser, void *call_ctx, ldch_file_t *file); void (*free_payload)(ldch_data_t *data); - void (*unreg)(ldch_ctx_t *ctx, ldch_high_parser_t *high); + void (*unreg)(ldch_high_parser_t *high); + ldch_ctx_t *ctx; void *used_data; };