summaryrefslogtreecommitdiffabout
path: root/src/txtacc.c
Side-by-side diff
Diffstat (limited to 'src/txtacc.c') (more/less context) (show whitespace changes)
-rw-r--r--src/txtacc.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/txtacc.c b/src/txtacc.c
index 91659f6..442e27e 100644
--- a/src/txtacc.c
+++ b/src/txtacc.c
@@ -34,8 +34,8 @@ struct txtacc
static struct txtacc_entry *
txtacc_alloc_entry (struct grecs_list *list, size_t size)
{
- struct txtacc_entry *p = xmalloc (sizeof (*p));
- p->buf = xmalloc (size);
+ struct txtacc_entry *p = grecs_malloc (sizeof (*p));
+ p->buf = grecs_malloc (size);
p->size = size;
p->len = 0;
grecs_list_append (list, p);
@@ -89,7 +89,7 @@ txtacc_entry_free (void *p)
struct txtacc *
txtacc_create ()
{
- struct txtacc *acc = xmalloc (sizeof (*acc));
+ struct txtacc *acc = grecs_malloc (sizeof (*acc));
acc->cur = grecs_list_create ();
acc->cur->free_entry = txtacc_entry_free;
acc->mem = grecs_list_create ();
@@ -137,6 +137,7 @@ txtacc_finish (struct txtacc *acc, int steal)
txtent = acc->cur->head->data;
acc->cur->head->data = NULL;
txtacc_entry_tailor (txtent);
+ grecs_list_append (acc->mem, txtent);
break;
default:
@@ -158,9 +159,10 @@ txtacc_finish (struct txtacc *acc, int steal)
grecs_list_clear (acc->cur);
p = txtent->buf;
if (steal)
+ {
+ grecs_list_remove_tail (acc->mem);
free (txtent);
- else
- grecs_list_append (acc->mem, txtent);
+ }
return p;
}

Return to:

Send suggestions and report system problems to the System administrator.