diff options
67 files changed, 590 insertions, 604 deletions
diff --git a/src/glsl/ast.h b/src/glsl/ast.h index b2e19169e9..878f48b207 100644 --- a/src/glsl/ast.h +++ b/src/glsl/ast.h @@ -49,23 +49,23 @@ struct YYLTYPE; */ class ast_node { public: - /* Callers of this talloc-based new need not call delete. It's - * easier to just talloc_free 'ctx' (or any of its ancestors). */ + /* Callers of this ralloc-based new need not call delete. It's + * easier to just ralloc_free 'ctx' (or any of its ancestors). */ static void* operator new(size_t size, void *ctx) { void *node; - node = talloc_zero_size(ctx, size); + node = rzalloc_size(ctx, size); assert(node != NULL); return node; } /* If the user *does* call delete, that's OK, we will just - * talloc_free in that case. */ + * ralloc_free in that case. */ static void operator delete(void *table) { - talloc_free(table); + ralloc_free(table); } /** diff --git a/src/glsl/ast_function.cpp b/src/glsl/ast_function.cpp index 3e5e345389..b3635bf686 100644 --- a/src/glsl/ast_function.cpp +++ b/src/glsl/ast_function.cpp @@ -66,7 +66,7 @@ process_parameters(exec_list *instructions, exec_list *actual_parameters, * formal or actual parameter list. Only the type is used. * * \return - * A talloced string representing the prototype of the function. + * A ralloced string representing the prototype of the function. */ char * prototype_string(const glsl_type *return_type, const char *name, @@ -75,19 +75,19 @@ prototype_string(const glsl_type *return_type, const char *name, char *str = NULL; if (return_type != NULL) - str = talloc_asprintf(str, "%s ", return_type->name); + ralloc_asprintf(&str, "%s ", return_type->name); - str = talloc_asprintf_append(str, "%s(", name); + ralloc_asprintf_append(&str, "%s(", name); const char *comma = ""; foreach_list(node, parameters) { const ir_instruction *const param = (ir_instruction *) node; - str = talloc_asprintf_append(str, "%s%s", comma, param->type->name); + ralloc_asprintf_append(&str, "%s%s", comma, param->type->name); comma = ", "; } - str = talloc_strdup_append(str, ")"); + ralloc_strcat(&str, ")"); return str; } @@ -188,7 +188,7 @@ match_function_by_name(exec_list *instructions, const char *name, ir_dereference_variable *deref; var = new(ctx) ir_variable(sig->return_type, - talloc_asprintf(ctx, "%s_retval", + ralloc_asprintf(ctx, "%s_retval", sig->function_name()), ir_var_temporary); instructions->push_tail(var); @@ -210,7 +210,7 @@ match_function_by_name(exec_list *instructions, const char *name, _mesa_glsl_error(loc, state, "no matching function for call to `%s'", str); - talloc_free(str); + ralloc_free(str); const char *prefix = "candidates are: "; @@ -226,7 +226,7 @@ match_function_by_name(exec_list *instructions, const char *name, str = prototype_string(sig->return_type, f->name, &sig->parameters); _mesa_glsl_error(loc, state, "%s%s\n", prefix, str); - talloc_free(str); + ralloc_free(str); prefix = " "; } @@ -247,7 +247,7 @@ match_function_by_name(exec_list *instructions, const char *name, static ir_rvalue * convert_component(ir_rvalue *src, const glsl_type *desired_type) { - void *ctx = talloc_parent(src); + void *ctx = ralloc_parent(src); const unsigned a = desired_type->base_type; const unsigned b = src->type->base_type; ir_expression *result = NULL; @@ -310,7 +310,7 @@ convert_component(ir_rvalue *src, const glsl_type *desired_type) static ir_rvalue * dereference_component(ir_rvalue *src, unsigned component) { - void *ctx = talloc_parent(src); + void *ctx = ralloc_parent(src); assert(component < src->type->components()); /* If the source is a constant, just create a new constant instead of a diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index df11a30c1a..75f28cd2c7 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -719,7 +719,7 @@ do_assignment(exec_list *instructions, struct _mesa_glsl_parse_state *state, static ir_rvalue * get_lvalue_copy(exec_list *instructions, ir_rvalue *lvalue) { - void *ctx = talloc_parent(lvalue); + void *ctx = ralloc_parent(lvalue); ir_variable *var; var = new(ctx) ir_variable(lvalue->type, "_post_incdec_tmp", @@ -3392,7 +3392,7 @@ ast_struct_specifier::hir(exec_list *instructions, * the types to HIR. This ensures that structure definitions embedded in * other structure definitions are processed. */ - glsl_struct_field *const fields = talloc_array(state, glsl_struct_field, + glsl_struct_field *const fields = ralloc_array(state, glsl_struct_field, decl_count); unsigned i = 0; diff --git a/src/glsl/builtins/tools/generate_builtins.py b/src/glsl/builtins/tools/generate_builtins.py index 3a938a022d..998ff512ab 100755 --- a/src/glsl/builtins/tools/generate_builtins.py +++ b/src/glsl/builtins/tools/generate_builtins.py @@ -178,7 +178,7 @@ read_builtins(GLenum target, const char *protos, const char **functions, unsigne if (st->error) { printf("error reading builtin: %.35s ...\\n", functions[i]); printf("Info log:\\n%s\\n", st->info_log); - talloc_free(sh); + ralloc_free(sh); return NULL; } } @@ -203,7 +203,7 @@ void *builtin_mem_ctx = NULL; void _mesa_glsl_release_functions(void) { - talloc_free(builtin_mem_ctx); + ralloc_free(builtin_mem_ctx); builtin_mem_ctx = NULL; memset(builtin_profiles, 0, sizeof(builtin_profiles)); } @@ -219,7 +219,7 @@ _mesa_read_profile(struct _mesa_glsl_parse_state *state, if (sh == NULL) { sh = read_builtins(GL_VERTEX_SHADER, prototypes, functions, count); - talloc_steal(builtin_mem_ctx, sh); + ralloc_steal(builtin_mem_ctx, sh); builtin_profiles[profile_index] = sh; } @@ -231,7 +231,7 @@ void _mesa_glsl_initialize_functions(struct _mesa_glsl_parse_state *state) { if (builtin_mem_ctx == NULL) { - builtin_mem_ctx = talloc_init("GLSL built-in functions"); + builtin_mem_ctx = ralloc_context(NULL); // "GLSL built-in functions" memset(&builtin_profiles, 0, sizeof(builtin_profiles)); } diff --git a/src/glsl/glcpp/glcpp-lex.c b/src/glsl/glcpp/glcpp-lex.c index 156af3008c..b53bea6271 100644 --- a/src/glsl/glcpp/glcpp-lex.c +++ b/src/glsl/glcpp/glcpp-lex.c @@ -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): diff --git a/src/glsl/glcpp/glcpp-lex.l b/src/glsl/glcpp/glcpp-lex.l index e936854cf2..11b73aea88 100644 --- a/src/glsl/glcpp/glcpp-lex.l +++ b/src/glsl/glcpp/glcpp-lex.l @@ -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; } diff --git a/src/glsl/glcpp/glcpp-parse.c b/src/glsl/glcpp/glcpp-parse.c index 8567bda1e5..da86ee7395 100644 --- a/src/glsl/glcpp/glcpp-parse.c +++ b/src/glsl/glcpp/glcpp-parse.c @@ -102,10 +102,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); @@ -149,7 +145,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); @@ -159,7 +155,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); @@ -216,7 +212,7 @@ add_builtin_define(glcpp_parser_t *parser, const char *name, int value); /* Line 189 of yacc.c */ -#line 220 "glcpp/glcpp-parse.c" +#line 216 "glcpp/glcpp-parse.c" /* Enabling traces. */ #ifndef YYDEBUG @@ -304,7 +300,7 @@ typedef struct YYLTYPE /* Line 264 of yacc.c */ -#line 308 "glcpp/glcpp-parse.c" +#line 304 "glcpp/glcpp-parse.c" #ifdef short # undef short @@ -629,17 +625,17 @@ static const yytype_int8 yyrhs[] = /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { - 0, 185, 185, 187, 191, 194, 199, 200, 204, 207, - 213, 216, 219, 222, 230, 249, 259, 264, 269, 288, - 303, 306, 309, 330, 334, 343, 348, 349, 352, 355, - 358, 361, 364, 367, 370, 373, 376, 379, 382, 385, - 388, 391, 394, 397, 405, 408, 411, 414, 417, 420, - 426, 431, 439, 440, 444, 450, 451, 454, 456, 463, - 467, 471, 476, 480, 487, 492, 499, 503, 507, 511, - 515, 522, 523, 524, 525, 526, 527, 528, 529, 530, - 531, 532, 533, 534, 535, 536, 537, 538, 539, 540, - 541, 542, 543, 544, 545, 546, 547, 548, 549, 550, - 551, 552 + 0, 181, 181, 183, 187, 190, 195, 196, 200, 203, + 209, 212, 215, 218, 226, 245, 255, 260, 265, 284, + 299, 302, 305, 326, 330, 339, 344, 345, 348, 351, + 354, 357, 360, 363, 366, 369, 372, 375, 378, 381, + 384, 387, 390, 393, 401, 404, 407, 410, 413, 416, + 422, 427, 435, 436, 440, 446, 447, 450, 452, 459, + 463, 467, 472, 476, 483, 488, 495, 499, 503, 507, + 511, 518, 519, 520, 521, 522, 523, 524, 525, 526, + 527, 528, 529, 530, 531, 532, 533, 534, 535, 536, + 537, 538, 539, 540, 541, 542, 543, 544, 545, 546, + 547, 548 }; #endif @@ -1608,7 +1604,7 @@ YYLTYPE yylloc; /* User initialization code. */ /* Line 1251 of yacc.c */ -#line 152 "glcpp/glcpp-parse.y" +#line 148 "glcpp/glcpp-parse.y" { yylloc.first_line = 1; yylloc.first_column = 1; @@ -1618,7 +1614,7 @@ YYLTYPE yylloc; } /* Line 1251 of yacc.c */ -#line 1622 "glcpp/glcpp-parse.c" +#line 1618 "glcpp/glcpp-parse.c" yylsp[0] = yylloc; goto yysetstate; @@ -1806,27 +1802,27 @@ yyreduce: case 4: /* Line 1464 of yacc.c */ -#line 191 "glcpp/glcpp-parse.y" +#line 187 "glcpp/glcpp-parse.y" { - glcpp_print(parser->output, "\n"); + ralloc_strcat (&parser->output, "\n"); ;} break; case 5: /* Line 1464 of yacc.c */ -#line 194 "glcpp/glcpp-parse.y" +#line 190 "glcpp/glcpp-parse.y" { _glcpp_parser_print_expanded_token_list (parser, (yyvsp[(1) - (1)].token_list)); - glcpp_print(parser->output, "\n"); - talloc_free ((yyvsp[(1) - (1)].token_list)); + ralloc_strcat (&parser->output, "\n"); + ralloc_free ((yyvsp[(1) - (1)].token_list)); ;} break; case 8: /* Line 1464 of yacc.c */ -#line 204 "glcpp/glcpp-parse.y" +#line 200 "glcpp/glcpp-parse.y" { _glcpp_parser_skip_stack_push_if (parser, & (yylsp[(1) - (3)]), (yyvsp[(2) - (3)].ival)); ;} @@ -1835,7 +1831,7 @@ yyreduce: case 9: /* Line 1464 of yacc.c */ -#line 207 "glcpp/glcpp-parse.y" +#line 203 "glcpp/glcpp-parse.y" { _glcpp_parser_skip_stack_change_if (parser, & (yylsp[(1) - (3)]), "elif", (yyvsp[(2) - (3)].ival)); ;} @@ -1844,7 +1840,7 @@ yyreduce: case 10: /* Line 1464 of yacc.c */ -#line 213 "glcpp/glcpp-parse.y" +#line 209 "glcpp/glcpp-parse.y" { _define_object_macro (parser, & (yylsp[(2) - (4)]), (yyvsp[(2) - (4)].str), (yyvsp[(3) - (4)].token_list)); ;} @@ -1853,7 +1849,7 @@ yyreduce: case 11: /* Line 1464 of yacc.c */ -#line 216 "glcpp/glcpp-parse.y" +#line 212 "glcpp/glcpp-parse.y" { _define_function_macro (parser, & (yylsp[(2) - (6)]), (yyvsp[(2) - (6)].str), NULL, (yyvsp[(5) - (6)].token_list)); ;} @@ -1862,7 +1858,7 @@ yyreduce: case 12: /* Line 1464 of yacc.c */ -#line 219 "glcpp/glcpp-parse.y" +#line 215 "glcpp/glcpp-parse.y" { _define_function_macro (parser, & (yylsp[(2) - (7)]), (yyvsp[(2) - (7)].str), (yyvsp[(4) - (7)].string_list), (yyvsp[(6) - (7)].token_list)); ;} @@ -1871,21 +1867,21 @@ yyreduce: case 13: /* Line 1464 of yacc.c */ -#line 222 "glcpp/glcpp-parse.y" +#line 218 "glcpp/glcpp-parse.y" { macro_t *macro = hash_table_find (parser->defines, (yyvsp[(2) - (3)].str)); if (macro) { hash_table_remove (parser->defines, (yyvsp[(2) - (3)].str)); - talloc_free (macro); + ralloc_free (macro); } - talloc_free ((yyvsp[(2) - (3)].str)); + ralloc_free ((yyvsp[(2) - (3)].str)); ;} break; case 14: /* Line 1464 of yacc.c */ -#line 230 "glcpp/glcpp-parse.y" +#line 226 "glcpp/glcpp-parse.y" { /* Be careful to only evaluate the 'if' expression if * we are not skipping. When we are skipping, we @@ -1910,7 +1906,7 @@ yyreduce: case 15: /* Line 1464 of yacc.c */ -#line 249 "glcpp/glcpp-parse.y" +#line 245 "glcpp/glcpp-parse.y" { /* #if without an expression is only an error if we * are not skipping */ @@ -1926,10 +1922,10 @@ yyreduce: case 16: /* Line 1464 of yacc.c */ -#line 259 "glcpp/glcpp-parse.y" +#line 255 "glcpp/glcpp-parse.y" { macro_t *macro = hash_table_find (parser->defines, (yyvsp[(2) - (4)].str)); - talloc_free ((yyvsp[(2) - (4)].str)); + ralloc_free ((yyvsp[(2) - (4)].str)); _glcpp_parser_skip_stack_push_if (parser, & (yylsp[(1) - (4)]), macro != NULL); ;} break; @@ -1937,10 +1933,10 @@ yyreduce: case 17: /* Line 1464 of yacc.c */ -#line 264 "glcpp/glcpp-parse.y" +#line 260 "glcpp/glcpp-parse.y" { macro_t *macro = hash_table_find (parser->defines, (yyvsp[(2) - (4)].str)); - talloc_free ((yyvsp[(2) - (4)].str)); + ralloc_free ((yyvsp[(2) - (4)].str)); _glcpp_parser_skip_stack_push_if (parser, & (yylsp[(1) - (4)]), macro == NULL); ;} break; @@ -1948,7 +1944,7 @@ yyreduce: case 18: /* Line 1464 of yacc.c */ -#line 269 "glcpp/glcpp-parse.y" +#line 265 "glcpp/glcpp-parse.y" { /* Be careful to only evaluate the 'elif' expression * if we are not skipping. When we are skipping, we @@ -1973,7 +1969,7 @@ yyreduce: case 19: /* Line 1464 of yacc.c */ -#line 288 "glcpp/glcpp-parse.y" +#line 284 "glcpp/glcpp-parse.y" { /* #elif without an expression is an error unless we * are skipping. */ @@ -1994,7 +1990,7 @@ yyreduce: case 20: /* Line 1464 of yacc.c */ -#line 303 "glcpp/glcpp-parse.y" +#line 299 "glcpp/glcpp-parse.y" { _glcpp_parser_skip_stack_change_if (parser, & (yylsp[(1) - (2)]), "else", 1); ;} @@ -2003,7 +1999,7 @@ yyreduce: case 21: /* Line 1464 of yacc.c */ -#line 306 "glcpp/glcpp-parse.y" +#line 302 "glcpp/glcpp-parse.y" { _glcpp_parser_skip_stack_pop (parser, & (yylsp[(1) - (2)])); ;} @@ -2012,12 +2008,12 @@ yyreduce: case 22: /* Line 1464 of yacc.c */ -#line 309 "glcpp/glcpp-parse.y" +#line 305 "glcpp/glcpp-parse.y" { 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__", (yyvsp[(2) - (3)].ival)); @@ -2032,14 +2028,14 @@ yyreduce: if ((yyvsp[(2) - (3)].ival) >= 130 || (yyvsp[(2) - (3)].ival) == 100) add_builtin_define (parser, "GL_FRAGMENT_PRECISION_HIGH", 1); - glcpp_printf(parser->output, "#version %" PRIiMAX, (yyvsp[(2) - (3)].ival)); + ralloc_asprintf_append (&parser->output, "#version %" PRIiMAX, (yyvsp[(2) - (3)].ival)); ;} break; case 24: /* Line 1464 of yacc.c */ -#line 334 "glcpp/glcpp-parse.y" +#line 330 "glcpp/glcpp-parse.y" { if (strlen ((yyvsp[(1) - (1)].str)) >= 3 && strncmp ((yyvsp[(1) - (1)].str), "0x", 2) == 0) { (yyval.ival) = strtoll ((yyvsp[(1) - (1)].str) + 2, NULL, 16); @@ -2054,7 +2050,7 @@ yyreduce: case 25: /* Line 1464 of yacc.c */ -#line 343 "glcpp/glcpp-parse.y" +#line 339 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (1)].ival); ;} @@ -2063,7 +2059,7 @@ yyreduce: case 27: /* Line 1464 of yacc.c */ -#line 349 "glcpp/glcpp-parse.y" +#line 345 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) || (yyvsp[(3) - (3)].ival); ;} @@ -2072,7 +2068,7 @@ yyreduce: case 28: /* Line 1464 of yacc.c */ -#line 352 "glcpp/glcpp-parse.y" +#line 348 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) && (yyvsp[(3) - (3)].ival); ;} @@ -2081,7 +2077,7 @@ yyreduce: case 29: /* Line 1464 of yacc.c */ -#line 355 "glcpp/glcpp-parse.y" +#line 351 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) | (yyvsp[(3) - (3)].ival); ;} @@ -2090,7 +2086,7 @@ yyreduce: case 30: /* Line 1464 of yacc.c */ -#line 358 "glcpp/glcpp-parse.y" +#line 354 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) ^ (yyvsp[(3) - (3)].ival); ;} @@ -2099,7 +2095,7 @@ yyreduce: case 31: /* Line 1464 of yacc.c */ -#line 361 "glcpp/glcpp-parse.y" +#line 357 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) & (yyvsp[(3) - (3)].ival); ;} @@ -2108,7 +2104,7 @@ yyreduce: case 32: /* Line 1464 of yacc.c */ -#line 364 "glcpp/glcpp-parse.y" +#line 360 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) != (yyvsp[(3) - (3)].ival); ;} @@ -2117,7 +2113,7 @@ yyreduce: case 33: /* Line 1464 of yacc.c */ -#line 367 "glcpp/glcpp-parse.y" +#line 363 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) == (yyvsp[(3) - (3)].ival); ;} @@ -2126,7 +2122,7 @@ yyreduce: case 34: /* Line 1464 of yacc.c */ -#line 370 "glcpp/glcpp-parse.y" +#line 366 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) >= (yyvsp[(3) - (3)].ival); ;} @@ -2135,7 +2131,7 @@ yyreduce: case 35: /* Line 1464 of yacc.c */ -#line 373 "glcpp/glcpp-parse.y" +#line 369 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) <= (yyvsp[(3) - (3)].ival); ;} @@ -2144,7 +2140,7 @@ yyreduce: case 36: /* Line 1464 of yacc.c */ -#line 376 "glcpp/glcpp-parse.y" +#line 372 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) > (yyvsp[(3) - (3)].ival); ;} @@ -2153,7 +2149,7 @@ yyreduce: case 37: /* Line 1464 of yacc.c */ -#line 379 "glcpp/glcpp-parse.y" +#line 375 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) < (yyvsp[(3) - (3)].ival); ;} @@ -2162,7 +2158,7 @@ yyreduce: case 38: /* Line 1464 of yacc.c */ -#line 382 "glcpp/glcpp-parse.y" +#line 378 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) >> (yyvsp[(3) - (3)].ival); ;} @@ -2171,7 +2167,7 @@ yyreduce: case 39: /* Line 1464 of yacc.c */ -#line 385 "glcpp/glcpp-parse.y" +#line 381 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) << (yyvsp[(3) - (3)].ival); ;} @@ -2180,7 +2176,7 @@ yyreduce: case 40: /* Line 1464 of yacc.c */ -#line 388 "glcpp/glcpp-parse.y" +#line 384 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) - (yyvsp[(3) - (3)].ival); ;} @@ -2189,7 +2185,7 @@ yyreduce: case 41: /* Line 1464 of yacc.c */ -#line 391 "glcpp/glcpp-parse.y" +#line 387 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) + (yyvsp[(3) - (3)].ival); ;} @@ -2198,7 +2194,7 @@ yyreduce: case 42: /* Line 1464 of yacc.c */ -#line 394 "glcpp/glcpp-parse.y" +#line 390 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) % (yyvsp[(3) - (3)].ival); ;} @@ -2207,7 +2203,7 @@ yyreduce: case 43: /* Line 1464 of yacc.c */ -#line 397 "glcpp/glcpp-parse.y" +#line 393 "glcpp/glcpp-parse.y" { if ((yyvsp[(3) - (3)].ival) == 0) { yyerror (& (yylsp[(1) - (3)]), parser, @@ -2221,7 +2217,7 @@ yyreduce: case 44: /* Line 1464 of yacc.c */ -#line 405 "glcpp/glcpp-parse.y" +#line 401 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) * (yyvsp[(3) - (3)].ival); ;} @@ -2230,7 +2226,7 @@ yyreduce: case 45: /* Line 1464 of yacc.c */ -#line 408 "glcpp/glcpp-parse.y" +#line 404 "glcpp/glcpp-parse.y" { (yyval.ival) = ! (yyvsp[(2) - (2)].ival); ;} @@ -2239,7 +2235,7 @@ yyreduce: case 46: /* Line 1464 of yacc.c */ -#line 411 "glcpp/glcpp-parse.y" +#line 407 "glcpp/glcpp-parse.y" { (yyval.ival) = ~ (yyvsp[(2) - (2)].ival); ;} @@ -2248,7 +2244,7 @@ yyreduce: case 47: /* Line 1464 of yacc.c */ -#line 414 "glcpp/glcpp-parse.y" +#line 410 "glcpp/glcpp-parse.y" { (yyval.ival) = - (yyvsp[(2) - (2)].ival); ;} @@ -2257,7 +2253,7 @@ yyreduce: case 48: /* Line 1464 of yacc.c */ -#line 417 "glcpp/glcpp-parse.y" +#line 413 "glcpp/glcpp-parse.y" { (yyval.ival) = + (yyvsp[(2) - (2)].ival); ;} @@ -2266,7 +2262,7 @@ yyreduce: case 49: /* Line 1464 of yacc.c */ -#line 420 "glcpp/glcpp-parse.y" +#line 416 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(2) - (3)].ival); ;} @@ -2275,36 +2271,36 @@ yyreduce: case 50: /* Line 1464 of yacc.c */ -#line 426 "glcpp/glcpp-parse.y" +#line 422 "glcpp/glcpp-parse.y" { (yyval.string_list) = _string_list_create (parser); _string_list_append_item ((yyval.string_list), (yyvsp[(1) - (1)].str)); - talloc_steal ((yyval.string_list), (yyvsp[(1) - (1)].str)); + ralloc_steal ((yyval.string_list), (yyvsp[(1) - (1)].str)); ;} break; case 51: /* Line 1464 of yacc.c */ -#line 431 "glcpp/glcpp-parse.y" +#line 427 "glcpp/glcpp-parse.y" { (yyval.string_list) = (yyvsp[(1) - (3)].string_list); _string_list_append_item ((yyval.string_list), (yyvsp[(3) - (3)].str)); - talloc_steal ((yyval.string_list), (yyvsp[(3) - (3)].str)); + ralloc_steal ((yyval.string_list), (yyvsp[(3) - (3)].str)); ;} break; case 52: /* Line 1464 of yacc.c */ -#line 439 "glcpp/glcpp-parse.y" +#line 435 "glcpp/glcpp-parse.y" { (yyval.token_list) = NULL; ;} break; case 54: /* Line 1464 of yacc.c */ -#line 444 "glcpp/glcpp-parse.y" +#line 440 "glcpp/glcpp-parse.y" { yyerror (& (yylsp[(1) - (2)]), parser, "Invalid tokens after #"); ;} @@ -2313,14 +2309,14 @@ yyreduce: case 55: /* Line 1464 of yacc.c */ -#line 450 "glcpp/glcpp-parse.y" +#line 446 "glcpp/glcpp-parse.y" { (yyval.token_list) = NULL; ;} break; case 58: /* Line 1464 of yacc.c */ -#line 456 "glcpp/glcpp-parse.y" +#line 452 "glcpp/glcpp-parse.y" { glcpp_warning(&(yylsp[(1) - (1)]), parser, "extra tokens at end of directive"); ;} @@ -2329,7 +2325,7 @@ yyreduce: case 59: /* Line 1464 of yacc.c */ -#line 463 "glcpp/glcpp-parse.y" +#line 459 "glcpp/glcpp-parse.y" { int v = hash_table_find (parser->defines, (yyvsp[(2) - (2)].str)) ? 1 : 0; (yyval.token) = _token_create_ival (parser, INTEGER, v); @@ -2339,7 +2335,7 @@ yyreduce: case 60: /* Line 1464 of yacc.c */ -#line 467 "glcpp/glcpp-parse.y" +#line 463 "glcpp/glcpp-parse.y" { int v = hash_table_find (parser->defines, (yyvsp[(3) - (4)].str)) ? 1 : 0; (yyval.token) = _token_create_ival (parser, INTEGER, v); @@ -2349,7 +2345,7 @@ yyreduce: case 62: /* Line 1464 of yacc.c */ -#line 476 "glcpp/glcpp-parse.y" +#line 472 "glcpp/glcpp-parse.y" { (yyval.token_list) = _token_list_create (parser); _token_list_append ((yyval.token_list), (yyvsp[(1) - (1)].token)); @@ -2359,7 +2355,7 @@ yyreduce: case 63: /* Line 1464 of yacc.c */ -#line 480 "glcpp/glcpp-parse.y" +#line 476 "glcpp/glcpp-parse.y" { (yyval.token_list) = (yyvsp[(1) - (2)].token_list); _token_list_append ((yyval.token_list), (yyvsp[(2) - (2)].token)); @@ -2369,7 +2365,7 @@ yyreduce: case 64: /* Line 1464 of yacc.c */ -#line 487 "glcpp/glcpp-parse.y" +#line 483 "glcpp/glcpp-parse.y" { parser->space_tokens = 1; (yyval.token_list) = _token_list_create (parser); @@ -2380,7 +2376,7 @@ yyreduce: case 65: /* Line 1464 of yacc.c */ -#line 492 "glcpp/glcpp-parse.y" +#line 488 "glcpp/glcpp-parse.y" { (yyval.token_list) = (yyvsp[(1) - (2)].token_list); _token_list_append ((yyval.token_list), (yyvsp[(2) - (2)].token)); @@ -2390,7 +2386,7 @@ yyreduce: case 66: /* Line 1464 of yacc.c */ -#line 499 "glcpp/glcpp-parse.y" +#line 495 "glcpp/glcpp-parse.y" { (yyval.token) = _token_create_str (parser, IDENTIFIER, (yyvsp[(1) - (1)].str)); (yyval.token)->location = yylloc; @@ -2400,7 +2396,7 @@ yyreduce: case 67: /* Line 1464 of yacc.c */ -#line 503 "glcpp/glcpp-parse.y" +#line 499 "glcpp/glcpp-parse.y" { (yyval.token) = _token_create_str (parser, INTEGER_STRING, (yyvsp[(1) - (1)].str)); (yyval.token)->location = yylloc; @@ -2410,7 +2406,7 @@ yyreduce: case 68: /* Line 1464 of yacc.c */ -#line 507 "glcpp/glcpp-parse.y" +#line 503 "glcpp/glcpp-parse.y" { (yyval.token) = _token_create_ival (parser, (yyvsp[(1) - (1)].ival), (yyvsp[(1) - (1)].ival)); (yyval.token)->location = yylloc; @@ -2420,7 +2416,7 @@ yyreduce: case 69: /* Line 1464 of yacc.c */ -#line 511 "glcpp/glcpp-parse.y" +#line 507 "glcpp/glcpp-parse.y" { (yyval.token) = _token_create_str (parser, OTHER, (yyvsp[(1) - (1)].str)); (yyval.token)->location = yylloc; @@ -2430,7 +2426,7 @@ yyreduce: case 70: /* Line 1464 of yacc.c */ -#line 515 "glcpp/glcpp-parse.y" +#line 511 "glcpp/glcpp-parse.y" { (yyval.token) = _token_create_ival (parser, SPACE, SPACE); (yyval.token)->location = yylloc; @@ -2440,224 +2436,224 @@ yyreduce: case 71: /* Line 1464 of yacc.c */ -#line 522 "glcpp/glcpp-parse.y" +#line 518 "glcpp/glcpp-parse.y" { (yyval.ival) = '['; ;} break; case 72: /* Line 1464 of yacc.c */ -#line 523 "glcpp/glcpp-parse.y" +#line 519 "glcpp/glcpp-parse.y" { (yyval.ival) = ']'; ;} break; case 73: /* Line 1464 of yacc.c */ -#line 524 "glcpp/glcpp-parse.y" +#line 520 "glcpp/glcpp-parse.y" { (yyval.ival) = '('; ;} break; case 74: /* Line 1464 of yacc.c */ -#line 525 "glcpp/glcpp-parse.y" +#line 521 "glcpp/glcpp-parse.y" { (yyval.ival) = ')'; ;} break; case 75: /* Line 1464 of yacc.c */ -#line 526 "glcpp/glcpp-parse.y" +#line 522 "glcpp/glcpp-parse.y" { (yyval.ival) = '{'; ;} break; case 76: /* Line 1464 of yacc.c */ -#line 527 "glcpp/glcpp-parse.y" +#line 523 "glcpp/glcpp-parse.y" { (yyval.ival) = '}'; ;} break; case 77: /* Line 1464 of yacc.c */ -#line 528 "glcpp/glcpp-parse.y" +#line 524 "glcpp/glcpp-parse.y" { (yyval.ival) = '.'; ;} break; case 78: /* Line 1464 of yacc.c */ -#line 529 "glcpp/glcpp-parse.y" +#line 525 "glcpp/glcpp-parse.y" { (yyval.ival) = '&'; ;} break; case 79: /* Line 1464 of yacc.c */ -#line 530 "glcpp/glcpp-parse.y" +#line 526 "glcpp/glcpp-parse.y" { (yyval.ival) = '*'; ;} break; case 80: /* Line 1464 of yacc.c */ -#line 531 "glcpp/glcpp-parse.y" +#line 527 "glcpp/glcpp-parse.y" { (yyval.ival) = '+'; ;} break; case 81: /* Line 1464 of yacc.c */ -#line 532 "glcpp/glcpp-parse.y" +#line 528 "glcpp/glcpp-parse.y" { (yyval.ival) = '-'; ;} break; case 82: /* Line 1464 of yacc.c */ -#line 533 "glcpp/glcpp-parse.y" +#line 529 "glcpp/glcpp-parse.y" { (yyval.ival) = '~'; ;} break; case 83: /* Line 1464 of yacc.c */ -#line 534 "glcpp/glcpp-parse.y" +#line 530 "glcpp/glcpp-parse.y" { (yyval.ival) = '!'; ;} break; case 84: /* Line 1464 of yacc.c */ -#line 535 "glcpp/glcpp-parse.y" +#line 531 "glcpp/glcpp-parse.y" { (yyval.ival) = '/'; ;} break; case 85: /* Line 1464 of yacc.c */ -#line 536 "glcpp/glcpp-parse.y" +#line 532 "glcpp/glcpp-parse.y" { (yyval.ival) = '%'; ;} break; case 86: /* Line 1464 of yacc.c */ -#line 537 "glcpp/glcpp-parse.y" +#line 533 "glcpp/glcpp-parse.y" { (yyval.ival) = LEFT_SHIFT; ;} break; case 87: /* Line 1464 of yacc.c */ -#line 538 "glcpp/glcpp-parse.y" +#line 534 "glcpp/glcpp-parse.y" { (yyval.ival) = RIGHT_SHIFT; ;} break; case 88: /* Line 1464 of yacc.c */ -#line 539 "glcpp/glcpp-parse.y" +#line 535 "glcpp/glcpp-parse.y" { (yyval.ival) = '<'; ;} break; case 89: /* Line 1464 of yacc.c */ -#line 540 "glcpp/glcpp-parse.y" +#line 536 "glcpp/glcpp-parse.y" { (yyval.ival) = '>'; ;} break; case 90: /* Line 1464 of yacc.c */ -#line 541 "glcpp/glcpp-parse.y" +#line 537 "glcpp/glcpp-parse.y" { (yyval.ival) = LESS_OR_EQUAL; ;} break; case 91: /* Line 1464 of yacc.c */ -#line 542 "glcpp/glcpp-parse.y" +#line 538 "glcpp/glcpp-parse.y" { (yyval.ival) = GREATER_OR_EQUAL; ;} break; case 92: /* Line 1464 of yacc.c */ -#line 543 "glcpp/glcpp-parse.y" +#line 539 "glcpp/glcpp-parse.y" { (yyval.ival) = EQUAL; ;} break; case 93: /* Line 1464 of yacc.c */ -#line 544 "glcpp/glcpp-parse.y" +#line 540 "glcpp/glcpp-parse.y" { (yyval.ival) = NOT_EQUAL; ;} break; case 94: /* Line 1464 of yacc.c */ -#line 545 "glcpp/glcpp-parse.y" +#line 541 "glcpp/glcpp-parse.y" { (yyval.ival) = '^'; ;} break; case 95: /* Line 1464 of yacc.c */ -#line 546 "glcpp/glcpp-parse.y" +#line 542 "glcpp/glcpp-parse.y" { (yyval.ival) = '|'; ;} break; case 96: /* Line 1464 of yacc.c */ -#line 547 "glcpp/glcpp-parse.y" +#line 543 "glcpp/glcpp-parse.y" { (yyval.ival) = AND; ;} break; case 97: /* Line 1464 of yacc.c */ -#line 548 "glcpp/glcpp-parse.y" +#line 544 "glcpp/glcpp-parse.y" { (yyval.ival) = OR; ;} break; case 98: /* Line 1464 of yacc.c */ -#line 549 "glcpp/glcpp-parse.y" +#line 545 "glcpp/glcpp-parse.y" { (yyval.ival) = ';'; ;} break; case 99: /* Line 1464 of yacc.c */ -#line 550 "glcpp/glcpp-parse.y" +#line 546 "glcpp/glcpp-parse.y" { (yyval.ival) = ','; ;} break; case 100: /* Line 1464 of yacc.c */ -#line 551 "glcpp/glcpp-parse.y" +#line 547 "glcpp/glcpp-parse.y" { (yyval.ival) = '='; ;} break; case 101: /* Line 1464 of yacc.c */ -#line 552 "glcpp/glcpp-parse.y" +#line 548 "glcpp/glcpp-parse.y" { (yyval.ival) = PASTE; ;} break; /* Line 1464 of yacc.c */ -#line 2661 "glcpp/glcpp-parse.c" +#line 2657 "glcpp/glcpp-parse.c" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); @@ -2876,7 +2872,7 @@ yyreturn: /* Line 1684 of yacc.c */ -#line 555 "glcpp/glcpp-parse.y" +#line 551 "glcpp/glcpp-parse.y" string_list_t * @@ -2884,7 +2880,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; @@ -2896,8 +2892,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; @@ -2975,7 +2971,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; @@ -2987,7 +2983,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; @@ -3038,15 +3034,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; } @@ -3056,7 +3054,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; @@ -3068,7 +3066,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; @@ -3081,11 +3079,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 { @@ -3124,7 +3123,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); } @@ -3144,7 +3143,7 @@ _token_list_trim_trailing_space (token_list_t *list) while (tail) { next = tail->next; - talloc_free (tail); + ralloc_free (tail); tail = next; } } @@ -3230,51 +3229,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. */ @@ -3285,7 +3284,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. * @@ -3356,7 +3355,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; @@ -3364,11 +3363,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; } @@ -3410,7 +3409,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, @@ -3427,8 +3426,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. */ @@ -3470,7 +3469,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 @@ -3641,7 +3640,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); } @@ -3797,7 +3796,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); @@ -3833,8 +3832,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; @@ -3850,7 +3849,7 @@ _active_list_pop (active_list_t *list) return NULL; node = list->next; - talloc_free (list); + ralloc_free (list); return node; } @@ -3999,17 +3998,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", @@ -4030,17 +4030,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", @@ -4116,7 +4117,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; } @@ -4145,13 +4146,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; } } @@ -4166,7 +4167,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) { @@ -4211,6 +4212,6 @@ _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); } diff --git a/src/glsl/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y index b449eb288b..65112c94d9 100644 --- a/src/glsl/glcpp/glcpp-parse.y +++ b/src/glsl/glcpp/glcpp-parse.y @@ -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); } diff --git a/src/glsl/glcpp/glcpp.c b/src/glsl/glcpp/glcpp.c index 062eb6b72d..564194caac 100644 --- a/src/glsl/glcpp/glcpp.c +++ b/src/glsl/glcpp/glcpp.c @@ -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; } diff --git a/src/glsl/glcpp/glcpp.h b/src/glsl/glcpp/glcpp.h index 7125d325df..dc816e90ee 100644 --- a/src/glsl/glcpp/glcpp.h +++ b/src/glsl/glcpp/glcpp.h @@ -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 */ diff --git a/src/glsl/glcpp/pp.c b/src/glsl/glcpp/pp.c index e1a3a88a3e..3640896a2c 100644 --- a/src/glsl/glcpp/pp.c +++ b/src/glsl/glcpp/pp.c @@ -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; diff --git a/src/glsl/glsl_lexer.cpp b/src/glsl/glsl_lexer.cpp index 04a434eb5b..04927950f4 100644 --- a/src/glsl/glsl_lexer.cpp +++ b/src/glsl/glsl_lexer.cpp @@ -2537,7 +2537,7 @@ YY_RULE_SETUP { struct _mesa_glsl_parse_state *state = yyextra; void *ctx = state; - yylval->identifier = talloc_strdup(ctx, yytext); + yylval->identifier = ralloc_strdup(ctx, yytext); return IDENTIFIER; } YY_BREAK diff --git a/src/glsl/glsl_lexer.lpp b/src/glsl/glsl_lexer.lpp index 4d6866390d..d3d53ffb68 100644 --- a/src/glsl/glsl_lexer.lpp +++ b/src/glsl/glsl_lexer.lpp @@ -418,7 +418,7 @@ row_major KEYWORD(130, 999, ROW_MAJOR); [_a-zA-Z][_a-zA-Z0-9]* { struct _mesa_glsl_parse_state *state = yyextra; void *ctx = state; - yylval->identifier = talloc_strdup(ctx, yytext); + yylval->identifier = ralloc_strdup(ctx, yytext); return IDENTIFIER; } diff --git a/src/glsl/glsl_parser.cpp b/src/glsl/glsl_parser.cpp index 360676cf87..a52df93fdb 100644 --- a/src/glsl/glsl_parser.cpp +++ b/src/glsl/glsl_parser.cpp @@ -2844,7 +2844,7 @@ yyreduce: /* FINISHME: Check against implementation support versions. */ state->language_version = (yyvsp[(2) - (3)].n); state->version_string = - talloc_asprintf(state, "GLSL%s %d.%02d", + ralloc_asprintf(state, "GLSL%s %d.%02d", state->es_shader ? " ES" : "", state->language_version / 100, state->language_version % 100); diff --git a/src/glsl/glsl_parser.ypp b/src/glsl/glsl_parser.ypp index 3955648eb6..7336b18cdc 100644 --- a/src/glsl/glsl_parser.ypp +++ b/src/glsl/glsl_parser.ypp @@ -229,7 +229,7 @@ version_statement: /* FINISHME: Check against implementation support versions. */ state->language_version = $2; state->version_string = - talloc_asprintf(state, "GLSL%s %d.%02d", + ralloc_asprintf(state, "GLSL%s %d.%02d", state->es_shader ? " ES" : "", state->language_version / 100, state->language_version % 100); diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp index c9a8a2cb27..5a8a5248c0 100644 --- a/src/glsl/glsl_parser_extras.cpp +++ b/src/glsl/glsl_parser_extras.cpp @@ -26,10 +26,10 @@ #include <assert.h> extern "C" { -#include <talloc.h> #include "main/core.h" /* for struct gl_context */ } +#include "ralloc.h" #include "ast.h" #include "glsl_parser_extras.h" #include "glsl_parser.h" @@ -48,7 +48,7 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct gl_context *ctx, this->scanner = NULL; this->translation_unit.make_empty(); this->symbols = new(mem_ctx) glsl_symbol_table; - this->info_log = talloc_strdup(mem_ctx, ""); + this->info_log = ralloc_strdup(mem_ctx, ""); this->error = false; this->loop_or_switch_nesting = NULL; @@ -104,15 +104,14 @@ _mesa_glsl_error(YYLTYPE *locp, _mesa_glsl_parse_state *state, state->error = true; assert(state->info_log != NULL); - state->info_log = talloc_asprintf_append(state->info_log, - "%u:%u(%u): error: ", + ralloc_asprintf_append(&state->info_log, "%u:%u(%u): error: ", locp->source, locp->first_line, locp->first_column); va_start(ap, fmt); - state->info_log = talloc_vasprintf_append(state->info_log, fmt, ap); + ralloc_vasprintf_append(&state->info_log, fmt, ap); va_end(ap); - state->info_log = talloc_strdup_append(state->info_log, "\n"); + ralloc_strcat(&state->info_log, "\n"); } @@ -123,15 +122,14 @@ _mesa_glsl_warning(const YYLTYPE *locp, _mesa_glsl_parse_state *state, va_list ap; assert(state->info_log != NULL); - state->info_log = talloc_asprintf_append(state->info_log, - "%u:%u(%u): warning: ", + ralloc_asprintf_append(&state->info_log, "%u:%u(%u): warning: ", locp->source, locp->first_line, locp->first_column); va_start(ap, fmt); - state->info_log = talloc_vasprintf_append(state->info_log, fmt, ap); + ralloc_vasprintf_append(&state->info_log, fmt, ap); va_end(ap); - state->info_log = talloc_strdup_append(state->info_log, "\n"); + ralloc_strcat(&state->info_log, "\n"); } @@ -712,7 +710,7 @@ ast_struct_specifier::ast_struct_specifier(char *identifier, { if (identifier == NULL) { static unsigned anon_count = 1; - identifier = talloc_asprintf(this, "#anon_struct_%04x", anon_count); + identifier = ralloc_asprintf(this, "#anon_struct_%04x", anon_count); anon_count++; } name = identifier; diff --git a/src/glsl/glsl_parser_extras.h b/src/glsl/glsl_parser_extras.h index 92029e2e8d..970275c0d1 100644 --- a/src/glsl/glsl_parser_extras.h +++ b/src/glsl/glsl_parser_extras.h @@ -46,21 +46,21 @@ struct _mesa_glsl_parse_state { _mesa_glsl_parse_state(struct gl_context *ctx, GLenum target, void *mem_ctx); - /* Callers of this talloc-based new need not call delete. It's - * easier to just talloc_free 'ctx' (or any of its ancestors). */ + /* Callers of this ralloc-based new need not call delete. It's + * easier to just ralloc_free 'ctx' (or any of its ancestors). */ static void* operator new(size_t size, void *ctx) { - void *mem = talloc_zero_size(ctx, size); + void *mem = rzalloc_size(ctx, size); assert(mem != NULL); return mem; } /* If the user *does* call delete, that's OK, we will just - * talloc_free in that case. */ + * ralloc_free in that case. */ static void operator delete(void *mem) { - talloc_free(mem); + ralloc_free(mem); } void *scanner; diff --git a/src/glsl/glsl_symbol_table.cpp b/src/glsl/glsl_symbol_table.cpp index 6fcfe07b9c..2f291d4f97 100644 --- a/src/glsl/glsl_symbol_table.cpp +++ b/src/glsl/glsl_symbol_table.cpp @@ -26,19 +26,19 @@ class symbol_table_entry { public: - /* Callers of this talloc-based new need not call delete. It's - * easier to just talloc_free 'ctx' (or any of its ancestors). */ + /* Callers of this ralloc-based new need not call delete. It's + * easier to just ralloc_free 'ctx' (or any of its ancestors). */ static void* operator new(size_t size, void *ctx) { - void *entry = talloc_size(ctx, size); + void *entry = ralloc_size(ctx, size); assert(entry != NULL); return entry; } - /* If the user *does* call delete, that's OK, we will just talloc_free. */ + /* If the user *does* call delete, that's OK, we will just ralloc_free. */ static void operator delete(void *entry) { - talloc_free(entry); + ralloc_free(entry); } symbol_table_entry(ir_variable *v) : v(v), f(0), t(0) {} @@ -54,13 +54,13 @@ glsl_symbol_table::glsl_symbol_table() { this->language_version = 120; this->table = _mesa_symbol_table_ctor(); - this->mem_ctx = talloc_init("symbol table entries"); + this->mem_ctx = ralloc_context(NULL); } glsl_symbol_table::~glsl_symbol_table() { _mesa_symbol_table_dtor(table); - talloc_free(mem_ctx); + ralloc_free(mem_ctx); } void glsl_symbol_table::push_scope() diff --git a/src/glsl/glsl_symbol_table.h b/src/glsl/glsl_symbol_table.h index 28a44ebe91..637bc033b9 100644 --- a/src/glsl/glsl_symbol_table.h +++ b/src/glsl/glsl_symbol_table.h @@ -44,36 +44,34 @@ class symbol_table_entry; */ struct glsl_symbol_table { private: - static int + static void _glsl_symbol_table_destructor (glsl_symbol_table *table) { table->~glsl_symbol_table(); - - return 0; } public: - /* Callers of this talloc-based new need not call delete. It's - * easier to just talloc_free 'ctx' (or any of its ancestors). */ + /* Callers of this ralloc-based new need not call delete. It's + * easier to just ralloc_free 'ctx' (or any of its ancestors). */ static void* operator new(size_t size, void *ctx) { void *table; - table = talloc_size(ctx, size); + table = ralloc_size(ctx, size); assert(table != NULL); - talloc_set_destructor(table, (int (*)(void*)) _glsl_symbol_table_destructor); + ralloc_set_destructor(table, (void (*)(void*)) _glsl_symbol_table_destructor); return table; } /* If the user *does* call delete, that's OK, we will just - * talloc_free in that case. Here, C++ will have already called the - * destructor so tell talloc not to do that again. */ + * ralloc_free in that case. Here, C++ will have already called the + * destructor so tell ralloc not to do that again. */ static void operator delete(void *table) { - talloc_set_destructor(table, NULL); - talloc_free(table); + ralloc_set_destructor(table, NULL); + ralloc_free(table); } glsl_symbol_table(); diff --git a/src/glsl/glsl_types.cpp b/src/glsl/glsl_types.cpp index 95b8592648..f4d9242b25 100644 --- a/src/glsl/glsl_types.cpp +++ b/src/glsl/glsl_types.cpp @@ -37,10 +37,10 @@ hash_table *glsl_type::record_types = NULL; void *glsl_type::mem_ctx = NULL; void -glsl_type::init_talloc_type_ctx(void) +glsl_type::init_ralloc_type_ctx(void) { if (glsl_type::mem_ctx == NULL) { - glsl_type::mem_ctx = talloc_autofree_context(); + glsl_type::mem_ctx = ralloc_autofree_context(); assert(glsl_type::mem_ctx != NULL); } } @@ -55,8 +55,8 @@ glsl_type::glsl_type(GLenum gl_type, vector_elements(vector_elements), matrix_columns(matrix_columns), length(0) { - init_talloc_type_ctx(); - this->name = talloc_strdup(this->mem_ctx, name); + init_ralloc_type_ctx(); + this->name = ralloc_strdup(this->mem_ctx, name); /* Neither dimension is zero or both dimensions are zero. */ assert((vector_elements == 0) == (matrix_columns == 0)); @@ -73,8 +73,8 @@ glsl_type::glsl_type(GLenum gl_type, vector_elements(0), matrix_columns(0), length(0) { - init_talloc_type_ctx(); - this->name = talloc_strdup(this->mem_ctx, name); + init_ralloc_type_ctx(); + this->name = ralloc_strdup(this->mem_ctx, name); memset(& fields, 0, sizeof(fields)); } @@ -88,13 +88,13 @@ glsl_type::glsl_type(const glsl_struct_field *fields, unsigned num_fields, { unsigned int i; - init_talloc_type_ctx(); - this->name = talloc_strdup(this->mem_ctx, name); - this->fields.structure = talloc_array(this->mem_ctx, + init_ralloc_type_ctx(); + this->name = ralloc_strdup(this->mem_ctx, name); + this->fields.structure = ralloc_array(this->mem_ctx, glsl_struct_field, length); for (i = 0; i < length; i++) { this->fields.structure[i].type = fields[i].type; - this->fields.structure[i].name = talloc_strdup(this->fields.structure, + this->fields.structure[i].name = ralloc_strdup(this->fields.structure, fields[i].name); } } @@ -264,7 +264,7 @@ glsl_type::glsl_type(const glsl_type *array, unsigned length) : * NUL. */ const unsigned name_length = strlen(array->name) + 10 + 3; - char *const n = (char *) talloc_size(this->mem_ctx, name_length); + char *const n = (char *) ralloc_size(this->mem_ctx, name_length); if (length == 0) snprintf(n, name_length, "%s[]", array->name); @@ -354,7 +354,7 @@ glsl_type::get_array_instance(const glsl_type *base, unsigned array_size) if (t == NULL) { t = new glsl_type(base, array_size); - hash_table_insert(array_types, (void *) t, talloc_strdup(mem_ctx, key)); + hash_table_insert(array_types, (void *) t, ralloc_strdup(mem_ctx, key)); } assert(t->base_type == GLSL_TYPE_ARRAY); diff --git a/src/glsl/glsl_types.h b/src/glsl/glsl_types.h index 57e7b09d98..ab6858faac 100644 --- a/src/glsl/glsl_types.h +++ b/src/glsl/glsl_types.h @@ -31,9 +31,10 @@ extern "C" { #include "GL/gl.h" -#include <talloc.h> } +#include "ralloc.h" + struct _mesa_glsl_parse_state; struct glsl_symbol_table; @@ -77,28 +78,28 @@ struct glsl_type { * and \c GLSL_TYPE_UINT are valid. */ - /* Callers of this talloc-based new need not call delete. It's - * easier to just talloc_free 'mem_ctx' (or any of its ancestors). */ + /* Callers of this ralloc-based new need not call delete. It's + * easier to just ralloc_free 'mem_ctx' (or any of its ancestors). */ static void* operator new(size_t size) { if (glsl_type::mem_ctx == NULL) { - glsl_type::mem_ctx = talloc_init("glsl_type"); + glsl_type::mem_ctx = ralloc_context(NULL); assert(glsl_type::mem_ctx != NULL); } void *type; - type = talloc_size(glsl_type::mem_ctx, size); + type = ralloc_size(glsl_type::mem_ctx, size); assert(type != NULL); return type; } /* If the user *does* call delete, that's OK, we will just - * talloc_free in that case. */ + * ralloc_free in that case. */ static void operator delete(void *type) { - talloc_free(type); + ralloc_free(type); } /** @@ -386,13 +387,13 @@ struct glsl_type { private: /** - * talloc context for all glsl_type allocations + * ralloc context for all glsl_type allocations * * Set on the first call to \c glsl_type::new. */ static void *mem_ctx; - void init_talloc_type_ctx(void); + void init_ralloc_type_ctx(void); /** Constructor for vector and matrix types */ glsl_type(GLenum gl_type, diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp index b4ceb5bba1..cc508e2a42 100644 --- a/src/glsl/ir.cpp +++ b/src/glsl/ir.cpp @@ -578,7 +578,7 @@ ir_constant::ir_constant(const struct glsl_type *type, exec_list *value_list) || type->is_record() || type->is_array()); if (type->is_array()) { - this->array_elements = talloc_array(this, ir_constant *, type->length); + this->array_elements = ralloc_array(this, ir_constant *, type->length); unsigned i = 0; foreach_list(node, value_list) { ir_constant *value = (ir_constant *) node; @@ -1036,7 +1036,7 @@ ir_dereference_array::ir_dereference_array(ir_rvalue *value, ir_dereference_array::ir_dereference_array(ir_variable *var, ir_rvalue *array_index) { - void *ctx = talloc_parent(var); + void *ctx = ralloc_parent(var); this->ir_type = ir_type_dereference_array; this->array_index = array_index; @@ -1069,7 +1069,7 @@ ir_dereference_record::ir_dereference_record(ir_rvalue *value, { this->ir_type = ir_type_dereference_record; this->record = value; - this->field = talloc_strdup(this, field); + this->field = ralloc_strdup(this, field); this->type = (this->record != NULL) ? this->record->type->field_type(field) : glsl_type::error_type; } @@ -1078,11 +1078,11 @@ ir_dereference_record::ir_dereference_record(ir_rvalue *value, ir_dereference_record::ir_dereference_record(ir_variable *var, const char *field) { - void *ctx = talloc_parent(var); + void *ctx = ralloc_parent(var); this->ir_type = ir_type_dereference_record; this->record = new(ctx) ir_dereference_variable(var); - this->field = talloc_strdup(this, field); + this->field = ralloc_strdup(this, field); this->type = (this->record != NULL) ? this->record->type->field_type(field) : glsl_type::error_type; } @@ -1245,7 +1245,7 @@ ir_swizzle::ir_swizzle(ir_rvalue *val, ir_swizzle_mask mask) ir_swizzle * ir_swizzle::create(ir_rvalue *val, const char *str, unsigned vector_length) { - void *ctx = talloc_parent(val); + void *ctx = ralloc_parent(val); /* For each possible swizzle character, this table encodes the value in * \c idx_map that represents the 0th element of the vector. For invalid @@ -1334,7 +1334,7 @@ ir_variable::ir_variable(const struct glsl_type *type, const char *name, { this->ir_type = ir_type_variable; this->type = type; - this->name = talloc_strdup(this, name); + this->name = ralloc_strdup(this, name); this->explicit_location = false; this->location = -1; this->warn_extension = NULL; @@ -1426,7 +1426,7 @@ ir_function_signature::replace_parameters(exec_list *new_params) ir_function::ir_function(const char *name) { this->ir_type = ir_type_function; - this->name = talloc_strdup(this, name); + this->name = ralloc_strdup(this, name); } @@ -1492,7 +1492,7 @@ steal_memory(ir_instruction *ir, void *new_ctx) } } - talloc_steal(new_ctx, ir); + ralloc_steal(new_ctx, ir); } diff --git a/src/glsl/ir.h b/src/glsl/ir.h index 8d5056aa1a..1fce272756 100644 --- a/src/glsl/ir.h +++ b/src/glsl/ir.h @@ -29,10 +29,7 @@ #include <cstdio> #include <cstdlib> -extern "C" { -#include <talloc.h> -} - +#include "ralloc.h" #include "glsl_types.h" #include "list.h" #include "ir_visitor.h" @@ -986,7 +983,7 @@ public: /** * Get a generic ir_call object when an error occurs * - * Any allocation will be performed with 'ctx' as talloc owner. + * Any allocation will be performed with 'ctx' as ralloc owner. */ static ir_call *get_error_instruction(void *ctx); diff --git a/src/glsl/ir_clone.cpp b/src/glsl/ir_clone.cpp index 1522af682b..20a59b1e43 100644 --- a/src/glsl/ir_clone.cpp +++ b/src/glsl/ir_clone.cpp @@ -346,7 +346,7 @@ ir_constant::clone(void *mem_ctx, struct hash_table *ht) const ir_constant *c = new(mem_ctx) ir_constant; c->type = this->type; - c->array_elements = talloc_array(c, ir_constant *, this->type->length); + c->array_elements = ralloc_array(c, ir_constant *, this->type->length); for (unsigned i = 0; i < this->type->length; i++) { c->array_elements[i] = this->array_elements[i]->clone(mem_ctx, NULL); } diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index 4fd6d09a3a..cf958aa7a1 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -86,7 +86,7 @@ ir_expression::constant_expression_value() components = op[1]->type->components(); } - void *ctx = talloc_parent(this); + void *ctx = ralloc_parent(this); /* Handle array operations here, rather than below. */ if (op[0]->type->is_array()) { @@ -845,7 +845,7 @@ ir_swizzle::constant_expression_value() } } - void *ctx = talloc_parent(this); + void *ctx = ralloc_parent(this); return new(ctx) ir_constant(this->type, &data); } return NULL; @@ -868,7 +868,7 @@ ir_dereference_variable::constant_expression_value() if (!var->constant_value) return NULL; - return var->constant_value->clone(talloc_parent(var), NULL); + return var->constant_value->clone(ralloc_parent(var), NULL); } @@ -879,7 +879,7 @@ ir_dereference_array::constant_expression_value() ir_constant *idx = this->array_index->constant_expression_value(); if ((array != NULL) && (idx != NULL)) { - void *ctx = talloc_parent(this); + void *ctx = ralloc_parent(this); if (array->type->is_matrix()) { /* Array access of a matrix results in a vector. */ @@ -984,7 +984,7 @@ ir_call::constant_expression_value() * - Fill "data" with appopriate constant data * - Return an ir_constant directly. */ - void *mem_ctx = talloc_parent(this); + void *mem_ctx = ralloc_parent(this); ir_expression *expr = NULL; ir_constant_data data; diff --git a/src/glsl/ir_expression_flattening.cpp b/src/glsl/ir_expression_flattening.cpp index 7b1b8dbfef..0b7c537bd8 100644 --- a/src/glsl/ir_expression_flattening.cpp +++ b/src/glsl/ir_expression_flattening.cpp @@ -78,7 +78,7 @@ ir_expression_flattening_visitor::handle_rvalue(ir_rvalue **rvalue) if (!ir || !this->predicate(ir)) return; - void *ctx = talloc_parent(ir); + void *ctx = ralloc_parent(ir); var = new(ctx) ir_variable(ir->type, "flattening_tmp", ir_var_temporary); base_ir->insert_before(var); diff --git a/src/glsl/ir_import_prototypes.cpp b/src/glsl/ir_import_prototypes.cpp index 4e0b30aa90..be5e0c1d3d 100644 --- a/src/glsl/ir_import_prototypes.cpp +++ b/src/glsl/ir_import_prototypes.cpp @@ -109,7 +109,7 @@ private: * \param dest Destination instruction stream where new \c ir_function and * \c ir_function_signature nodes will be stored * \param symbols Symbol table where new functions will be stored - * \param mem_ctx talloc memory context used for new allocations + * \param mem_ctx ralloc memory context used for new allocations */ void import_prototypes(const exec_list *source, exec_list *dest, diff --git a/src/glsl/ir_reader.cpp b/src/glsl/ir_reader.cpp index b78aa051b4..bff75ed0e8 100644 --- a/src/glsl/ir_reader.cpp +++ b/src/glsl/ir_reader.cpp @@ -92,7 +92,7 @@ ir_reader::read(exec_list *instructions, const char *src, bool scan_for_protos) } read_instructions(instructions, expr, NULL); - talloc_free(expr); + ralloc_free(expr); if (debug) validate_ir_tree(instructions); @@ -106,21 +106,19 @@ ir_reader::ir_read_error(s_expression *expr, const char *fmt, ...) state->error = true; if (state->current_function != NULL) - state->info_log = talloc_asprintf_append(state->info_log, - "In function %s:\n", - state->current_function->function_name()); - state->info_log = talloc_strdup_append(state->info_log, "error: "); + ralloc_asprintf_append(&state->info_log, "In function %s:\n", + state->current_function->function_name()); + ralloc_strcat(&state->info_log, "error: "); va_start(ap, fmt); - state->info_log = talloc_vasprintf_append(state->info_log, fmt, ap); + ralloc_vasprintf_append(&state->info_log, fmt, ap); va_end(ap); - state->info_log = talloc_strdup_append(state->info_log, "\n"); + ralloc_strcat(&state->info_log, "\n"); if (expr != NULL) { - state->info_log = talloc_strdup_append(state->info_log, - "...in this context:\n "); + ralloc_strcat(&state->info_log, "...in this context:\n "); expr->print(); - state->info_log = talloc_strdup_append(state->info_log, "\n\n"); + ralloc_strcat(&state->info_log, "\n\n"); } } diff --git a/src/glsl/ir_validate.cpp b/src/glsl/ir_validate.cpp index 5b055f64d3..44d7549ea2 100644 --- a/src/glsl/ir_validate.cpp +++ b/src/glsl/ir_validate.cpp @@ -179,7 +179,7 @@ ir_validate::visit_enter(ir_function *ir) ir_visitor_status ir_validate::visit_leave(ir_function *ir) { - assert(talloc_parent(ir->name) == ir); + assert(ralloc_parent(ir->name) == ir); this->current_function = NULL; return visit_continue; @@ -450,7 +450,7 @@ ir_validate::visit(ir_variable *ir) * declared before it is dereferenced. */ if (ir->name) - assert(talloc_parent(ir->name) == ir); + assert(ralloc_parent(ir->name) == ir); hash_table_insert(ht, ir, ir); return visit_continue; diff --git a/src/glsl/ir_variable_refcount.h b/src/glsl/ir_variable_refcount.h index 8b43bad71f..906135a9e1 100644 --- a/src/glsl/ir_variable_refcount.h +++ b/src/glsl/ir_variable_refcount.h @@ -54,13 +54,13 @@ class ir_variable_refcount_visitor : public ir_hierarchical_visitor { public: ir_variable_refcount_visitor(void) { - this->mem_ctx = talloc_new(NULL); + this->mem_ctx = ralloc_context(NULL); this->variable_list.make_empty(); } ~ir_variable_refcount_visitor(void) { - talloc_free(this->mem_ctx); + ralloc_free(this->mem_ctx); } virtual ir_visitor_status visit(ir_variable *); diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index 4332338df8..3d1b8a2f70 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -172,9 +172,9 @@ linker_error_printf(gl_shader_program *prog, const char *fmt, ...) { va_list ap; - prog->InfoLog = talloc_strdup_append(prog->InfoLog, "error: "); + ralloc_strcat(&prog->InfoLog, "error: "); va_start(ap, fmt); - prog->InfoLog = talloc_vasprintf_append(prog->InfoLog, fmt, ap); + ralloc_vasprintf_append(&prog->InfoLog, fmt, ap); va_end(ap); } @@ -432,7 +432,7 @@ cross_validate_globals(struct gl_shader_program *prog, * FINISHME: will fail. */ existing->constant_value = - var->constant_value->clone(talloc_parent(existing), NULL); + var->constant_value->clone(ralloc_parent(existing), NULL); } if (existing->invariant != var->invariant) { @@ -1015,7 +1015,7 @@ add_uniform(void *mem_ctx, exec_list *uniforms, struct hash_table *ht, if (type->is_record()) { for (unsigned int i = 0; i < type->length; i++) { const glsl_type *field_type = type->fields.structure[i].type; - char *field_name = talloc_asprintf(mem_ctx, "%s.%s", name, + char *field_name = ralloc_asprintf(mem_ctx, "%s.%s", name, type->fields.structure[i].name); add_uniform(mem_ctx, uniforms, ht, field_name, field_type, @@ -1031,7 +1031,7 @@ add_uniform(void *mem_ctx, exec_list *uniforms, struct hash_table *ht, /* Array of structures. */ if (array_elem_type->is_record()) { for (unsigned int i = 0; i < type->length; i++) { - char *elem_name = talloc_asprintf(mem_ctx, "%s[%d]", name, i); + char *elem_name = ralloc_asprintf(mem_ctx, "%s[%d]", name, i); add_uniform(mem_ctx, uniforms, ht, elem_name, array_elem_type, shader_type, next_shader_pos, total_uniforms); } @@ -1093,7 +1093,7 @@ assign_uniform_locations(struct gl_shader_program *prog) unsigned total_uniforms = 0; hash_table *ht = hash_table_ctor(32, hash_table_string_hash, hash_table_string_compare); - void *mem_ctx = talloc_new(NULL); + void *mem_ctx = ralloc_context(NULL); for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) { if (prog->_LinkedShaders[i] == NULL) @@ -1122,7 +1122,7 @@ assign_uniform_locations(struct gl_shader_program *prog) } } - talloc_free(mem_ctx); + ralloc_free(mem_ctx); gl_uniform_list *ul = (gl_uniform_list *) calloc(1, sizeof(gl_uniform_list)); @@ -1490,16 +1490,16 @@ assign_varying_locations(struct gl_shader_program *prog, void link_shaders(struct gl_context *ctx, struct gl_shader_program *prog) { - void *mem_ctx = talloc_init("temporary linker context"); + void *mem_ctx = ralloc_context(NULL); // temporary linker context prog->LinkStatus = false; prog->Validated = false; prog->_Used = false; if (prog->InfoLog != NULL) - talloc_free(prog->InfoLog); + ralloc_free(prog->InfoLog); - prog->InfoLog = talloc_strdup(NULL, ""); + prog->InfoLog = ralloc_strdup(NULL, ""); /* Separate the shaders into groups based on their type. */ @@ -1694,5 +1694,5 @@ done: reparent_ir(prog->_LinkedShaders[i]->ir, prog->_LinkedShaders[i]->ir); } - talloc_free(mem_ctx); + ralloc_free(mem_ctx); } diff --git a/src/glsl/list.h b/src/glsl/list.h index 3197b03cf2..1d46365fae 100644 --- a/src/glsl/list.h +++ b/src/glsl/list.h @@ -66,37 +66,33 @@ #ifndef __cplusplus #include <stddef.h> -#include <talloc.h> -#else -extern "C" { -#include <talloc.h> -} #endif - #include <assert.h> +#include "ralloc.h" + struct exec_node { struct exec_node *next; struct exec_node *prev; #ifdef __cplusplus - /* Callers of this talloc-based new need not call delete. It's - * easier to just talloc_free 'ctx' (or any of its ancestors). */ + /* Callers of this ralloc-based new need not call delete. It's + * easier to just ralloc_free 'ctx' (or any of its ancestors). */ static void* operator new(size_t size, void *ctx) { void *node; - node = talloc_size(ctx, size); + node = ralloc_size(ctx, size); assert(node != NULL); return node; } /* If the user *does* call delete, that's OK, we will just - * talloc_free in that case. */ + * ralloc_free in that case. */ static void operator delete(void *node) { - talloc_free(node); + ralloc_free(node); } exec_node() : next(NULL), prev(NULL) @@ -289,23 +285,23 @@ struct exec_list { struct exec_node *tail_pred; #ifdef __cplusplus - /* Callers of this talloc-based new need not call delete. It's - * easier to just talloc_free 'ctx' (or any of its ancestors). */ + /* Callers of this ralloc-based new need not call delete. It's + * easier to just ralloc_free 'ctx' (or any of its ancestors). */ static void* operator new(size_t size, void *ctx) { void *node; - node = talloc_size(ctx, size); + node = ralloc_size(ctx, size); assert(node != NULL); return node; } /* If the user *does* call delete, that's OK, we will just - * talloc_free in that case. */ + * ralloc_free in that case. */ static void operator delete(void *node) { - talloc_free(node); + ralloc_free(node); } exec_list() diff --git a/src/glsl/loop_analysis.cpp b/src/glsl/loop_analysis.cpp index 3cf86ebaa3..9bba6a97c4 100644 --- a/src/glsl/loop_analysis.cpp +++ b/src/glsl/loop_analysis.cpp @@ -37,7 +37,7 @@ loop_state::loop_state() { this->ht = hash_table_ctor(0, hash_table_pointer_hash, hash_table_pointer_compare); - this->mem_ctx = talloc_init("loop state"); + this->mem_ctx = ralloc_context(NULL); this->loop_found = false; } @@ -45,7 +45,7 @@ loop_state::loop_state() loop_state::~loop_state() { hash_table_dtor(this->ht); - talloc_free(this->mem_ctx); + ralloc_free(this->mem_ctx); } @@ -78,8 +78,8 @@ loop_variable_state::get(const ir_variable *ir) loop_variable * loop_variable_state::insert(ir_variable *var) { - void *mem_ctx = talloc_parent(this); - loop_variable *lv = talloc_zero(mem_ctx, loop_variable); + void *mem_ctx = ralloc_parent(this); + loop_variable *lv = rzalloc(mem_ctx, loop_variable); lv->var = var; @@ -93,8 +93,8 @@ loop_variable_state::insert(ir_variable *var) loop_terminator * loop_variable_state::insert(ir_if *if_stmt) { - void *mem_ctx = talloc_parent(this); - loop_terminator *t = talloc_zero(mem_ctx, loop_terminator); + void *mem_ctx = ralloc_parent(this); + loop_terminator *t = rzalloc(mem_ctx, loop_terminator); t->ir = if_stmt; this->terminators.push_tail(t); @@ -450,7 +450,7 @@ get_basic_induction_increment(ir_assignment *ir, hash_table *var_hash) } if ((inc != NULL) && (rhs->operation == ir_binop_sub)) { - void *mem_ctx = talloc_parent(ir); + void *mem_ctx = ralloc_parent(ir); inc = new(mem_ctx) ir_expression(ir_unop_neg, inc->type, diff --git a/src/glsl/loop_controls.cpp b/src/glsl/loop_controls.cpp index b528810f40..9eaa50f22d 100644 --- a/src/glsl/loop_controls.cpp +++ b/src/glsl/loop_controls.cpp @@ -88,7 +88,7 @@ calculate_iterations(ir_rvalue *from, ir_rvalue *to, ir_rvalue *increment, if (from == NULL || to == NULL || increment == NULL) return -1; - void *mem_ctx = talloc_init("%s", __func__); + void *mem_ctx = ralloc_context(NULL); ir_expression *const sub = new(mem_ctx) ir_expression(ir_binop_sub, from->type, to, from); @@ -147,7 +147,7 @@ calculate_iterations(ir_rvalue *from, ir_rvalue *to, ir_rvalue *increment, } } - talloc_free(mem_ctx); + ralloc_free(mem_ctx); return (valid_loop) ? iter_value : -1; } diff --git a/src/glsl/loop_unroll.cpp b/src/glsl/loop_unroll.cpp index 46000524ba..5b84e10147 100644 --- a/src/glsl/loop_unroll.cpp +++ b/src/glsl/loop_unroll.cpp @@ -150,7 +150,7 @@ loop_unroll_visitor::visit_leave(ir_loop *ir) */ break_ir->remove(); - void *const mem_ctx = talloc_parent(ir); + void *const mem_ctx = ralloc_parent(ir); ir_instruction *ir_to_replace = ir; for (int i = 0; i < iterations; i++) { @@ -182,7 +182,7 @@ loop_unroll_visitor::visit_leave(ir_loop *ir) } } - void *const mem_ctx = talloc_parent(ir); + void *const mem_ctx = ralloc_parent(ir); for (int i = 0; i < iterations; i++) { exec_list copy_list; diff --git a/src/glsl/lower_discard.cpp b/src/glsl/lower_discard.cpp index b95313df8c..cafd2dd3b4 100644 --- a/src/glsl/lower_discard.cpp +++ b/src/glsl/lower_discard.cpp @@ -170,7 +170,7 @@ lower_discard_visitor::visit_leave(ir_if *ir) if (then_discard == NULL && else_discard == NULL) return visit_continue; - void *mem_ctx = talloc_parent(ir); + void *mem_ctx = ralloc_parent(ir); ir_variable *temp = new(mem_ctx) ir_variable(glsl_type::bool_type, "discard_cond_temp", diff --git a/src/glsl/lower_if_to_cond_assign.cpp b/src/glsl/lower_if_to_cond_assign.cpp index 40ffc45c86..e3a1065d99 100644 --- a/src/glsl/lower_if_to_cond_assign.cpp +++ b/src/glsl/lower_if_to_cond_assign.cpp @@ -171,7 +171,7 @@ ir_if_to_cond_assign_visitor::visit_leave(ir_if *ir) if (found_control_flow) return visit_continue; - void *mem_ctx = talloc_parent(ir); + void *mem_ctx = ralloc_parent(ir); /* Store the condition to a variable so the assignment conditions are * simpler. diff --git a/src/glsl/lower_mat_op_to_vec.cpp b/src/glsl/lower_mat_op_to_vec.cpp index 7065fdec35..8cbbfa713c 100644 --- a/src/glsl/lower_mat_op_to_vec.cpp +++ b/src/glsl/lower_mat_op_to_vec.cpp @@ -368,7 +368,7 @@ ir_mat_op_to_vec_visitor::visit_leave(ir_assignment *orig_assign) assert(orig_expr->get_num_operands() <= 2); - mem_ctx = talloc_parent(orig_assign); + mem_ctx = ralloc_parent(orig_assign); ir_dereference_variable *lhs_deref = orig_assign->lhs->as_dereference_variable(); diff --git a/src/glsl/lower_noise.cpp b/src/glsl/lower_noise.cpp index cb32d28348..85f59b675e 100644 --- a/src/glsl/lower_noise.cpp +++ b/src/glsl/lower_noise.cpp @@ -51,7 +51,7 @@ public: * that implements noise. No hardware has a noise instruction. */ if (expr->operation == ir_unop_noise) { - *rvalue = ir_constant::zero(talloc_parent(expr), expr->type); + *rvalue = ir_constant::zero(ralloc_parent(expr), expr->type); this->progress = true; } } diff --git a/src/glsl/lower_texture_projection.cpp b/src/glsl/lower_texture_projection.cpp index 1fd26a7a2b..6e3aaeccee 100644 --- a/src/glsl/lower_texture_projection.cpp +++ b/src/glsl/lower_texture_projection.cpp @@ -55,7 +55,7 @@ lower_texture_projection_visitor::visit_leave(ir_texture *ir) if (!ir->projector) return visit_continue; - void *mem_ctx = talloc_parent(ir); + void *mem_ctx = ralloc_parent(ir); ir_variable *var = new(mem_ctx) ir_variable(ir->projector->type, "projector", ir_var_auto); diff --git a/src/glsl/lower_variable_index_to_cond_assign.cpp b/src/glsl/lower_variable_index_to_cond_assign.cpp index 7b4e4ad07c..147a6aea1e 100644 --- a/src/glsl/lower_variable_index_to_cond_assign.cpp +++ b/src/glsl/lower_variable_index_to_cond_assign.cpp @@ -54,7 +54,7 @@ struct assignment_generator /* Just clone the rest of the deref chain when trying to get at the * underlying variable. */ - void *mem_ctx = talloc_parent(base_ir); + void *mem_ctx = ralloc_parent(base_ir); ir_dereference *element = new(mem_ctx) ir_dereference_array(this->array->clone(mem_ctx, NULL), new(mem_ctx) ir_constant(i)); @@ -91,7 +91,7 @@ struct switch_generator linear_sequence_max_length(linear_sequence_max_length), condition_components(condition_components) { - this->mem_ctx = talloc_parent(index); + this->mem_ctx = ralloc_parent(index); } void linear_sequence(unsigned begin, unsigned end, exec_list *list) @@ -275,7 +275,7 @@ public: ? orig_deref->array->type->length : orig_deref->array->type->matrix_columns; - void *const mem_ctx = talloc_parent(base_ir); + void *const mem_ctx = ralloc_parent(base_ir); /* Temporary storage for either the result of the dereference of * the array, or the RHS that's being assigned into the @@ -342,7 +342,7 @@ public: if (needs_lowering(orig_deref)) { ir_variable* var = convert_dereference_array(orig_deref, 0); assert(var); - *pir = new(talloc_parent(base_ir)) ir_dereference_variable(var); + *pir = new(ralloc_parent(base_ir)) ir_dereference_variable(var); this->progress = true; } } diff --git a/src/glsl/lower_vec_index_to_cond_assign.cpp b/src/glsl/lower_vec_index_to_cond_assign.cpp index f8011a16e5..3c4d93201d 100644 --- a/src/glsl/lower_vec_index_to_cond_assign.cpp +++ b/src/glsl/lower_vec_index_to_cond_assign.cpp @@ -82,7 +82,7 @@ ir_vec_index_to_cond_assign_visitor::convert_vec_index_to_cond_assign(ir_rvalue orig_deref->array->type->is_array()) return ir; - void *mem_ctx = talloc_parent(ir); + void *mem_ctx = ralloc_parent(ir); assert(orig_deref->array_index->type->base_type == GLSL_TYPE_INT); @@ -167,7 +167,7 @@ ir_vec_index_to_cond_assign_visitor::visit_leave(ir_assignment *ir) orig_deref->array->type->is_array()) return visit_continue; - void *mem_ctx = talloc_parent(ir); + void *mem_ctx = ralloc_parent(ir); assert(orig_deref->array_index->type->base_type == GLSL_TYPE_INT); diff --git a/src/glsl/lower_vec_index_to_swizzle.cpp b/src/glsl/lower_vec_index_to_swizzle.cpp index 9ae43c0db1..c7630c28a8 100644 --- a/src/glsl/lower_vec_index_to_swizzle.cpp +++ b/src/glsl/lower_vec_index_to_swizzle.cpp @@ -74,7 +74,7 @@ ir_vec_index_to_swizzle_visitor::convert_vec_index_to_swizzle(ir_rvalue *ir) if (!ir_constant) return ir; - void *ctx = talloc_parent(ir); + void *ctx = ralloc_parent(ir); this->progress = true; return new(ctx) ir_swizzle(deref->array, ir_constant->value.i[0], 0, 0, 0, 1); diff --git a/src/glsl/lower_vector.cpp b/src/glsl/lower_vector.cpp index 93c37638bb..57963a121a 100644 --- a/src/glsl/lower_vector.cpp +++ b/src/glsl/lower_vector.cpp @@ -125,7 +125,7 @@ lower_vector_visitor::handle_rvalue(ir_rvalue **rvalue) if (this->dont_lower_swz && is_extended_swizzle(expr)) return; - /* FINISHME: Is this the right thing to use for the talloc context? + /* FINISHME: Is this the right thing to use for the ralloc context? */ void *const mem_ctx = expr; diff --git a/src/glsl/main.cpp b/src/glsl/main.cpp index 9b041aafe4..b4c7f96626 100644 --- a/src/glsl/main.cpp +++ b/src/glsl/main.cpp @@ -56,7 +56,7 @@ _mesa_new_shader(struct gl_context *ctx, GLuint name, GLenum type) (void) ctx; assert(type == GL_FRAGMENT_SHADER || type == GL_VERTEX_SHADER); - shader = talloc_zero(NULL, struct gl_shader); + shader = rzalloc(NULL, struct gl_shader); if (shader) { shader->Type = type; shader->Name = name; @@ -101,7 +101,7 @@ initialize_context(struct gl_context *ctx, gl_api api) ctx->Driver.NewShader = _mesa_new_shader; } -/* Returned string will have 'ctx' as its talloc owner. */ +/* Returned string will have 'ctx' as its ralloc owner. */ static char * load_text_file(void *ctx, const char *file_name) { @@ -118,7 +118,7 @@ load_text_file(void *ctx, const char *file_name) size = ftell(fp); fseek(fp, 0L, SEEK_SET); - text = (char *) talloc_size(ctx, size + 1); + text = (char *) ralloc_size(ctx, size + 1); if (text != NULL) { do { size_t bytes = fread(text + total_read, @@ -236,14 +236,14 @@ compile_shader(struct gl_context *ctx, struct gl_shader *shader) shader->num_builtins_to_link = state->num_builtins_to_link; if (shader->InfoLog) - talloc_free(shader->InfoLog); + ralloc_free(shader->InfoLog); shader->InfoLog = state->info_log; /* Retain any live IR, but trash the rest. */ reparent_ir(shader->ir, shader); - talloc_free(state); + ralloc_free(state); return; } @@ -268,16 +268,16 @@ main(int argc, char **argv) struct gl_shader_program *whole_program; - whole_program = talloc_zero (NULL, struct gl_shader_program); + whole_program = rzalloc (NULL, struct gl_shader_program); assert(whole_program != NULL); for (/* empty */; argc > optind; optind++) { - whole_program->Shaders = (struct gl_shader **) - talloc_realloc(whole_program, whole_program->Shaders, - struct gl_shader *, whole_program->NumShaders + 1); + whole_program->Shaders = + reralloc(whole_program, whole_program->Shaders, + struct gl_shader *, whole_program->NumShaders + 1); assert(whole_program->Shaders != NULL); - struct gl_shader *shader = talloc_zero(whole_program, gl_shader); + struct gl_shader *shader = rzalloc(whole_program, gl_shader); whole_program->Shaders[whole_program->NumShaders] = shader; whole_program->NumShaders++; @@ -320,9 +320,9 @@ main(int argc, char **argv) } for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) - talloc_free(whole_program->_LinkedShaders[i]); + ralloc_free(whole_program->_LinkedShaders[i]); - talloc_free(whole_program); + ralloc_free(whole_program); _mesa_glsl_release_types(); _mesa_glsl_release_functions(); diff --git a/src/glsl/opt_algebraic.cpp b/src/glsl/opt_algebraic.cpp index 20f6159f0e..cade9611db 100644 --- a/src/glsl/opt_algebraic.cpp +++ b/src/glsl/opt_algebraic.cpp @@ -191,7 +191,7 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir) } if (this->mem_ctx == NULL) - this->mem_ctx = talloc_parent(ir); + this->mem_ctx = ralloc_parent(ir); switch (ir->operation) { case ir_unop_logic_not: { diff --git a/src/glsl/opt_constant_propagation.cpp b/src/glsl/opt_constant_propagation.cpp index 6719fc8186..e1f68892fb 100644 --- a/src/glsl/opt_constant_propagation.cpp +++ b/src/glsl/opt_constant_propagation.cpp @@ -78,13 +78,13 @@ public: ir_constant_propagation_visitor() { progress = false; - mem_ctx = talloc_new(0); + mem_ctx = ralloc_context(0); this->acp = new(mem_ctx) exec_list; this->kills = new(mem_ctx) exec_list; } ~ir_constant_propagation_visitor() { - talloc_free(mem_ctx); + ralloc_free(mem_ctx); } virtual ir_visitor_status visit_enter(class ir_loop *); @@ -195,7 +195,7 @@ ir_constant_propagation_visitor::handle_rvalue(ir_rvalue **rvalue) } } - *rvalue = new(talloc_parent(deref)) ir_constant(type, &data); + *rvalue = new(ralloc_parent(deref)) ir_constant(type, &data); this->progress = true; } diff --git a/src/glsl/opt_copy_propagation.cpp b/src/glsl/opt_copy_propagation.cpp index 8d07fefbfd..4ab23bf9b0 100644 --- a/src/glsl/opt_copy_propagation.cpp +++ b/src/glsl/opt_copy_propagation.cpp @@ -71,13 +71,13 @@ public: ir_copy_propagation_visitor() { progress = false; - mem_ctx = talloc_new(0); + mem_ctx = ralloc_context(0); this->acp = new(mem_ctx) exec_list; this->kills = new(mem_ctx) exec_list; } ~ir_copy_propagation_visitor() { - talloc_free(mem_ctx); + ralloc_free(mem_ctx); } virtual ir_visitor_status visit(class ir_dereference_variable *); @@ -325,7 +325,7 @@ ir_copy_propagation_visitor::add_copy(ir_assignment *ir) * calling us. Just flag it to not execute, and someone else * will clean up the mess. */ - ir->condition = new(talloc_parent(ir)) ir_constant(false); + ir->condition = new(ralloc_parent(ir)) ir_constant(false); this->progress = true; } else { entry = new(this->mem_ctx) acp_entry(lhs_var, rhs_var); diff --git a/src/glsl/opt_dead_code_local.cpp b/src/glsl/opt_dead_code_local.cpp index 5689e7d20d..2610b69815 100644 --- a/src/glsl/opt_dead_code_local.cpp +++ b/src/glsl/opt_dead_code_local.cpp @@ -190,7 +190,7 @@ dead_code_local_basic_block(ir_instruction *first, bool *out_progress = (bool *)data; bool progress = false; - void *ctx = talloc_new(NULL); + void *ctx = ralloc_context(NULL); /* Safe looping, since process_assignment */ for (ir = first, ir_next = (ir_instruction *)first->next;; ir = ir_next, ir_next = (ir_instruction *)ir->next) { @@ -212,7 +212,7 @@ dead_code_local_basic_block(ir_instruction *first, break; } *out_progress = progress; - talloc_free(ctx); + ralloc_free(ctx); } /** diff --git a/src/glsl/opt_dead_functions.cpp b/src/glsl/opt_dead_functions.cpp index cf91cb6d36..ceb79080a7 100644 --- a/src/glsl/opt_dead_functions.cpp +++ b/src/glsl/opt_dead_functions.cpp @@ -49,12 +49,12 @@ public: ir_dead_functions_visitor() { - this->mem_ctx = talloc_new(NULL); + this->mem_ctx = ralloc_context(NULL); } ~ir_dead_functions_visitor() { - talloc_free(this->mem_ctx); + ralloc_free(this->mem_ctx); } virtual ir_visitor_status visit_enter(ir_function_signature *); diff --git a/src/glsl/opt_function_inlining.cpp b/src/glsl/opt_function_inlining.cpp index 169fd82688..a0449a7427 100644 --- a/src/glsl/opt_function_inlining.cpp +++ b/src/glsl/opt_function_inlining.cpp @@ -89,7 +89,7 @@ do_function_inlining(exec_list *instructions) static void replace_return_with_assignment(ir_instruction *ir, void *data) { - void *ctx = talloc_parent(ir); + void *ctx = ralloc_parent(ir); ir_variable *retval = (ir_variable *)data; ir_return *ret = ir->as_return(); @@ -110,7 +110,7 @@ replace_return_with_assignment(ir_instruction *ir, void *data) ir_rvalue * ir_call::generate_inline(ir_instruction *next_ir) { - void *ctx = talloc_parent(this); + void *ctx = ralloc_parent(this); ir_variable **parameters; int num_parameters; int i; @@ -357,7 +357,7 @@ ir_sampler_replacement_visitor::replace_deref(ir_dereference **deref) { ir_dereference_variable *deref_var = (*deref)->as_dereference_variable(); if (deref_var && deref_var->var == this->sampler) { - *deref = this->deref->clone(talloc_parent(*deref), NULL); + *deref = this->deref->clone(ralloc_parent(*deref), NULL); } } diff --git a/src/glsl/opt_structure_splitting.cpp b/src/glsl/opt_structure_splitting.cpp index d6191002c2..014407c0be 100644 --- a/src/glsl/opt_structure_splitting.cpp +++ b/src/glsl/opt_structure_splitting.cpp @@ -65,7 +65,7 @@ public: ir_variable **components; - /** talloc_parent(this->var) -- the shader's talloc context. */ + /** ralloc_parent(this->var) -- the shader's ralloc context. */ void *mem_ctx; }; @@ -74,13 +74,13 @@ class ir_structure_reference_visitor : public ir_hierarchical_visitor { public: ir_structure_reference_visitor(void) { - this->mem_ctx = talloc_new(NULL); + this->mem_ctx = ralloc_context(NULL); this->variable_list.make_empty(); } ~ir_structure_reference_visitor(void) { - talloc_free(mem_ctx); + ralloc_free(mem_ctx); } virtual ir_visitor_status visit(ir_variable *); @@ -322,7 +322,7 @@ do_structure_splitting(exec_list *instructions) if (refs.variable_list.is_empty()) return false; - void *mem_ctx = talloc_new(NULL); + void *mem_ctx = ralloc_context(NULL); /* Replace the decls of the structures to be split with their split * components. @@ -331,14 +331,14 @@ do_structure_splitting(exec_list *instructions) variable_entry2 *entry = (variable_entry2 *)iter.get(); const struct glsl_type *type = entry->var->type; - entry->mem_ctx = talloc_parent(entry->var); + entry->mem_ctx = ralloc_parent(entry->var); - entry->components = talloc_array(mem_ctx, + entry->components = ralloc_array(mem_ctx, ir_variable *, type->length); for (unsigned int i = 0; i < entry->var->type->length; i++) { - const char *name = talloc_asprintf(mem_ctx, "%s_%s", + const char *name = ralloc_asprintf(mem_ctx, "%s_%s", entry->var->name, type->fields.structure[i].name); @@ -355,7 +355,7 @@ do_structure_splitting(exec_list *instructions) ir_structure_splitting_visitor split(&refs.variable_list); visit_list_elements(&split, instructions); - talloc_free(mem_ctx); + ralloc_free(mem_ctx); return true; } diff --git a/src/glsl/s_expression.cpp b/src/glsl/s_expression.cpp index 6edbf62e48..77ac08ac7e 100644 --- a/src/glsl/s_expression.cpp +++ b/src/glsl/s_expression.cpp @@ -30,7 +30,7 @@ s_symbol::s_symbol(const char *tmp, size_t n) { - this->str = talloc_strndup (this, tmp, n); + this->str = ralloc_strndup (this, tmp, n); assert(this->str != NULL); } diff --git a/src/glsl/s_expression.h b/src/glsl/s_expression.h index 795f3fccea..c9dc676b31 100644 --- a/src/glsl/s_expression.h +++ b/src/glsl/s_expression.h @@ -57,7 +57,7 @@ public: * Read an S-Expression from the given string. * Advances the supplied pointer to just after the expression read. * - * Any allocation will be performed with 'ctx' as the talloc owner. + * Any allocation will be performed with 'ctx' as the ralloc owner. */ static s_expression *read_expression(void *ctx, const char *&src); diff --git a/src/mesa/drivers/dri/i965/brw_cubemap_normalize.cpp b/src/mesa/drivers/dri/i965/brw_cubemap_normalize.cpp index 35bea68121..8574169e47 100644 --- a/src/mesa/drivers/dri/i965/brw_cubemap_normalize.cpp +++ b/src/mesa/drivers/dri/i965/brw_cubemap_normalize.cpp @@ -51,7 +51,7 @@ brw_cubemap_normalize_visitor::visit_leave(ir_texture *ir) if (ir->sampler->type->sampler_dimensionality != GLSL_SAMPLER_DIM_CUBE) return visit_continue; - void *mem_ctx = talloc_parent(ir); + void *mem_ctx = ralloc_parent(ir); ir_variable *var = new(mem_ctx) ir_variable(ir->coordinate->type, "coordinate", ir_var_auto); diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp index e5b2e1758c..c64a4c00c5 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp @@ -55,7 +55,7 @@ brw_new_shader(struct gl_context *ctx, GLuint name, GLuint type) { struct brw_shader *shader; - shader = talloc_zero(NULL, struct brw_shader); + shader = rzalloc(NULL, struct brw_shader); if (shader) { shader->base.Type = type; shader->base.Name = name; @@ -69,7 +69,7 @@ struct gl_shader_program * brw_new_shader_program(struct gl_context *ctx, GLuint name) { struct brw_shader_program *prog; - prog = talloc_zero(NULL, struct brw_shader_program); + prog = rzalloc(NULL, struct brw_shader_program); if (prog) { prog->base.Name = name; _mesa_init_shader_program(ctx, &prog->base); @@ -95,11 +95,11 @@ brw_link_shader(struct gl_context *ctx, struct gl_shader_program *prog) struct brw_shader *shader = (struct brw_shader *)prog->_LinkedShaders[MESA_SHADER_FRAGMENT]; if (shader != NULL) { - void *mem_ctx = talloc_new(NULL); + void *mem_ctx = ralloc_context(NULL); bool progress; if (shader->ir) - talloc_free(shader->ir); + ralloc_free(shader->ir); shader->ir = new(shader) exec_list; clone_ir_list(mem_ctx, shader->ir, shader->base.ir); @@ -149,7 +149,7 @@ brw_link_shader(struct gl_context *ctx, struct gl_shader_program *prog) validate_ir_tree(shader->ir); reparent_ir(shader->ir, shader->ir); - talloc_free(mem_ctx); + ralloc_free(mem_ctx); } if (!_mesa_ir_link_shader(ctx, prog)) @@ -236,8 +236,8 @@ fs_visitor::virtual_grf_alloc(int size) virtual_grf_array_size = 16; else virtual_grf_array_size *= 2; - virtual_grf_sizes = talloc_realloc(mem_ctx, virtual_grf_sizes, - int, virtual_grf_array_size); + virtual_grf_sizes = reralloc(mem_ctx, virtual_grf_sizes, int, + virtual_grf_array_size); /* This slot is always unused. */ virtual_grf_sizes[0] = 0; @@ -2065,7 +2065,7 @@ fs_visitor::emit_fb_writes() } for (int target = 0; target < c->key.nr_color_regions; target++) { - this->current_annotation = talloc_asprintf(this->mem_ctx, + this->current_annotation = ralloc_asprintf(this->mem_ctx, "FB write target %d", target); if (this->frag_color || this->frag_data) { @@ -2755,8 +2755,8 @@ void fs_visitor::calculate_live_intervals() { int num_vars = this->virtual_grf_next; - int *def = talloc_array(mem_ctx, int, num_vars); - int *use = talloc_array(mem_ctx, int, num_vars); + int *def = ralloc_array(mem_ctx, int, num_vars); + int *use = ralloc_array(mem_ctx, int, num_vars); int loop_depth = 0; int loop_start = 0; int bb_header_ip = 0; @@ -2839,8 +2839,8 @@ fs_visitor::calculate_live_intervals() } } - talloc_free(this->virtual_grf_def); - talloc_free(this->virtual_grf_use); + ralloc_free(this->virtual_grf_def); + ralloc_free(this->virtual_grf_use); this->virtual_grf_def = def; this->virtual_grf_use = use; diff --git a/src/mesa/drivers/dri/i965/brw_fs.h b/src/mesa/drivers/dri/i965/brw_fs.h index f0497957bc..59a17f7f3b 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.h +++ b/src/mesa/drivers/dri/i965/brw_fs.h @@ -41,7 +41,6 @@ extern "C" { #include "brw_context.h" #include "brw_eu.h" #include "brw_wm.h" -#include "talloc.h" } #include "../glsl/glsl_types.h" #include "../glsl/ir.h" @@ -83,13 +82,13 @@ enum fs_opcodes { class fs_reg { public: - /* Callers of this talloc-based new need not call delete. It's - * easier to just talloc_free 'ctx' (or any of its ancestors). */ + /* Callers of this ralloc-based new need not call delete. It's + * easier to just ralloc_free 'ctx' (or any of its ancestors). */ static void* operator new(size_t size, void *ctx) { void *node; - node = talloc_size(ctx, size); + node = ralloc_size(ctx, size); assert(node != NULL); return node; @@ -193,13 +192,13 @@ static const fs_reg reg_null_d(ARF, BRW_ARF_NULL, BRW_REGISTER_TYPE_D); class fs_inst : public exec_node { public: - /* Callers of this talloc-based new need not call delete. It's - * easier to just talloc_free 'ctx' (or any of its ancestors). */ + /* Callers of this ralloc-based new need not call delete. It's + * easier to just ralloc_free 'ctx' (or any of its ancestors). */ static void* operator new(size_t size, void *ctx) { void *node; - node = talloc_zero_size(ctx, size); + node = rzalloc_size(ctx, size); assert(node != NULL); return node; @@ -361,7 +360,7 @@ public: this->fp = brw->fragment_program; this->intel = &brw->intel; this->ctx = &intel->ctx; - this->mem_ctx = talloc_new(NULL); + this->mem_ctx = ralloc_context(NULL); this->shader = shader; this->fail = false; this->variable_ht = hash_table_ctor(0, @@ -405,7 +404,7 @@ public: ~fs_visitor() { - talloc_free(this->mem_ctx); + ralloc_free(this->mem_ctx); hash_table_dtor(this->variable_ht); } diff --git a/src/mesa/drivers/dri/i965/brw_fs_channel_expressions.cpp b/src/mesa/drivers/dri/i965/brw_fs_channel_expressions.cpp index 20bfa4c3ea..7f3f52854d 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_channel_expressions.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_channel_expressions.cpp @@ -141,7 +141,7 @@ ir_channel_expressions_visitor::visit_leave(ir_assignment *ir) return visit_continue; if (!this->mem_ctx) - this->mem_ctx = talloc_parent(ir); + this->mem_ctx = ralloc_parent(ir); for (i = 0; i < expr->get_num_operands(); i++) { if (expr->operands[i]->type->is_vector()) { diff --git a/src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp b/src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp index 4ec5b57cde..f027742317 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp @@ -233,8 +233,8 @@ fs_visitor::assign_regs() } - talloc_free(g); - talloc_free(regs); + ralloc_free(g); + ralloc_free(regs); return false; } @@ -272,8 +272,8 @@ fs_visitor::assign_regs() this->grf_used = last_grf + 1; - talloc_free(g); - talloc_free(regs); + ralloc_free(g); + ralloc_free(regs); return true; } diff --git a/src/mesa/drivers/dri/i965/brw_fs_schedule_instructions.cpp b/src/mesa/drivers/dri/i965/brw_fs_schedule_instructions.cpp index b5202d4d2e..bff8f82f3f 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_schedule_instructions.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_schedule_instructions.cpp @@ -128,7 +128,7 @@ public: instruction_scheduler(fs_visitor *v, void *mem_ctx, int virtual_grf_count) { this->v = v; - this->mem_ctx = talloc_new(mem_ctx); + this->mem_ctx = ralloc_context(mem_ctx); this->virtual_grf_count = virtual_grf_count; this->instructions.make_empty(); this->instructions_to_schedule = 0; @@ -136,7 +136,7 @@ public: ~instruction_scheduler() { - talloc_free(this->mem_ctx); + ralloc_free(this->mem_ctx); } void add_barrier_deps(schedule_node *n); void add_dep(schedule_node *before, schedule_node *after, int latency); @@ -195,11 +195,11 @@ instruction_scheduler::add_dep(schedule_node *before, schedule_node *after, else before->child_array_size *= 2; - before->children = talloc_realloc(mem_ctx, before->children, - schedule_node *, - before->child_array_size); - before->child_latency = talloc_realloc(mem_ctx, before->child_latency, - int, before->child_array_size); + before->children = reralloc(mem_ctx, before->children, + schedule_node *, + before->child_array_size); + before->child_latency = reralloc(mem_ctx, before->child_latency, + int, before->child_array_size); } before->children[before->child_count] = after; diff --git a/src/mesa/drivers/dri/i965/brw_fs_vector_splitting.cpp b/src/mesa/drivers/dri/i965/brw_fs_vector_splitting.cpp index 2be6b08b5c..530ffa2658 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_vector_splitting.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_vector_splitting.cpp @@ -69,7 +69,7 @@ public: ir_variable *components[4]; - /** talloc_parent(this->var) -- the shader's talloc context. */ + /** ralloc_parent(this->var) -- the shader's ralloc context. */ void *mem_ctx; }; @@ -77,13 +77,13 @@ class ir_vector_reference_visitor : public ir_hierarchical_visitor { public: ir_vector_reference_visitor(void) { - this->mem_ctx = talloc_new(NULL); + this->mem_ctx = ralloc_context(NULL); this->variable_list.make_empty(); } ~ir_vector_reference_visitor(void) { - talloc_free(mem_ctx); + ralloc_free(mem_ctx); } virtual ir_visitor_status visit(ir_variable *); @@ -358,7 +358,7 @@ brw_do_vector_splitting(exec_list *instructions) if (refs.variable_list.is_empty()) return false; - void *mem_ctx = talloc_new(NULL); + void *mem_ctx = ralloc_context(NULL); /* Replace the decls of the vectors to be split with their split * components. @@ -368,10 +368,10 @@ brw_do_vector_splitting(exec_list *instructions) const struct glsl_type *type; type = glsl_type::get_instance(entry->var->type->base_type, 1, 1); - entry->mem_ctx = talloc_parent(entry->var); + entry->mem_ctx = ralloc_parent(entry->var); for (unsigned int i = 0; i < entry->var->type->vector_elements; i++) { - const char *name = talloc_asprintf(mem_ctx, "%s_%c", + const char *name = ralloc_asprintf(mem_ctx, "%s_%c", entry->var->name, "xyzw"[i]); @@ -386,7 +386,7 @@ brw_do_vector_splitting(exec_list *instructions) ir_vector_splitting_visitor split(&refs.variable_list); visit_list_elements(&split, instructions); - talloc_free(mem_ctx); + ralloc_free(mem_ctx); return true; } diff --git a/src/mesa/drivers/dri/i965/brw_program.c b/src/mesa/drivers/dri/i965/brw_program.c index 94efa79109..7d653327e3 100644 --- a/src/mesa/drivers/dri/i965/brw_program.c +++ b/src/mesa/drivers/dri/i965/brw_program.c @@ -36,7 +36,7 @@ #include "program/program.h" #include "program/programopt.h" #include "tnl/tnl.h" -#include "talloc.h" +#include "../glsl/ralloc.h" #include "brw_context.h" #include "brw_wm.h" @@ -115,7 +115,7 @@ shader_error(struct gl_context *ctx, struct gl_program *prog, const char *msg) shader = _mesa_lookup_shader_program(ctx, prog->Id); if (shader) { - shader->InfoLog = talloc_strdup_append(shader->InfoLog, msg); + ralloc_strcat(&shader->InfoLog, msg); shader->LinkStatus = GL_FALSE; } } diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c index a5e90d7cbd..f2b8aa449e 100644 --- a/src/mesa/main/shaderapi.c +++ b/src/mesa/main/shaderapi.c @@ -48,7 +48,7 @@ #include "program/program.h" #include "program/prog_parameter.h" #include "program/prog_uniform.h" -#include "talloc.h" +#include "ralloc.h" #include <stdbool.h> #include "../glsl/glsl_parser_extras.h" @@ -1137,9 +1137,9 @@ validate_program(struct gl_context *ctx, GLuint program) if (!shProg->Validated) { /* update info log */ if (shProg->InfoLog) { - talloc_free(shProg->InfoLog); + ralloc_free(shProg->InfoLog); } - shProg->InfoLog = talloc_strdup(shProg, errMsg); + shProg->InfoLog = ralloc_strdup(shProg, errMsg); } } @@ -1855,7 +1855,7 @@ _mesa_CreateShaderProgramEXT(GLenum type, const GLchar *string) #endif } - shProg->InfoLog = talloc_strdup_append(shProg->InfoLog, sh->InfoLog); + ralloc_strcat(&shProg->InfoLog, sh->InfoLog); } delete_shader(ctx, shader); diff --git a/src/mesa/main/shaderobj.c b/src/mesa/main/shaderobj.c index 647fd31cab..1d75845590 100644 --- a/src/mesa/main/shaderobj.c +++ b/src/mesa/main/shaderobj.c @@ -38,7 +38,7 @@ #include "program/program.h" #include "program/prog_parameter.h" #include "program/prog_uniform.h" -#include "talloc.h" +#include "ralloc.h" /**********************************************************************/ /*** Shader object functions ***/ @@ -105,7 +105,7 @@ _mesa_new_shader(struct gl_context *ctx, GLuint name, GLenum type) struct gl_shader *shader; assert(type == GL_FRAGMENT_SHADER || type == GL_VERTEX_SHADER || type == GL_GEOMETRY_SHADER_ARB); - shader = talloc_zero(NULL, struct gl_shader); + shader = rzalloc(NULL, struct gl_shader); if (shader) { shader->Type = type; shader->Name = name; @@ -125,7 +125,7 @@ _mesa_delete_shader(struct gl_context *ctx, struct gl_shader *sh) if (sh->Source) free((void *) sh->Source); _mesa_reference_program(ctx, &sh->Program, NULL); - talloc_free(sh); + ralloc_free(sh); } @@ -252,7 +252,7 @@ static struct gl_shader_program * _mesa_new_shader_program(struct gl_context *ctx, GLuint name) { struct gl_shader_program *shProg; - shProg = talloc_zero(NULL, struct gl_shader_program); + shProg = rzalloc(NULL, struct gl_shader_program); if (shProg) { shProg->Name = name; _mesa_init_shader_program(ctx, shProg); @@ -316,7 +316,7 @@ _mesa_free_shader_program_data(struct gl_context *ctx, } if (shProg->InfoLog) { - talloc_free(shProg->InfoLog); + ralloc_free(shProg->InfoLog); shProg->InfoLog = NULL; } @@ -347,7 +347,7 @@ _mesa_delete_shader_program(struct gl_context *ctx, struct gl_shader_program *sh { _mesa_free_shader_program_data(ctx, shProg); - talloc_free(shProg); + ralloc_free(shProg); } diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp index 404b6c646a..3794c0de02 100644 --- a/src/mesa/program/ir_to_mesa.cpp +++ b/src/mesa/program/ir_to_mesa.cpp @@ -105,13 +105,13 @@ extern ir_to_mesa_src_reg ir_to_mesa_undef; class ir_to_mesa_instruction : public exec_node { public: - /* Callers of this talloc-based new need not call delete. It's - * easier to just talloc_free 'ctx' (or any of its ancestors). */ + /* Callers of this ralloc-based new need not call delete. It's + * easier to just ralloc_free 'ctx' (or any of its ancestors). */ static void* operator new(size_t size, void *ctx) { void *node; - node = talloc_zero_size(ctx, size); + node = rzalloc_size(ctx, size); assert(node != NULL); return node; @@ -318,7 +318,7 @@ fail_link(struct gl_shader_program *prog, const char *fmt, ...) { va_list args; va_start(args, fmt); - prog->InfoLog = talloc_vasprintf_append(prog->InfoLog, fmt, args); + ralloc_vasprintf_append(&prog->InfoLog, fmt, args); va_end(args); prog->LinkStatus = GL_FALSE; @@ -1570,7 +1570,7 @@ ir_to_mesa_visitor::visit(ir_dereference_array *ir) this->result, src_reg_for_float(element_size)); } - src_reg.reladdr = talloc(mem_ctx, ir_to_mesa_src_reg); + src_reg.reladdr = ralloc(mem_ctx, ir_to_mesa_src_reg); memcpy(src_reg.reladdr, &index_reg, sizeof(index_reg)); } @@ -1927,7 +1927,7 @@ ir_to_mesa_visitor::get_function_signature(ir_function_signature *sig) return entry; } - entry = talloc(mem_ctx, function_entry); + entry = ralloc(mem_ctx, function_entry); entry->sig = sig; entry->sig_id = this->next_signature_id++; entry->bgn_inst = NULL; @@ -2264,12 +2264,12 @@ ir_to_mesa_visitor::ir_to_mesa_visitor() next_temp = 1; next_signature_id = 1; current_function = NULL; - mem_ctx = talloc_new(NULL); + mem_ctx = ralloc_context(NULL); } ir_to_mesa_visitor::~ir_to_mesa_visitor() { - talloc_free(mem_ctx); + ralloc_free(mem_ctx); } static struct prog_src_register @@ -2318,8 +2318,8 @@ set_branchtargets(ir_to_mesa_visitor *v, } } - if_stack = talloc_zero_array(v->mem_ctx, int, if_count); - loop_stack = talloc_zero_array(v->mem_ctx, int, loop_count); + if_stack = rzalloc_array(v->mem_ctx, int, if_count); + loop_stack = rzalloc_array(v->mem_ctx, int, loop_count); for (i = 0; i < num_instructions; i++) { switch (mesa_instructions[i].Opcode) { @@ -2462,7 +2462,7 @@ add_uniforms_to_parameters_list(struct gl_shader_program *shader_program, unsigned int next_sampler = 0, num_uniforms = 0; struct uniform_sort *sorted_uniforms; - sorted_uniforms = talloc_array(NULL, struct uniform_sort, + sorted_uniforms = ralloc_array(NULL, struct uniform_sort, shader_program->Uniforms->NumUniforms); for (i = 0; i < shader_program->Uniforms->NumUniforms; i++) { @@ -2541,7 +2541,7 @@ add_uniforms_to_parameters_list(struct gl_shader_program *shader_program, } } - talloc_free(sorted_uniforms); + ralloc_free(sorted_uniforms); } static void @@ -2557,7 +2557,7 @@ set_uniform_initializer(struct gl_context *ctx, void *mem_ctx, for (unsigned int i = 0; i < type->length; i++) { const glsl_type *field_type = type->fields.structure[i].type; - const char *field_name = talloc_asprintf(mem_ctx, "%s.%s", name, + const char *field_name = ralloc_asprintf(mem_ctx, "%s.%s", name, type->fields.structure[i].name); set_uniform_initializer(ctx, mem_ctx, shader_program, field_name, field_type, field_constant); @@ -2588,7 +2588,7 @@ set_uniform_initializer(struct gl_context *ctx, void *mem_ctx, void *values; if (element_type->base_type == GLSL_TYPE_BOOL) { - int *conv = talloc_array(mem_ctx, int, element_type->components()); + int *conv = ralloc_array(mem_ctx, int, element_type->components()); for (unsigned int j = 0; j < element_type->components(); j++) { conv[j] = element->value.b[j]; } @@ -2634,14 +2634,14 @@ set_uniform_initializers(struct gl_context *ctx, continue; if (!mem_ctx) - mem_ctx = talloc_new(NULL); + mem_ctx = ralloc_context(NULL); set_uniform_initializer(ctx, mem_ctx, shader_program, var->name, var->type, var->constant_value); } } - talloc_free(mem_ctx); + ralloc_free(mem_ctx); } /* @@ -2667,7 +2667,7 @@ set_uniform_initializers(struct gl_context *ctx, void ir_to_mesa_visitor::copy_propagate(void) { - ir_to_mesa_instruction **acp = talloc_zero_array(mem_ctx, + ir_to_mesa_instruction **acp = rzalloc_array(mem_ctx, ir_to_mesa_instruction *, this->next_temp * 4); @@ -2771,7 +2771,7 @@ ir_to_mesa_visitor::copy_propagate(void) } } - talloc_free(acp); + ralloc_free(acp); } @@ -2870,7 +2870,7 @@ get_mesa_program(struct gl_context *ctx, mesa_instructions = (struct prog_instruction *)calloc(num_instructions, sizeof(*mesa_instructions)); - mesa_instruction_annotation = talloc_array(v.mem_ctx, ir_instruction *, + mesa_instruction_annotation = ralloc_array(v.mem_ctx, ir_instruction *, num_instructions); v.copy_propagate(); @@ -3127,7 +3127,7 @@ _mesa_glsl_compile_shader(struct gl_context *ctx, struct gl_shader *shader) _mesa_glsl_lexer_dtor(state); } - talloc_free(shader->ir); + ralloc_free(shader->ir); shader->ir = new(shader) exec_list; if (!state->error && !state->translation_unit.is_empty()) _mesa_ast_to_hir(shader->ir, state); @@ -3174,7 +3174,7 @@ _mesa_glsl_compile_shader(struct gl_context *ctx, struct gl_shader *shader) /* Retain any live IR, but trash the rest. */ reparent_ir(shader->ir, shader->ir); - talloc_free(state); + ralloc_free(state); if (shader->CompileStatus) { if (!ctx->Driver.CompileShader(ctx, shader)) diff --git a/src/mesa/program/register_allocate.c b/src/mesa/program/register_allocate.c index 700e351841..95a9bde401 100644 --- a/src/mesa/program/register_allocate.c +++ b/src/mesa/program/register_allocate.c @@ -30,7 +30,7 @@ * Graph-coloring register allocator. */ -#include <talloc.h> +#include <ralloc.h> #include "main/imports.h" #include "main/macros.h" @@ -96,15 +96,15 @@ ra_alloc_reg_set(unsigned int count) unsigned int i; struct ra_regs *regs; - regs = talloc_zero(NULL, struct ra_regs); + regs = rzalloc(NULL, struct ra_regs); regs->count = count; - regs->regs = talloc_zero_array(regs, struct ra_reg, count); + regs->regs = rzalloc_array(regs, struct ra_reg, count); for (i = 0; i < count; i++) { - regs->regs[i].conflicts = talloc_zero_array(regs->regs, GLboolean, count); + regs->regs[i].conflicts = rzalloc_array(regs->regs, GLboolean, count); regs->regs[i].conflicts[i] = GL_TRUE; - regs->regs[i].conflict_list = talloc_array(regs->regs, unsigned int, 4); + regs->regs[i].conflict_list = ralloc_array(regs->regs, unsigned int, 4); regs->regs[i].conflict_list_size = 4; regs->regs[i].conflict_list[0] = i; regs->regs[i].num_conflicts = 1; @@ -120,10 +120,8 @@ ra_add_conflict_list(struct ra_regs *regs, unsigned int r1, unsigned int r2) if (reg1->conflict_list_size == reg1->num_conflicts) { reg1->conflict_list_size *= 2; - reg1->conflict_list = talloc_realloc(regs->regs, - reg1->conflict_list, - unsigned int, - reg1->conflict_list_size); + reg1->conflict_list = reralloc(regs->regs, reg1->conflict_list, + unsigned int, reg1->conflict_list_size); } reg1->conflict_list[reg1->num_conflicts++] = r2; reg1->conflicts[r2] = GL_TRUE; @@ -143,14 +141,13 @@ ra_alloc_reg_class(struct ra_regs *regs) { struct ra_class *class; - regs->classes = talloc_realloc(regs->regs, regs->classes, - struct ra_class *, - regs->class_count + 1); + regs->classes = reralloc(regs->regs, regs->classes, struct ra_class *, + regs->class_count + 1); - class = talloc_zero(regs, struct ra_class); + class = rzalloc(regs, struct ra_class); regs->classes[regs->class_count] = class; - class->regs = talloc_zero_array(class, GLboolean, regs->count); + class->regs = rzalloc_array(class, GLboolean, regs->count); return regs->class_count++; } @@ -174,7 +171,7 @@ ra_set_finalize(struct ra_regs *regs) unsigned int b, c; for (b = 0; b < regs->class_count; b++) { - regs->classes[b]->q = talloc_array(regs, unsigned int, regs->class_count); + regs->classes[b]->q = ralloc_array(regs, unsigned int, regs->class_count); } /* Compute, for each class B and C, how many regs of B an @@ -218,16 +215,16 @@ ra_alloc_interference_graph(struct ra_regs *regs, unsigned int count) struct ra_graph *g; unsigned int i; - g = talloc_zero(regs, struct ra_graph); + g = rzalloc(regs, struct ra_graph); g->regs = regs; - g->nodes = talloc_zero_array(g, struct ra_node, count); + g->nodes = rzalloc_array(g, struct ra_node, count); g->count = count; - g->stack = talloc_zero_array(g, unsigned int, count); + g->stack = rzalloc_array(g, unsigned int, count); for (i = 0; i < count; i++) { - g->nodes[i].adjacency = talloc_zero_array(g, GLboolean, count); - g->nodes[i].adjacency_list = talloc_array(g, unsigned int, count); + g->nodes[i].adjacency = rzalloc_array(g, GLboolean, count); + g->nodes[i].adjacency_list = ralloc_array(g, unsigned int, count); g->nodes[i].adjacency_count = 0; ra_add_node_adjacency(g, i, i); g->nodes[i].reg = ~0; diff --git a/src/mesa/program/sampler.cpp b/src/mesa/program/sampler.cpp index 9a813c8795..12c4a40a25 100644 --- a/src/mesa/program/sampler.cpp +++ b/src/mesa/program/sampler.cpp @@ -40,7 +40,7 @@ static void fail_link(struct gl_shader_program *prog, const char *fmt, ...) { va_list args; va_start(args, fmt); - prog->InfoLog = talloc_vasprintf_append(prog->InfoLog, fmt, args); + ralloc_vasprintf_append(&prog->InfoLog, fmt, args); va_end(args); prog->LinkStatus = GL_FALSE; @@ -52,7 +52,7 @@ public: get_sampler_name(ir_dereference *last, struct gl_shader_program *shader_program) { - this->mem_ctx = talloc_new(NULL); + this->mem_ctx = ralloc_context(NULL); this->shader_program = shader_program; this->name = NULL; this->offset = 0; @@ -61,7 +61,7 @@ public: ~get_sampler_name() { - talloc_free(this->mem_ctx); + ralloc_free(this->mem_ctx); } virtual ir_visitor_status visit(ir_dereference_variable *ir) @@ -72,7 +72,7 @@ public: virtual ir_visitor_status visit_leave(ir_dereference_record *ir) { - this->name = talloc_asprintf(mem_ctx, "%s.%s", name, ir->field); + this->name = ralloc_asprintf(mem_ctx, "%s.%s", name, ir->field); return visit_continue; } @@ -91,16 +91,14 @@ public: * all that would work would be an unrolled loop counter that ends * up being constant above. */ - shader_program->InfoLog = - talloc_asprintf_append(shader_program->InfoLog, - "warning: Variable sampler array index " - "unsupported.\nThis feature of the language " - "was removed in GLSL 1.20 and is unlikely " - "to be supported for 1.10 in Mesa.\n"); + ralloc_strcat(&shader_program->InfoLog, + "warning: Variable sampler array index unsupported.\n" + "This feature of the language was removed in GLSL 1.20 " + "and is unlikely to be supported for 1.10 in Mesa.\n"); i = 0; } if (ir != last) { - this->name = talloc_asprintf(mem_ctx, "%s[%d]", name, i); + this->name = ralloc_asprintf(mem_ctx, "%s[%d]", name, i); } else { offset = i; } |