Renamed internal_malloc() and internal_free().
authorRyan C. Gordon <icculus@icculus.org>
Sat, 07 Feb 2009 00:35:17 -0500
changeset 553 288ed486e5c3
parent 552 40ca33bd5f88
child 554 42dd28107cd8
Renamed internal_malloc() and internal_free(). This is to prevent namespace clash if we statically link MojoShader to an app.
mojoshader.c
mojoshader_assembler.c
mojoshader_internal.h
mojoshader_opengl.c
--- a/mojoshader.c	Thu Feb 05 12:39:19 2009 -0500
+++ b/mojoshader.c	Sat Feb 07 00:35:17 2009 -0500
@@ -237,6 +237,8 @@
 
 
 // Convenience functions for allocators...
+void *MOJOSHADER_internal_malloc(int bytes, void *d) { return malloc(bytes); }
+void MOJOSHADER_internal_free(void *ptr, void *d) { free(ptr); }
 
 MOJOSHADER_error MOJOSHADER_out_of_mem_error = { "Out of memory", NULL, -1 };
 MOJOSHADER_parseData MOJOSHADER_out_of_mem_data = {
@@ -6745,8 +6747,8 @@
                               const unsigned int swizcount,
                               MOJOSHADER_malloc m, MOJOSHADER_free f, void *d)
 {
-    if (m == NULL) m = internal_malloc;
-    if (f == NULL) f = internal_free;
+    if (m == NULL) m = MOJOSHADER_internal_malloc;
+    if (f == NULL) f = MOJOSHADER_internal_free;
 
     Context *ctx = (Context *) m(sizeof (Context), d);
     if (ctx == NULL)
@@ -6836,7 +6838,7 @@
 {
     if (ctx != NULL)
     {
-        MOJOSHADER_free f = ((ctx->free != NULL) ? ctx->free : internal_free);
+        MOJOSHADER_free f = ((ctx->free != NULL) ? ctx->free : MOJOSHADER_internal_free);
         void *d = ctx->malloc_data;
         if (ctx->output_bytes != NULL)
             f(d, ctx->output_bytes);
@@ -7289,8 +7291,8 @@
 
     retval->error_count = ctx->error_count;
     retval->errors = errors;
-    retval->malloc = (ctx->malloc == internal_malloc) ? NULL : ctx->malloc;
-    retval->free = (ctx->free == internal_free) ? NULL : ctx->free;
+    retval->malloc = (ctx->malloc == MOJOSHADER_internal_malloc) ? NULL : ctx->malloc;
+    retval->free = (ctx->free == MOJOSHADER_internal_free) ? NULL : ctx->free;
     retval->malloc_data = ctx->malloc_data;
 
     return retval;
@@ -7539,7 +7541,7 @@
     if ((data == NULL) || (data == &MOJOSHADER_out_of_mem_data))
         return;  // no-op.
 
-    MOJOSHADER_free f = (data->free == NULL) ? internal_free : data->free;
+    MOJOSHADER_free f = (data->free == NULL) ? MOJOSHADER_internal_free : data->free;
     void *d = data->malloc_data;
     int i;
 
--- a/mojoshader_assembler.c	Thu Feb 05 12:39:19 2009 -0500
+++ b/mojoshader_assembler.c	Sat Feb 07 00:35:17 2009 -0500
@@ -1704,8 +1704,8 @@
 static Context *build_context(const char *source, MOJOSHADER_malloc m,
                               MOJOSHADER_free f, void *d)
 {
-    if (m == NULL) m = internal_malloc;
-    if (f == NULL) f = internal_free;
+    if (m == NULL) m = MOJOSHADER_internal_malloc;
+    if (f == NULL) f = MOJOSHADER_internal_free;
 
     Context *ctx = (Context *) m(sizeof (Context), d);
     if (ctx == NULL)
@@ -1740,7 +1740,7 @@
 {
     if (ctx != NULL)
     {
-        MOJOSHADER_free f = ((ctx->free != NULL) ? ctx->free : internal_free);
+        MOJOSHADER_free f = ((ctx->free != NULL) ? ctx->free : MOJOSHADER_internal_free);
         void *d = ctx->malloc_data;
         free_error_list(f, d, ctx->errors);
         if (ctx->output != NULL)
@@ -1792,8 +1792,8 @@
         return &MOJOSHADER_out_of_mem_data;
 
     memset(retval, '\0', sizeof (MOJOSHADER_parseData));
-    retval->malloc = (ctx->malloc == internal_malloc) ? NULL : ctx->malloc;
-    retval->free = (ctx->free == internal_free) ? NULL : ctx->free;
+    retval->malloc = (ctx->malloc == MOJOSHADER_internal_malloc) ? NULL : ctx->malloc;
+    retval->free = (ctx->free == MOJOSHADER_internal_free) ? NULL : ctx->free;
     retval->malloc_data = ctx->malloc_data;
 
     retval->error_count = ctx->error_count;
--- a/mojoshader_internal.h	Thu Feb 05 12:39:19 2009 -0500
+++ b/mojoshader_internal.h	Sat Feb 07 00:35:17 2009 -0500
@@ -132,11 +132,11 @@
 // #define this to force app to supply an allocator, so there's no reference
 //  to the C runtime's malloc() and free()...
 #if MOJOSHADER_FORCE_ALLOCATOR
-#define internal_malloc NULL
-#define internal_free NULL
+#define MOJOSHADER_internal_malloc NULL
+#define MOJOSHADER_internal_free NULL
 #else
-static void *internal_malloc(int bytes, void *d) { return malloc(bytes); }
-static void internal_free(void *ptr, void *d) { free(ptr); }
+void *MOJOSHADER_internal_malloc(int bytes, void *d);
+void MOJOSHADER_internal_free(void *ptr, void *d);
 #endif
 
 // result modifiers.
--- a/mojoshader_opengl.c	Thu Feb 05 12:39:19 2009 -0500
+++ b/mojoshader_opengl.c	Sat Feb 07 00:35:17 2009 -0500
@@ -939,8 +939,8 @@
     MOJOSHADER_glContext *current_ctx = ctx;
     ctx = NULL;
 
-    if (m == NULL) m = internal_malloc;
-    if (f == NULL) f = internal_free;
+    if (m == NULL) m = MOJOSHADER_internal_malloc;
+    if (f == NULL) f = MOJOSHADER_internal_free;
 
     ctx = (MOJOSHADER_glContext *) m(sizeof (MOJOSHADER_glContext), d);
     if (ctx == NULL)