summaryrefslogtreecommitdiff
path: root/src/glsl/pp/sl_pp_macro.c
diff options
context:
space:
mode:
authorMichal Krol <michal@vmware.com>2009-06-22 09:14:14 +0200
committerMichal Krol <michal@vmware.com>2009-09-07 10:11:48 +0200
commit2dad8ed9d68289ba25a4023da12fc5ddf6a621dd (patch)
tree28a141fb7ae18ce6402c0079d9391aecaeb5b118 /src/glsl/pp/sl_pp_macro.c
parent6a11d4150cfcdd646c17f8b365b5481c2c583208 (diff)
glsl: Centralise sl_pp_macro constructor.
Diffstat (limited to 'src/glsl/pp/sl_pp_macro.c')
-rw-r--r--src/glsl/pp/sl_pp_macro.c29
1 files changed, 19 insertions, 10 deletions
diff --git a/src/glsl/pp/sl_pp_macro.c b/src/glsl/pp/sl_pp_macro.c
index 82591b9d77..0138270c67 100644
--- a/src/glsl/pp/sl_pp_macro.c
+++ b/src/glsl/pp/sl_pp_macro.c
@@ -30,13 +30,17 @@
#include "sl_pp_process.h"
-static void
-skip_whitespace(const struct sl_pp_token_info *input,
- unsigned int *pi)
+struct sl_pp_macro *
+sl_pp_macro_new(void)
{
- while (input[*pi].token == SL_PP_WHITESPACE) {
- (*pi)++;
+ struct sl_pp_macro *macro;
+
+ macro = calloc(1, sizeof(struct sl_pp_macro));
+ if (macro) {
+ macro->name = -1;
+ macro->num_args = -1;
}
+ return macro;
}
void
@@ -60,6 +64,15 @@ sl_pp_macro_free(struct sl_pp_macro *macro)
}
}
+static void
+skip_whitespace(const struct sl_pp_token_info *input,
+ unsigned int *pi)
+{
+ while (input[*pi].token == SL_PP_WHITESPACE) {
+ (*pi)++;
+ }
+}
+
int
sl_pp_macro_expand(struct sl_pp_context *context,
const struct sl_pp_token_info *input,
@@ -124,16 +137,12 @@ sl_pp_macro_expand(struct sl_pp_context *context,
unsigned int paren_nesting = 0;
unsigned int k;
- *pmacro = malloc(sizeof(struct sl_pp_macro));
+ *pmacro = sl_pp_macro_new();
if (!*pmacro) {
return -1;
}
(**pmacro).name = formal_arg->name;
- (**pmacro).num_args = -1;
- (**pmacro).arg = NULL;
- (**pmacro).body = NULL;
- (**pmacro).next = NULL;
body_len = 1;
for (i = *pi; !done; i++) {