Convert everything from the talloc API to the ralloc API.
This commit is contained in:
@@ -795,6 +795,10 @@ int glcpp_get_lineno (yyscan_t yyscanner );
|
||||
|
||||
void glcpp_set_lineno (int line_number ,yyscan_t yyscanner );
|
||||
|
||||
int glcpp_get_column (yyscan_t yyscanner );
|
||||
|
||||
void glcpp_set_column (int column_no ,yyscan_t yyscanner );
|
||||
|
||||
YYSTYPE * glcpp_get_lval (yyscan_t yyscanner );
|
||||
|
||||
void glcpp_set_lval (YYSTYPE * yylval_param ,yyscan_t yyscanner );
|
||||
@@ -954,7 +958,7 @@ YY_DECL
|
||||
|
||||
|
||||
/* Single-line comments */
|
||||
#line 958 "glcpp/glcpp-lex.c"
|
||||
#line 962 "glcpp/glcpp-lex.c"
|
||||
|
||||
yylval = yylval_param;
|
||||
|
||||
@@ -1121,7 +1125,7 @@ case 8:
|
||||
YY_RULE_SETUP
|
||||
#line 94 "glcpp/glcpp-lex.l"
|
||||
{
|
||||
yylval->str = talloc_strdup (yyextra, yytext);
|
||||
yylval->str = ralloc_strdup (yyextra, yytext);
|
||||
yyextra->space_tokens = 0;
|
||||
return HASH_VERSION;
|
||||
}
|
||||
@@ -1132,7 +1136,7 @@ case 9:
|
||||
YY_RULE_SETUP
|
||||
#line 102 "glcpp/glcpp-lex.l"
|
||||
{
|
||||
yylval->str = talloc_strdup (yyextra, yytext);
|
||||
yylval->str = ralloc_strdup (yyextra, yytext);
|
||||
yylineno++;
|
||||
yycolumn = 0;
|
||||
return OTHER;
|
||||
@@ -1312,7 +1316,7 @@ case 24:
|
||||
YY_RULE_SETUP
|
||||
#line 221 "glcpp/glcpp-lex.l"
|
||||
{
|
||||
yylval->str = talloc_strdup (yyextra, yytext);
|
||||
yylval->str = ralloc_strdup (yyextra, yytext);
|
||||
return INTEGER_STRING;
|
||||
}
|
||||
YY_BREAK
|
||||
@@ -1320,7 +1324,7 @@ case 25:
|
||||
YY_RULE_SETUP
|
||||
#line 226 "glcpp/glcpp-lex.l"
|
||||
{
|
||||
yylval->str = talloc_strdup (yyextra, yytext);
|
||||
yylval->str = ralloc_strdup (yyextra, yytext);
|
||||
return INTEGER_STRING;
|
||||
}
|
||||
YY_BREAK
|
||||
@@ -1328,7 +1332,7 @@ case 26:
|
||||
YY_RULE_SETUP
|
||||
#line 231 "glcpp/glcpp-lex.l"
|
||||
{
|
||||
yylval->str = talloc_strdup (yyextra, yytext);
|
||||
yylval->str = ralloc_strdup (yyextra, yytext);
|
||||
return INTEGER_STRING;
|
||||
}
|
||||
YY_BREAK
|
||||
@@ -1406,7 +1410,7 @@ case 37:
|
||||
YY_RULE_SETUP
|
||||
#line 276 "glcpp/glcpp-lex.l"
|
||||
{
|
||||
yylval->str = talloc_strdup (yyextra, yytext);
|
||||
yylval->str = ralloc_strdup (yyextra, yytext);
|
||||
return IDENTIFIER;
|
||||
}
|
||||
YY_BREAK
|
||||
@@ -1421,7 +1425,7 @@ case 39:
|
||||
YY_RULE_SETUP
|
||||
#line 285 "glcpp/glcpp-lex.l"
|
||||
{
|
||||
yylval->str = talloc_strdup (yyextra, yytext);
|
||||
yylval->str = ralloc_strdup (yyextra, yytext);
|
||||
return OTHER;
|
||||
}
|
||||
YY_BREAK
|
||||
@@ -1471,7 +1475,7 @@ YY_RULE_SETUP
|
||||
#line 319 "glcpp/glcpp-lex.l"
|
||||
ECHO;
|
||||
YY_BREAK
|
||||
#line 1475 "glcpp/glcpp-lex.c"
|
||||
#line 1479 "glcpp/glcpp-lex.c"
|
||||
case YY_STATE_EOF(DONE):
|
||||
case YY_STATE_EOF(COMMENT):
|
||||
case YY_STATE_EOF(UNREACHABLE):
|
||||
|
@@ -92,7 +92,7 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]?
|
||||
}
|
||||
|
||||
{HASH}version {
|
||||
yylval->str = talloc_strdup (yyextra, yytext);
|
||||
yylval->str = ralloc_strdup (yyextra, yytext);
|
||||
yyextra->space_tokens = 0;
|
||||
return HASH_VERSION;
|
||||
}
|
||||
@@ -100,7 +100,7 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]?
|
||||
/* glcpp doesn't handle #extension, #version, or #pragma directives.
|
||||
* Simply pass them through to the main compiler's lexer/parser. */
|
||||
{HASH}(extension|pragma)[^\n]+ {
|
||||
yylval->str = talloc_strdup (yyextra, yytext);
|
||||
yylval->str = ralloc_strdup (yyextra, yytext);
|
||||
yylineno++;
|
||||
yycolumn = 0;
|
||||
return OTHER;
|
||||
@@ -219,17 +219,17 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]?
|
||||
}
|
||||
|
||||
{DECIMAL_INTEGER} {
|
||||
yylval->str = talloc_strdup (yyextra, yytext);
|
||||
yylval->str = ralloc_strdup (yyextra, yytext);
|
||||
return INTEGER_STRING;
|
||||
}
|
||||
|
||||
{OCTAL_INTEGER} {
|
||||
yylval->str = talloc_strdup (yyextra, yytext);
|
||||
yylval->str = ralloc_strdup (yyextra, yytext);
|
||||
return INTEGER_STRING;
|
||||
}
|
||||
|
||||
{HEXADECIMAL_INTEGER} {
|
||||
yylval->str = talloc_strdup (yyextra, yytext);
|
||||
yylval->str = ralloc_strdup (yyextra, yytext);
|
||||
return INTEGER_STRING;
|
||||
}
|
||||
|
||||
@@ -274,7 +274,7 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]?
|
||||
}
|
||||
|
||||
{IDENTIFIER} {
|
||||
yylval->str = talloc_strdup (yyextra, yytext);
|
||||
yylval->str = ralloc_strdup (yyextra, yytext);
|
||||
return IDENTIFIER;
|
||||
}
|
||||
|
||||
@@ -283,7 +283,7 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]?
|
||||
}
|
||||
|
||||
{OTHER}+ {
|
||||
yylval->str = talloc_strdup (yyextra, yytext);
|
||||
yylval->str = ralloc_strdup (yyextra, yytext);
|
||||
return OTHER;
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -32,10 +32,6 @@
|
||||
#include "main/core.h" /* for struct gl_extensions */
|
||||
#include "main/mtypes.h" /* for gl_api enum */
|
||||
|
||||
#define glcpp_print(stream, str) stream = talloc_strdup_append(stream, str)
|
||||
#define glcpp_printf(stream, fmt, args, ...) \
|
||||
stream = talloc_asprintf_append(stream, fmt, args)
|
||||
|
||||
static void
|
||||
yyerror (YYLTYPE *locp, glcpp_parser_t *parser, const char *error);
|
||||
|
||||
@@ -79,7 +75,7 @@ _argument_list_length (argument_list_t *list);
|
||||
static token_list_t *
|
||||
_argument_list_member_at (argument_list_t *list, int index);
|
||||
|
||||
/* Note: This function talloc_steal()s the str pointer. */
|
||||
/* Note: This function ralloc_steal()s the str pointer. */
|
||||
static token_t *
|
||||
_token_create_str (void *ctx, int type, char *str);
|
||||
|
||||
@@ -89,7 +85,7 @@ _token_create_ival (void *ctx, int type, int ival);
|
||||
static token_list_t *
|
||||
_token_list_create (void *ctx);
|
||||
|
||||
/* Note: This function calls talloc_steal on token. */
|
||||
/* Note: This function calls ralloc_steal on token. */
|
||||
static void
|
||||
_token_list_append (token_list_t *list, token_t *token);
|
||||
|
||||
@@ -189,12 +185,12 @@ input:
|
||||
|
||||
line:
|
||||
control_line {
|
||||
glcpp_print(parser->output, "\n");
|
||||
ralloc_strcat (&parser->output, "\n");
|
||||
}
|
||||
| text_line {
|
||||
_glcpp_parser_print_expanded_token_list (parser, $1);
|
||||
glcpp_print(parser->output, "\n");
|
||||
talloc_free ($1);
|
||||
ralloc_strcat (&parser->output, "\n");
|
||||
ralloc_free ($1);
|
||||
}
|
||||
| expanded_line
|
||||
| HASH non_directive
|
||||
@@ -223,9 +219,9 @@ control_line:
|
||||
macro_t *macro = hash_table_find (parser->defines, $2);
|
||||
if (macro) {
|
||||
hash_table_remove (parser->defines, $2);
|
||||
talloc_free (macro);
|
||||
ralloc_free (macro);
|
||||
}
|
||||
talloc_free ($2);
|
||||
ralloc_free ($2);
|
||||
}
|
||||
| HASH_IF conditional_tokens NEWLINE {
|
||||
/* Be careful to only evaluate the 'if' expression if
|
||||
@@ -258,12 +254,12 @@ control_line:
|
||||
}
|
||||
| HASH_IFDEF IDENTIFIER junk NEWLINE {
|
||||
macro_t *macro = hash_table_find (parser->defines, $2);
|
||||
talloc_free ($2);
|
||||
ralloc_free ($2);
|
||||
_glcpp_parser_skip_stack_push_if (parser, & @1, macro != NULL);
|
||||
}
|
||||
| HASH_IFNDEF IDENTIFIER junk NEWLINE {
|
||||
macro_t *macro = hash_table_find (parser->defines, $2);
|
||||
talloc_free ($2);
|
||||
ralloc_free ($2);
|
||||
_glcpp_parser_skip_stack_push_if (parser, & @1, macro == NULL);
|
||||
}
|
||||
| HASH_ELIF conditional_tokens NEWLINE {
|
||||
@@ -310,7 +306,7 @@ control_line:
|
||||
macro_t *macro = hash_table_find (parser->defines, "__VERSION__");
|
||||
if (macro) {
|
||||
hash_table_remove (parser->defines, "__VERSION__");
|
||||
talloc_free (macro);
|
||||
ralloc_free (macro);
|
||||
}
|
||||
add_builtin_define (parser, "__VERSION__", $2);
|
||||
|
||||
@@ -325,7 +321,7 @@ control_line:
|
||||
if ($2 >= 130 || $2 == 100)
|
||||
add_builtin_define (parser, "GL_FRAGMENT_PRECISION_HIGH", 1);
|
||||
|
||||
glcpp_printf(parser->output, "#version %" PRIiMAX, $2);
|
||||
ralloc_asprintf_append (&parser->output, "#version %" PRIiMAX, $2);
|
||||
}
|
||||
| HASH NEWLINE
|
||||
;
|
||||
@@ -426,12 +422,12 @@ identifier_list:
|
||||
IDENTIFIER {
|
||||
$$ = _string_list_create (parser);
|
||||
_string_list_append_item ($$, $1);
|
||||
talloc_steal ($$, $1);
|
||||
ralloc_steal ($$, $1);
|
||||
}
|
||||
| identifier_list ',' IDENTIFIER {
|
||||
$$ = $1;
|
||||
_string_list_append_item ($$, $3);
|
||||
talloc_steal ($$, $3);
|
||||
ralloc_steal ($$, $3);
|
||||
}
|
||||
;
|
||||
|
||||
@@ -559,7 +555,7 @@ _string_list_create (void *ctx)
|
||||
{
|
||||
string_list_t *list;
|
||||
|
||||
list = talloc (ctx, string_list_t);
|
||||
list = ralloc (ctx, string_list_t);
|
||||
list->head = NULL;
|
||||
list->tail = NULL;
|
||||
|
||||
@@ -571,8 +567,8 @@ _string_list_append_item (string_list_t *list, const char *str)
|
||||
{
|
||||
string_node_t *node;
|
||||
|
||||
node = talloc (list, string_node_t);
|
||||
node->str = talloc_strdup (node, str);
|
||||
node = ralloc (list, string_node_t);
|
||||
node->str = ralloc_strdup (node, str);
|
||||
|
||||
node->next = NULL;
|
||||
|
||||
@@ -650,7 +646,7 @@ _argument_list_create (void *ctx)
|
||||
{
|
||||
argument_list_t *list;
|
||||
|
||||
list = talloc (ctx, argument_list_t);
|
||||
list = ralloc (ctx, argument_list_t);
|
||||
list->head = NULL;
|
||||
list->tail = NULL;
|
||||
|
||||
@@ -662,7 +658,7 @@ _argument_list_append (argument_list_t *list, token_list_t *argument)
|
||||
{
|
||||
argument_node_t *node;
|
||||
|
||||
node = talloc (list, argument_node_t);
|
||||
node = ralloc (list, argument_node_t);
|
||||
node->argument = argument;
|
||||
|
||||
node->next = NULL;
|
||||
@@ -713,15 +709,17 @@ _argument_list_member_at (argument_list_t *list, int index)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Note: This function talloc_steal()s the str pointer. */
|
||||
/* Note: This function ralloc_steal()s the str pointer. */
|
||||
token_t *
|
||||
_token_create_str (void *ctx, int type, char *str)
|
||||
{
|
||||
token_t *token;
|
||||
|
||||
token = talloc (ctx, token_t);
|
||||
token = ralloc (ctx, token_t);
|
||||
token->type = type;
|
||||
token->value.str = talloc_steal (token, str);
|
||||
token->value.str = str;
|
||||
|
||||
ralloc_steal (token, str);
|
||||
|
||||
return token;
|
||||
}
|
||||
@@ -731,7 +729,7 @@ _token_create_ival (void *ctx, int type, int ival)
|
||||
{
|
||||
token_t *token;
|
||||
|
||||
token = talloc (ctx, token_t);
|
||||
token = ralloc (ctx, token_t);
|
||||
token->type = type;
|
||||
token->value.ival = ival;
|
||||
|
||||
@@ -743,7 +741,7 @@ _token_list_create (void *ctx)
|
||||
{
|
||||
token_list_t *list;
|
||||
|
||||
list = talloc (ctx, token_list_t);
|
||||
list = ralloc (ctx, token_list_t);
|
||||
list->head = NULL;
|
||||
list->tail = NULL;
|
||||
list->non_space_tail = NULL;
|
||||
@@ -756,11 +754,12 @@ _token_list_append (token_list_t *list, token_t *token)
|
||||
{
|
||||
token_node_t *node;
|
||||
|
||||
node = talloc (list, token_node_t);
|
||||
node->token = talloc_steal (list, token);
|
||||
|
||||
node = ralloc (list, token_node_t);
|
||||
node->token = token;
|
||||
node->next = NULL;
|
||||
|
||||
ralloc_steal (list, token);
|
||||
|
||||
if (list->head == NULL) {
|
||||
list->head = node;
|
||||
} else {
|
||||
@@ -799,7 +798,7 @@ _token_list_copy (void *ctx, token_list_t *other)
|
||||
|
||||
copy = _token_list_create (ctx);
|
||||
for (node = other->head; node; node = node->next) {
|
||||
token_t *new_token = talloc (copy, token_t);
|
||||
token_t *new_token = ralloc (copy, token_t);
|
||||
*new_token = *node->token;
|
||||
_token_list_append (copy, new_token);
|
||||
}
|
||||
@@ -819,7 +818,7 @@ _token_list_trim_trailing_space (token_list_t *list)
|
||||
|
||||
while (tail) {
|
||||
next = tail->next;
|
||||
talloc_free (tail);
|
||||
ralloc_free (tail);
|
||||
tail = next;
|
||||
}
|
||||
}
|
||||
@@ -905,51 +904,51 @@ static void
|
||||
_token_print (char **out, token_t *token)
|
||||
{
|
||||
if (token->type < 256) {
|
||||
glcpp_printf (*out, "%c", token->type);
|
||||
ralloc_asprintf_append (out, "%c", token->type);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (token->type) {
|
||||
case INTEGER:
|
||||
glcpp_printf (*out, "%" PRIiMAX, token->value.ival);
|
||||
ralloc_asprintf_append (out, "%" PRIiMAX, token->value.ival);
|
||||
break;
|
||||
case IDENTIFIER:
|
||||
case INTEGER_STRING:
|
||||
case OTHER:
|
||||
glcpp_print (*out, token->value.str);
|
||||
ralloc_strcat (out, token->value.str);
|
||||
break;
|
||||
case SPACE:
|
||||
glcpp_print (*out, " ");
|
||||
ralloc_strcat (out, " ");
|
||||
break;
|
||||
case LEFT_SHIFT:
|
||||
glcpp_print (*out, "<<");
|
||||
ralloc_strcat (out, "<<");
|
||||
break;
|
||||
case RIGHT_SHIFT:
|
||||
glcpp_print (*out, ">>");
|
||||
ralloc_strcat (out, ">>");
|
||||
break;
|
||||
case LESS_OR_EQUAL:
|
||||
glcpp_print (*out, "<=");
|
||||
ralloc_strcat (out, "<=");
|
||||
break;
|
||||
case GREATER_OR_EQUAL:
|
||||
glcpp_print (*out, ">=");
|
||||
ralloc_strcat (out, ">=");
|
||||
break;
|
||||
case EQUAL:
|
||||
glcpp_print (*out, "==");
|
||||
ralloc_strcat (out, "==");
|
||||
break;
|
||||
case NOT_EQUAL:
|
||||
glcpp_print (*out, "!=");
|
||||
ralloc_strcat (out, "!=");
|
||||
break;
|
||||
case AND:
|
||||
glcpp_print (*out, "&&");
|
||||
ralloc_strcat (out, "&&");
|
||||
break;
|
||||
case OR:
|
||||
glcpp_print (*out, "||");
|
||||
ralloc_strcat (out, "||");
|
||||
break;
|
||||
case PASTE:
|
||||
glcpp_print (*out, "##");
|
||||
ralloc_strcat (out, "##");
|
||||
break;
|
||||
case COMMA_FINAL:
|
||||
glcpp_print (*out, ",");
|
||||
ralloc_strcat (out, ",");
|
||||
break;
|
||||
case PLACEHOLDER:
|
||||
/* Nothing to print. */
|
||||
@@ -960,7 +959,7 @@ _token_print (char **out, token_t *token)
|
||||
}
|
||||
}
|
||||
|
||||
/* Return a new token (talloc()ed off of 'token') formed by pasting
|
||||
/* Return a new token (ralloc()ed off of 'token') formed by pasting
|
||||
* 'token' and 'other'. Note that this function may return 'token' or
|
||||
* 'other' directly rather than allocating anything new.
|
||||
*
|
||||
@@ -1031,7 +1030,7 @@ _token_paste (glcpp_parser_t *parser, token_t *token, token_t *other)
|
||||
{
|
||||
char *str;
|
||||
|
||||
str = talloc_asprintf (token, "%s%s", token->value.str,
|
||||
str = ralloc_asprintf (token, "%s%s", token->value.str,
|
||||
other->value.str);
|
||||
combined = _token_create_str (token, token->type, str);
|
||||
combined->location = token->location;
|
||||
@@ -1039,11 +1038,11 @@ _token_paste (glcpp_parser_t *parser, token_t *token, token_t *other)
|
||||
}
|
||||
|
||||
glcpp_error (&token->location, parser, "");
|
||||
glcpp_print (parser->info_log, "Pasting \"");
|
||||
ralloc_strcat (&parser->info_log, "Pasting \"");
|
||||
_token_print (&parser->info_log, token);
|
||||
glcpp_print (parser->info_log, "\" and \"");
|
||||
ralloc_strcat (&parser->info_log, "\" and \"");
|
||||
_token_print (&parser->info_log, other);
|
||||
glcpp_print (parser->info_log, "\" does not give a valid preprocessing token.\n");
|
||||
ralloc_strcat (&parser->info_log, "\" does not give a valid preprocessing token.\n");
|
||||
|
||||
return token;
|
||||
}
|
||||
@@ -1085,7 +1084,7 @@ glcpp_parser_create (const struct gl_extensions *extensions, int api)
|
||||
glcpp_parser_t *parser;
|
||||
int language_version;
|
||||
|
||||
parser = talloc (NULL, glcpp_parser_t);
|
||||
parser = ralloc (NULL, glcpp_parser_t);
|
||||
|
||||
glcpp_lex_init_extra (parser, &parser->scanner);
|
||||
parser->defines = hash_table_ctor (32, hash_table_string_hash,
|
||||
@@ -1102,8 +1101,8 @@ glcpp_parser_create (const struct gl_extensions *extensions, int api)
|
||||
parser->lex_from_list = NULL;
|
||||
parser->lex_from_node = NULL;
|
||||
|
||||
parser->output = talloc_strdup(parser, "");
|
||||
parser->info_log = talloc_strdup(parser, "");
|
||||
parser->output = ralloc_strdup(parser, "");
|
||||
parser->info_log = ralloc_strdup(parser, "");
|
||||
parser->error = 0;
|
||||
|
||||
/* Add pre-defined macros. */
|
||||
@@ -1145,7 +1144,7 @@ glcpp_parser_destroy (glcpp_parser_t *parser)
|
||||
{
|
||||
glcpp_lex_destroy (parser->scanner);
|
||||
hash_table_dtor (parser->defines);
|
||||
talloc_free (parser);
|
||||
ralloc_free (parser);
|
||||
}
|
||||
|
||||
typedef enum function_status
|
||||
@@ -1316,7 +1315,7 @@ _glcpp_parser_expand_function (glcpp_parser_t *parser,
|
||||
|
||||
/* Replace a macro defined as empty with a SPACE token. */
|
||||
if (macro->replacements == NULL) {
|
||||
talloc_free (arguments);
|
||||
ralloc_free (arguments);
|
||||
return _token_list_create_with_one_space (parser);
|
||||
}
|
||||
|
||||
@@ -1472,7 +1471,7 @@ _glcpp_parser_expand_node (glcpp_parser_t *parser,
|
||||
token_list_t *expansion;
|
||||
token_t *final;
|
||||
|
||||
str = talloc_strdup (parser, token->value.str);
|
||||
str = ralloc_strdup (parser, token->value.str);
|
||||
final = _token_create_str (parser, OTHER, str);
|
||||
expansion = _token_list_create (parser);
|
||||
_token_list_append (expansion, final);
|
||||
@@ -1508,8 +1507,8 @@ _active_list_push (active_list_t *list,
|
||||
{
|
||||
active_list_t *node;
|
||||
|
||||
node = talloc (list, active_list_t);
|
||||
node->identifier = talloc_strdup (node, identifier);
|
||||
node = ralloc (list, active_list_t);
|
||||
node->identifier = ralloc_strdup (node, identifier);
|
||||
node->marker = marker;
|
||||
node->next = list;
|
||||
|
||||
@@ -1525,7 +1524,7 @@ _active_list_pop (active_list_t *list)
|
||||
return NULL;
|
||||
|
||||
node = list->next;
|
||||
talloc_free (list);
|
||||
ralloc_free (list);
|
||||
|
||||
return node;
|
||||
}
|
||||
@@ -1674,17 +1673,18 @@ _define_object_macro (glcpp_parser_t *parser,
|
||||
if (loc != NULL)
|
||||
_check_for_reserved_macro_name(parser, loc, identifier);
|
||||
|
||||
macro = talloc (parser, macro_t);
|
||||
macro = ralloc (parser, macro_t);
|
||||
|
||||
macro->is_function = 0;
|
||||
macro->parameters = NULL;
|
||||
macro->identifier = talloc_strdup (macro, identifier);
|
||||
macro->replacements = talloc_steal (macro, replacements);
|
||||
macro->identifier = ralloc_strdup (macro, identifier);
|
||||
macro->replacements = replacements;
|
||||
ralloc_steal (macro, replacements);
|
||||
|
||||
previous = hash_table_find (parser->defines, identifier);
|
||||
if (previous) {
|
||||
if (_macro_equal (macro, previous)) {
|
||||
talloc_free (macro);
|
||||
ralloc_free (macro);
|
||||
return;
|
||||
}
|
||||
glcpp_error (loc, parser, "Redefinition of macro %s\n",
|
||||
@@ -1705,17 +1705,18 @@ _define_function_macro (glcpp_parser_t *parser,
|
||||
|
||||
_check_for_reserved_macro_name(parser, loc, identifier);
|
||||
|
||||
macro = talloc (parser, macro_t);
|
||||
macro = ralloc (parser, macro_t);
|
||||
ralloc_steal (macro, parameters);
|
||||
ralloc_steal (macro, replacements);
|
||||
|
||||
macro->is_function = 1;
|
||||
macro->parameters = talloc_steal (macro, parameters);
|
||||
macro->identifier = talloc_strdup (macro, identifier);
|
||||
macro->replacements = talloc_steal (macro, replacements);
|
||||
|
||||
macro->parameters = parameters;
|
||||
macro->identifier = ralloc_strdup (macro, identifier);
|
||||
macro->replacements = replacements;
|
||||
previous = hash_table_find (parser->defines, identifier);
|
||||
if (previous) {
|
||||
if (_macro_equal (macro, previous)) {
|
||||
talloc_free (macro);
|
||||
ralloc_free (macro);
|
||||
return;
|
||||
}
|
||||
glcpp_error (loc, parser, "Redefinition of macro %s\n",
|
||||
@@ -1791,7 +1792,7 @@ glcpp_parser_lex (YYSTYPE *yylval, YYLTYPE *yylloc, glcpp_parser_t *parser)
|
||||
node = parser->lex_from_node;
|
||||
|
||||
if (node == NULL) {
|
||||
talloc_free (parser->lex_from_list);
|
||||
ralloc_free (parser->lex_from_list);
|
||||
parser->lex_from_list = NULL;
|
||||
return NEWLINE;
|
||||
}
|
||||
@@ -1820,13 +1821,13 @@ glcpp_parser_lex_from (glcpp_parser_t *parser, token_list_t *list)
|
||||
_token_list_append (parser->lex_from_list, node->token);
|
||||
}
|
||||
|
||||
talloc_free (list);
|
||||
ralloc_free (list);
|
||||
|
||||
parser->lex_from_node = parser->lex_from_list->head;
|
||||
|
||||
/* It's possible the list consisted of nothing but whitespace. */
|
||||
if (parser->lex_from_node == NULL) {
|
||||
talloc_free (parser->lex_from_list);
|
||||
ralloc_free (parser->lex_from_list);
|
||||
parser->lex_from_list = NULL;
|
||||
}
|
||||
}
|
||||
@@ -1841,7 +1842,7 @@ _glcpp_parser_skip_stack_push_if (glcpp_parser_t *parser, YYLTYPE *loc,
|
||||
if (parser->skip_stack)
|
||||
current = parser->skip_stack->type;
|
||||
|
||||
node = talloc (parser, skip_node_t);
|
||||
node = ralloc (parser, skip_node_t);
|
||||
node->loc = *loc;
|
||||
|
||||
if (current == SKIP_NO_SKIP) {
|
||||
@@ -1886,5 +1887,5 @@ _glcpp_parser_skip_stack_pop (glcpp_parser_t *parser, YYLTYPE *loc)
|
||||
|
||||
node = parser->skip_stack;
|
||||
parser->skip_stack = node->next;
|
||||
talloc_free (node);
|
||||
ralloc_free (node);
|
||||
}
|
||||
|
@@ -54,7 +54,7 @@ load_text_fd (void *ctx, int fd)
|
||||
while (1) {
|
||||
if (total_read + CHUNK + 1 > text_size) {
|
||||
text_size = text_size ? text_size * 2 : CHUNK + 1;
|
||||
text = talloc_realloc_size (ctx, text, text_size);
|
||||
text = reralloc_size (ctx, text, text_size);
|
||||
if (text == NULL) {
|
||||
fprintf (stderr, "Out of memory\n");
|
||||
return NULL;
|
||||
@@ -64,7 +64,7 @@ load_text_fd (void *ctx, int fd)
|
||||
if (bytes < 0) {
|
||||
fprintf (stderr, "Error while reading: %s\n",
|
||||
strerror (errno));
|
||||
talloc_free (text);
|
||||
ralloc_free (text);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -107,8 +107,8 @@ int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
char *filename = NULL;
|
||||
void *ctx = talloc(NULL, void*);
|
||||
char *info_log = talloc_strdup(ctx, "");
|
||||
void *ctx = ralloc(NULL, void*);
|
||||
char *info_log = ralloc_strdup(ctx, "");
|
||||
const char *shader;
|
||||
int ret;
|
||||
|
||||
@@ -125,7 +125,7 @@ main (int argc, char *argv[])
|
||||
printf("%s", shader);
|
||||
fprintf(stderr, "%s", info_log);
|
||||
|
||||
talloc_free(ctx);
|
||||
ralloc_free(ctx);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@@ -26,7 +26,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <talloc.h>
|
||||
#include "../ralloc.h"
|
||||
|
||||
#include "program/hash_table.h"
|
||||
|
||||
@@ -189,7 +189,7 @@ void
|
||||
glcpp_parser_destroy (glcpp_parser_t *parser);
|
||||
|
||||
int
|
||||
preprocess(void *talloc_ctx, const char **shader, char **info_log,
|
||||
preprocess(void *ralloc_ctx, const char **shader, char **info_log,
|
||||
const struct gl_extensions *extensions, int api);
|
||||
|
||||
/* Functions for writing to the info log */
|
||||
|
@@ -33,16 +33,15 @@ glcpp_error (YYLTYPE *locp, glcpp_parser_t *parser, const char *fmt, ...)
|
||||
va_list ap;
|
||||
|
||||
parser->error = 1;
|
||||
parser->info_log = talloc_asprintf_append(parser->info_log,
|
||||
"%u:%u(%u): "
|
||||
ralloc_asprintf_append(&parser->info_log, "%u:%u(%u): "
|
||||
"preprocessor error: ",
|
||||
locp->source,
|
||||
locp->first_line,
|
||||
locp->first_column);
|
||||
va_start(ap, fmt);
|
||||
parser->info_log = talloc_vasprintf_append(parser->info_log, fmt, ap);
|
||||
ralloc_vasprintf_append(&parser->info_log, fmt, ap);
|
||||
va_end(ap);
|
||||
parser->info_log = talloc_strdup_append(parser->info_log, "\n");
|
||||
ralloc_strcat(&parser->info_log, "\n");
|
||||
}
|
||||
|
||||
void
|
||||
@@ -50,16 +49,15 @@ glcpp_warning (YYLTYPE *locp, glcpp_parser_t *parser, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
parser->info_log = talloc_asprintf_append(parser->info_log,
|
||||
"%u:%u(%u): "
|
||||
ralloc_asprintf_append(&parser->info_log, "%u:%u(%u): "
|
||||
"preprocessor warning: ",
|
||||
locp->source,
|
||||
locp->first_line,
|
||||
locp->first_column);
|
||||
va_start(ap, fmt);
|
||||
parser->info_log = talloc_vasprintf_append(parser->info_log, fmt, ap);
|
||||
ralloc_vasprintf_append(&parser->info_log, fmt, ap);
|
||||
va_end(ap);
|
||||
parser->info_log = talloc_strdup_append(parser->info_log, "\n");
|
||||
ralloc_strcat(&parser->info_log, "\n");
|
||||
}
|
||||
|
||||
/* Searches backwards for '^ *#' from a given starting point. */
|
||||
@@ -92,7 +90,7 @@ remove_line_continuations(glcpp_parser_t *ctx, const char *shader)
|
||||
{
|
||||
int in_continued_line = 0;
|
||||
int extra_newlines = 0;
|
||||
char *clean = talloc_strdup(ctx, "");
|
||||
char *clean = ralloc_strdup(ctx, "");
|
||||
const char *search_start = shader;
|
||||
const char *newline;
|
||||
while ((newline = strchr(search_start, '\n')) != NULL) {
|
||||
@@ -122,27 +120,27 @@ remove_line_continuations(glcpp_parser_t *ctx, const char *shader)
|
||||
}
|
||||
if (in_continued_line) {
|
||||
/* Copy everything before the \ */
|
||||
clean = talloc_strndup_append(clean, shader, backslash - shader);
|
||||
ralloc_strncat(&clean, shader, backslash - shader);
|
||||
shader = newline + 1;
|
||||
extra_newlines++;
|
||||
}
|
||||
} else if (in_continued_line) {
|
||||
/* Copy everything up to and including the \n */
|
||||
clean = talloc_strndup_append(clean, shader, newline - shader + 1);
|
||||
ralloc_strncat(&clean, shader, newline - shader + 1);
|
||||
shader = newline + 1;
|
||||
/* Output extra newlines to make line numbers match */
|
||||
for (; extra_newlines > 0; extra_newlines--)
|
||||
clean = talloc_strdup_append(clean, "\n");
|
||||
ralloc_strcat(&clean, "\n");
|
||||
in_continued_line = 0;
|
||||
}
|
||||
search_start = newline + 1;
|
||||
}
|
||||
clean = talloc_strdup_append(clean, shader);
|
||||
ralloc_strcat(&clean, shader);
|
||||
return clean;
|
||||
}
|
||||
|
||||
int
|
||||
preprocess(void *talloc_ctx, const char **shader, char **info_log,
|
||||
preprocess(void *ralloc_ctx, const char **shader, char **info_log,
|
||||
const struct gl_extensions *extensions, int api)
|
||||
{
|
||||
int errors;
|
||||
@@ -156,9 +154,9 @@ preprocess(void *talloc_ctx, const char **shader, char **info_log,
|
||||
if (parser->skip_stack)
|
||||
glcpp_error (&parser->skip_stack->loc, parser, "Unterminated #if\n");
|
||||
|
||||
*info_log = talloc_strdup_append(*info_log, parser->info_log);
|
||||
ralloc_strcat(info_log, parser->info_log);
|
||||
|
||||
talloc_steal(talloc_ctx, parser->output);
|
||||
ralloc_steal(ralloc_ctx, parser->output);
|
||||
*shader = parser->output;
|
||||
|
||||
errors = parser->error;
|
||||
|
Reference in New Issue
Block a user