Skip to content

Commit

Permalink
Don't free the string cache in MOJOSHADER_parseAst()...the AST itself…
Browse files Browse the repository at this point in the history
… needs it!
  • Loading branch information
icculus committed Nov 2, 2010
1 parent 2ed55ea commit 9671da5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions mojoshader.h
Expand Up @@ -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;


Expand Down
8 changes: 7 additions & 1 deletion mojoshader_compiler.c
Expand Up @@ -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.
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 9671da5

Please sign in to comment.