From 40763a8fe98400b28b7d840e7faa909a10af99ef Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Wed, 23 Apr 2008 04:19:39 -0400 Subject: [PATCH] Store profile string in MOJOSHADER_parseData. --HG-- branch : trunk --- mojoshader.c | 5 ++++- mojoshader.h | 7 ++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/mojoshader.c b/mojoshader.c index 79d24c0f..da35f412 100644 --- a/mojoshader.c +++ b/mojoshader.c @@ -430,7 +430,7 @@ static inline int isfail(const Context *ctx) static MOJOSHADER_parseData out_of_mem_data = { - "Out of memory", 0, 0, 0, MOJOSHADER_TYPE_UNKNOWN, 0, 0, 0, 0 + "Out of memory", 0, 0, 0, 0, MOJOSHADER_TYPE_UNKNOWN, 0, 0, 0, 0 }; static const char *out_of_mem_str = "Out of memory"; @@ -4659,6 +4659,7 @@ static MOJOSHADER_parseData *build_parsedata(Context *ctx) } // if else { + retval->profile = ctx->profile->name; retval->output = output; retval->output_len = ctx->output_len; retval->instruction_count = ctx->instruction_count; @@ -4825,6 +4826,8 @@ void MOJOSHADER_freeParseData(const MOJOSHADER_parseData *_data) MOJOSHADER_free f = (data->free == NULL) ? internal_free : data->free; void *d = data->malloc_data; + // we don't f(data->profile), because that's internal static data. + if (data->output != NULL) // check for NULL in case of dumb free() impl. f((void *) data->output, d); diff --git a/mojoshader.h b/mojoshader.h index 4ff4c1ed..57b6c427 100644 --- a/mojoshader.h +++ b/mojoshader.h @@ -146,6 +146,11 @@ typedef struct */ const char *error; + /* + * The name of the profile used to parse the shader. Will be NULL on error. + */ + const char *profile; + /* * Bytes of output from parsing. Most profiles produce a string of source * code, but profiles that do binary output may not be text at all. @@ -280,7 +285,7 @@ typedef struct * MOJOSHADER_parseData object, which is still safe to pass to * MOJOSHADER_freeParseData()). * - * This function is thread safe, so long (m) and (f) are too, and that + * This function is thread safe, so long as (m) and (f) are too, and that * (tokenbuf) remains intact for the duration of the call. This allows you * to parse several shaders on separate CPU cores at the same time. */