Store profile string in MOJOSHADER_parseData. trunk
authorRyan C. Gordon <icculus@icculus.org>
Wed, 23 Apr 2008 04:19:39 -0400
branchtrunk
changeset 187 1c709f65cf1b
parent 186 1658e8ce74ac
child 188 2b43d053d9cd
Store profile string in MOJOSHADER_parseData.
mojoshader.c
mojoshader.h
--- a/mojoshader.c	Tue Apr 22 06:07:36 2008 -0400
+++ b/mojoshader.c	Wed Apr 23 04:19:39 2008 -0400
@@ -430,7 +430,7 @@
 
 
 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 @@
     } // 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 @@
     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);
 
--- a/mojoshader.h	Tue Apr 22 06:07:36 2008 -0400
+++ b/mojoshader.h	Wed Apr 23 04:19:39 2008 -0400
@@ -147,6 +147,11 @@
     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.
      *  Will be NULL on error.
@@ -280,7 +285,7 @@
  *  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.
  */