LIBGLCPP_SOURCES = \
glcpp/glcpp-lex.c \
glcpp/glcpp-parse.c \
- glcpp/pp.c \
- glcpp/xtalloc.c
+ glcpp/pp.c
GLCPP_SOURCES = \
$(LIBGLCPP_SOURCES) \
glcpp-lex.l \
glcpp-parse.y \
glcpp.h \
- pp.c \
- xtalloc.c
+ pp.c
BUILT_SOURCES = glcpp-parse.h glcpp-parse.c glcpp-lex.c
CLEANFILES = $(BUILT_SOURCES)
}
{HASH}(version) {
- yylval->str = xtalloc_strdup (yyextra, yytext);
+ yylval->str = talloc_strdup (yyextra, yytext);
yylineno++;
yycolumn = 0;
yyextra->space_tokens = 0;
/* 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 = xtalloc_strdup (yyextra, yytext);
+ yylval->str = talloc_strdup (yyextra, yytext);
yylineno++;
yycolumn = 0;
return OTHER;
}
{DECIMAL_INTEGER} {
- yylval->str = xtalloc_strdup (yyextra, yytext);
+ yylval->str = talloc_strdup (yyextra, yytext);
return INTEGER_STRING;
}
{OCTAL_INTEGER} {
- yylval->str = xtalloc_strdup (yyextra, yytext);
+ yylval->str = talloc_strdup (yyextra, yytext);
return INTEGER_STRING;
}
{HEXADECIMAL_INTEGER} {
- yylval->str = xtalloc_strdup (yyextra, yytext);
+ yylval->str = talloc_strdup (yyextra, yytext);
return INTEGER_STRING;
}
}
{IDENTIFIER} {
- yylval->str = xtalloc_strdup (yyextra, yytext);
+ yylval->str = talloc_strdup (yyextra, yytext);
return IDENTIFIER;
}
}
{OTHER}+ {
- yylval->str = xtalloc_strdup (yyextra, yytext);
+ yylval->str = talloc_strdup (yyextra, yytext);
return OTHER;
}
{
string_list_t *list;
- list = xtalloc (ctx, string_list_t);
+ list = talloc (ctx, string_list_t);
list->head = NULL;
list->tail = NULL;
{
string_node_t *node;
- node = xtalloc (list, string_node_t);
- node->str = xtalloc_strdup (node, str);
+ node = talloc (list, string_node_t);
+ node->str = talloc_strdup (node, str);
node->next = NULL;
{
argument_list_t *list;
- list = xtalloc (ctx, argument_list_t);
+ list = talloc (ctx, argument_list_t);
list->head = NULL;
list->tail = NULL;
{
argument_node_t *node;
- node = xtalloc (list, argument_node_t);
+ node = talloc (list, argument_node_t);
node->argument = argument;
node->next = NULL;
{
token_t *token;
- token = xtalloc (ctx, token_t);
+ token = talloc (ctx, token_t);
token->type = type;
token->value.str = talloc_steal (token, str);
{
token_t *token;
- token = xtalloc (ctx, token_t);
+ token = talloc (ctx, token_t);
token->type = type;
token->value.ival = ival;
{
token_list_t *list;
- list = xtalloc (ctx, token_list_t);
+ list = talloc (ctx, token_list_t);
list->head = NULL;
list->tail = NULL;
list->non_space_tail = NULL;
{
token_node_t *node;
- node = xtalloc (list, token_node_t);
- node->token = xtalloc_reference (list, token);
+ node = talloc (list, token_node_t);
+ node->token = talloc_reference (list, token);
node->next = NULL;
{
char *str;
- str = xtalloc_asprintf (token, "%s%s",
- token->value.str, other->value.str);
+ str = talloc_asprintf (token, "%s%s", token->value.str,
+ other->value.str);
combined = _token_create_str (token, token->type, str);
combined->location = token->location;
return combined;
glcpp_parser_t *parser;
int language_version;
- parser = xtalloc (NULL, glcpp_parser_t);
+ parser = talloc (NULL, glcpp_parser_t);
glcpp_lex_init_extra (parser, &parser->scanner);
parser->defines = hash_table_ctor (32, hash_table_string_hash,
token_list_t *expansion;
token_t *final;
- str = xtalloc_strdup (parser, token->value.str);
+ str = talloc_strdup (parser, token->value.str);
final = _token_create_str (parser, OTHER, str);
expansion = _token_list_create (parser);
_token_list_append (expansion, final);
{
active_list_t *node;
- node = xtalloc (list, active_list_t);
- node->identifier = xtalloc_strdup (node, identifier);
+ node = talloc (list, active_list_t);
+ node->identifier = talloc_strdup (node, identifier);
node->marker = marker;
node->next = list;
if (loc != NULL)
_check_for_reserved_macro_name(parser, loc, identifier);
- macro = xtalloc (parser, macro_t);
+ macro = talloc (parser, macro_t);
macro->is_function = 0;
macro->parameters = NULL;
_check_for_reserved_macro_name(parser, loc, identifier);
- macro = xtalloc (parser, macro_t);
+ macro = talloc (parser, macro_t);
macro->is_function = 1;
macro->parameters = talloc_steal (macro, parameters);
if (parser->skip_stack)
current = parser->skip_stack->type;
- node = xtalloc (parser, skip_node_t);
+ node = talloc (parser, skip_node_t);
node->loc = *loc;
if (current == SKIP_NO_SKIP) {
int
yyparse (glcpp_parser_t *parser);
-/* xtalloc - wrappers around talloc to check for out-of-memory */
-
-#define xtalloc(ctx, type) (type *)xtalloc_named_const(ctx, sizeof(type), #type)
-
-#define xtalloc_size(ctx, size) xtalloc_named_const(ctx, size, __location__)
-
-void *
-xtalloc_named_const (const void *context, size_t size, const char *name);
-
-char *
-xtalloc_strdup (const void *t, const char *p);
-
-char *
-xtalloc_strndup (const void *t, const char *p, size_t n);
-
-char *
-xtalloc_asprintf (const void *t, const char *fmt, ...);
-
-void *
-_xtalloc_reference_loc (const void *context,
- const void *ptr, const char *location);
-
-#define xtalloc_reference(ctx, ptr) (_TALLOC_TYPEOF(ptr))_xtalloc_reference_loc((ctx),(ptr), __location__)
-
#endif
+++ /dev/null
-/*
- * Copyright © 2010 Intel Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
-
-#include "glcpp.h"
-
-void *
-xtalloc_named_const (const void *context, size_t size, const char *name)
-{
- void *ret;
-
- ret = talloc_named_const (context, size, name);
- if (ret == NULL) {
- fprintf (stderr, "Out of memory.\n");
- exit (1);
- }
-
- return ret;
-}
-
-char *
-xtalloc_strdup (const void *t, const char *p)
-{
- char *ret;
-
- ret = talloc_strdup (t, p);
- if (ret == NULL) {
- fprintf (stderr, "Out of memory.\n");
- exit (1);
- }
-
- return ret;
-}
-
-char *
-xtalloc_strndup (const void *t, const char *p, size_t n)
-{
- char *ret;
-
- ret = talloc_strndup (t, p, n);
- if (ret == NULL) {
- fprintf (stderr, "Out of memory.\n");
- exit (1);
- }
-
- return ret;
-}
-
-char *
-xtalloc_asprintf (const void *t, const char *fmt, ...)
-{
- va_list ap;
- char *ret;
-
- va_start(ap, fmt);
-
- ret = talloc_vasprintf(t, fmt, ap);
- if (ret == NULL) {
- fprintf (stderr, "Out of memory.\n");
- exit (1);
- }
-
- va_end(ap);
- return ret;
-}
-
-void *
-_xtalloc_reference_loc (const void *context,
- const void *ptr, const char *location)
-{
- void *ret;
-
- ret = _talloc_reference_loc (context, ptr, location);
- if (ret == NULL) {
- fprintf (stderr, "Out of memory.\n");
- exit (1);
- }
-
- return ret;
-}