Skip to content

Commit

Permalink
Store profile string in MOJOSHADER_parseData.
Browse files Browse the repository at this point in the history
--HG--
branch : trunk
  • Loading branch information
icculus committed Apr 23, 2008
1 parent 1968a87 commit 40763a8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 4 additions & 1 deletion mojoshader.c
Expand Up @@ -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";
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down
7 changes: 6 additions & 1 deletion mojoshader.h
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
*/
Expand Down

0 comments on commit 40763a8

Please sign in to comment.