From 699bb516340166f75ffced6cfd361cedc0b7dbb0 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Mon, 8 Feb 2010 03:30:48 -0500 Subject: [PATCH] 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. --HG-- branch : calculator-experiment --- mojoshader_preprocessor.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mojoshader_preprocessor.c b/mojoshader_preprocessor.c index 48daf3f3..f465b2aa 100644 --- a/mojoshader_preprocessor.c +++ b/mojoshader_preprocessor.c @@ -656,8 +656,6 @@ Preprocessor *preprocessor_start(const char *fname, const char *source, // 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 @@ static void handle_pp_include(Context *ctx) 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))