diff options
author | Michal Krol <michal@vmware.com> | 2009-09-18 11:19:25 +0200 |
---|---|---|
committer | Michal Krol <michal@vmware.com> | 2009-09-18 11:19:25 +0200 |
commit | 95956bb8cb9513c429b9749426720be94f4cf5a8 (patch) | |
tree | ec7396e2766d2f5b415d3224f8c28bcc5a80ebe3 /src/glsl/pp/sl_pp_context.c | |
parent | 2a661c383fee65bc4413541e706925fa3e9b9cf5 (diff) |
glsl/pp: Define a public interface for external modules.
Make sl_pp_context struct opaque.
Move all public declarations to sl_pp_public.h.
Diffstat (limited to 'src/glsl/pp/sl_pp_context.c')
-rw-r--r-- | src/glsl/pp/sl_pp_context.c | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/src/glsl/pp/sl_pp_context.c b/src/glsl/pp/sl_pp_context.c index b196d8102a..fd205de5d3 100644 --- a/src/glsl/pp/sl_pp_context.c +++ b/src/glsl/pp/sl_pp_context.c @@ -26,17 +26,23 @@ **************************************************************************/ #include <stdlib.h> +#include "sl_pp_public.h" #include "sl_pp_context.h" -int -sl_pp_context_init(struct sl_pp_context *context) +struct sl_pp_context * +sl_pp_context_create(void) { - memset(context, 0, sizeof(struct sl_pp_context)); + struct sl_pp_context *context; + + context = calloc(1, sizeof(struct sl_pp_context)); + if (!context) { + return NULL; + } if (sl_pp_dict_init(context)) { sl_pp_context_destroy(context); - return -1; + return NULL; } context->macro_tail = &context->macro; @@ -46,14 +52,23 @@ sl_pp_context_init(struct sl_pp_context *context) context->line = 1; context->file = 0; - return 0; + return context; } void sl_pp_context_destroy(struct sl_pp_context *context) { - free(context->cstr_pool); - sl_pp_macro_free(context->macro); + if (context) { + free(context->cstr_pool); + sl_pp_macro_free(context->macro); + free(context); + } +} + +const char * +sl_pp_context_error_message(const struct sl_pp_context *context) +{ + return context->error_msg; } int |