summaryrefslogtreecommitdiffabout
path: root/src/preproc.c
authorSergey Poznyakoff <gray@gnu.org.ua>2011-05-06 21:24:03 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2011-05-06 21:24:03 (GMT)
commited39daa568d162617a183497010d70a55a38ae73 (patch) (side-by-side diff)
tree313c1caef8b42ab1800f5c1cef8dece9116fbd0d /src/preproc.c
parent18d7db07b9f369901300bf664d07d4b39032ce64 (diff)
downloadgrecs-ed39daa568d162617a183497010d70a55a38ae73.tar.gz
grecs-ed39daa568d162617a183497010d70a55a38ae73.tar.bz2
Redo memory management (2).
* src/grecs.h (grecs_free_fun): New extern. (grecs_free): New proto. * src/format.c: Use grecs_free where appropriate. * src/grecs-lex.l: Likewise. * src/preproc.c: Likewise. * src/tree.c: Likewise. * src/lookup.c (parse_label): Use grecs_value_list_create. * src/mem.c: Initialize hooks with the default values. (grecs_free_fun): New hook. (grecs_free): New function. * doc/grecs_malloc.3: Document grecs_free. * doc/grecs_parse.3: Document the recent changes. * doc/grecs_strdup.3: Update.
Diffstat (limited to 'src/preproc.c') (more/less context) (ignore whitespace changes)
-rw-r--r--src/preproc.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/preproc.c b/src/preproc.c
index 06924c1..28f473f 100644
--- a/src/preproc.c
+++ b/src/preproc.c
@@ -269,7 +269,7 @@ pp_list_find(struct grecs_list *list, struct file_data *dptr)
static void
incl_free(void *data)
{
- free(data);
+ grecs_free(data);
}
void
@@ -315,7 +315,7 @@ grecs_include_path_setup(const char *dir, ...)
p = va_arg(ap, const char*);
}
grecs_include_path_setup_v(argv);
- free(argv);
+ grecs_free(argv);
va_end(ap);
}
@@ -452,7 +452,7 @@ pop_source()
/* Restore previous context */
ctx = context_stack->prev;
- free(context_stack);
+ grecs_free(context_stack);
context_stack = ctx;
if (!context_stack) {
@@ -541,7 +541,7 @@ parse_include(const char *text, int once)
if (p)
rc = push_source(p, once);
- free(tmp);
+ grecs_free(tmp);
wordsplit_free(&ws);
return rc;
}
@@ -556,9 +556,9 @@ void
grecs_preproc_done()
{
grecs_symtab_free(incl_sources);
- free(linebuf);
- free(putback_buffer);
- free(linebufbase);
+ grecs_free(linebuf);
+ grecs_free(putback_buffer);
+ free(linebufbase); /* Allocated via standard malloc/realloc */
}
int
@@ -579,7 +579,7 @@ grecs_preproc_run(const char *config_file, const char *extpp)
if (grecs_asprintf(&cmd, &size,
"%s %s -", extpp, setup_file))
grecs_alloc_die();
- free(setup_file);
+ grecs_free(setup_file);
} else
cmd = grecs_strdup (extpp);
/*FIXME_DEBUG_F1 (2, "Running preprocessor: `%s'", cmd);*/
@@ -588,14 +588,14 @@ grecs_preproc_run(const char *config_file, const char *extpp)
grecs_error(NULL, errno,
_("Unable to start external preprocessor `%s'"),
cmd);
- free(cmd);
+ grecs_free(cmd);
return 1;
}
while ((i = grecs_preproc_fill_buffer(buffer, sizeof buffer)))
fwrite(buffer, 1, i, outfile);
pclose(outfile);
- free(cmd);
+ grecs_free(cmd);
} else {
while ((i = grecs_preproc_fill_buffer(buffer, sizeof buffer)))
fwrite(buffer, 1, i, stdout);

Return to:

Send suggestions and report system problems to the System administrator.