From 9671da55435f3af8b1dc4864eb80fd59c9cc0f14 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Tue, 2 Nov 2010 14:55:10 -0400 Subject: [PATCH] Don't free the string cache in MOJOSHADER_parseAst()...the AST itself needs it! --- mojoshader.h | 5 +++++ mojoshader_compiler.c | 8 +++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/mojoshader.h b/mojoshader.h index 912d966d..578efbf3 100644 --- a/mojoshader.h +++ b/mojoshader.h @@ -1517,6 +1517,11 @@ typedef struct MOJOSHADER_astData * This is the pointer you passed as opaque data for your allocator. */ void *malloc_data; + + /* + * This is internal data, and not for the application to touch. + */ + void *strcache; } MOJOSHADER_astData; diff --git a/mojoshader_compiler.c b/mojoshader_compiler.c index 0ef228e7..bd766b9c 100644 --- a/mojoshader_compiler.c +++ b/mojoshader_compiler.c @@ -2365,7 +2365,7 @@ static void parse_source(Context *ctx, const char *filename, static MOJOSHADER_astData MOJOSHADER_out_of_mem_ast_data = { - 1, &MOJOSHADER_out_of_mem_error, 0, 0, 0, 0, 0 + 1, &MOJOSHADER_out_of_mem_error, 0, 0, 0, 0, 0, 0 }; // !!! FIXME: cut and paste from assembler. @@ -2459,6 +2459,9 @@ static const MOJOSHADER_astData *build_astdata(Context *ctx) retval->free = (ctx->free == MOJOSHADER_internal_free) ? NULL : ctx->free; retval->malloc_data = ctx->malloc_data; + retval->strcache = ctx->strcache; + ctx->strcache = NULL; + return retval; } // build_astdata @@ -2665,6 +2668,9 @@ void MOJOSHADER_freeAstData(const MOJOSHADER_astData *_data) (MOJOSHADER_astCompilationUnit *) &data->ast->compunit); } // if + if (data->strcache != NULL) + stringcache_destroy((StringCache *) data->strcache); + f(data, d); } // MOJOSHADER_freeAstData