summaryrefslogtreecommitdiffstats
path: root/src/glsl/apps/tokenise.c
diff options
context:
space:
mode:
authorMichal Krol <[email protected]>2009-06-17 13:49:06 +0200
committerMichal Krol <[email protected]>2009-09-07 10:11:43 +0200
commitf24322fbf6599b31f07ebc548e390c77b803d67c (patch)
treea550e9dd12bcceb9acc76bc677b645e4f1b21f17 /src/glsl/apps/tokenise.c
parentf24ec185c531d2b2209df01901c90eca57ca711f (diff)
glsl: Introduce sl_pp_context and maintain a reuseable pool of strings.
Diffstat (limited to 'src/glsl/apps/tokenise.c')
-rw-r--r--src/glsl/apps/tokenise.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/glsl/apps/tokenise.c b/src/glsl/apps/tokenise.c
index 2631b829986..b5092ba35f6 100644
--- a/src/glsl/apps/tokenise.c
+++ b/src/glsl/apps/tokenise.c
@@ -28,6 +28,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
+#include "../pp/sl_pp_context.h"
#include "../pp/sl_pp_purify.h"
#include "../pp/sl_pp_token.h"
@@ -41,6 +42,7 @@ main(int argc,
char *inbuf;
struct sl_pp_purify_options options;
char *outbuf;
+ struct sl_pp_context context;
struct sl_pp_token_info *tokens;
FILE *out;
unsigned int i;
@@ -82,7 +84,10 @@ main(int argc,
free(inbuf);
- if (sl_pp_tokenise(outbuf, &tokens)) {
+ sl_pp_context_init(&context);
+
+ if (sl_pp_tokenise(&context, outbuf, &tokens)) {
+ sl_pp_context_destroy(&context);
free(outbuf);
return 1;
}
@@ -91,6 +96,7 @@ main(int argc,
out = fopen(argv[2], "wb");
if (!out) {
+ sl_pp_context_destroy(&context);
free(tokens);
return 1;
}
@@ -289,13 +295,11 @@ main(int argc,
break;
case SL_PP_IDENTIFIER:
- fprintf(out, "%s ", tokens[i].data.identifier);
- free(tokens[i].data.identifier);
+ fprintf(out, "%s ", sl_pp_context_cstr(&context, tokens[i].data.identifier));
break;
case SL_PP_NUMBER:
- fprintf(out, "(%s) ", tokens[i].data.number);
- free(tokens[i].data.number);
+ fprintf(out, "(%s) ", sl_pp_context_cstr(&context, tokens[i].data.number));
break;
case SL_PP_OTHER:
@@ -311,6 +315,7 @@ main(int argc,
}
}
+ sl_pp_context_destroy(&context);
free(tokens);
fclose(out);