Make #include callbacks optional.
Now fails at runtime if we hit an #include without callbacks defined. If
we never need the callbacks, it's silly to assert they must exist.
--- a/mojoshader_preprocessor.c Mon Feb 08 03:04:29 2010 -0500
+++ b/mojoshader_preprocessor.c Mon Feb 08 03:30:48 2010 -0500
@@ -656,8 +656,6 @@
// the preprocessor is internal-only, so we verify all these are != NULL.
assert(m != NULL);
assert(f != NULL);
- assert(open_callback != NULL);
- assert(close_callback != NULL);
Context *ctx = (Context *) m(sizeof (Context), d);
if (ctx == NULL)
@@ -837,6 +835,12 @@
const char *newdata = NULL;
unsigned int newbytes = 0;
+ if ((ctx->open_callback == NULL) || (ctx->close_callback == NULL))
+ {
+ fail(ctx, "Saw #include, but no include callbacks defined");
+ return;
+ } // if
+
if (!ctx->open_callback(incltype, filename, state->source_base,
&newdata, &newbytes, ctx->malloc,
ctx->free, ctx->malloc_data))