summaryrefslogtreecommitdiffabout
path: root/src/txtacc.c
authorSergey Poznyakoff <gray@gnu.org.ua>2011-05-13 07:21:43 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2011-05-13 07:33:34 (GMT)
commitde3fbe3e8d4dd2a89f7755906d76055784c437cc (patch) (side-by-side diff)
tree65356dd7b5a9010499550c468e960c93515a7e15 /src/txtacc.c
parentf569a6f2628b9ddef4dfb4424aff2dad644a8f19 (diff)
downloadwydawca-de3fbe3e8d4dd2a89f7755906d76055784c437cc.tar.gz
wydawca-de3fbe3e8d4dd2a89f7755906d76055784c437cc.tar.bz2
Drop gnulib.
* bootstrap: Rewrite. * bootstrap.conf: Remove. * configure.ac: Remove gl_EARLY/gl_INIT * src/backup.c: New file. * src/txtacc.c (txtacc_finish): Make sure a new entry is appended only once to the list. * (all sources): Use grecs memory allocation functions. * src/wydawca.h" Include fnmatch.h and regex.h (backup_type): New enum. (simple_backup_suffix): New extern. (find_backup_file_name): New proto. * tests/bkupname.c: New file. * tests/backup00.at: New file. * tests/backup01.at: New file. * tests/backup02.at: New file. * tests/backup03.at: New file. * tests/Makefile.am: Add new tests. * tests/testsuite.at: Add new tests. * grecs: Update.
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
@@ -31,14 +31,14 @@ struct txtacc
struct grecs_list *mem; /* List of already allocated elements */
};
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);
return p;
}
@@ -86,13 +86,13 @@ 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 ();
acc->mem->free_entry = txtacc_entry_free;
return acc;
}
@@ -134,12 +134,13 @@ txtacc_finish (struct txtacc *acc, int steal)
return NULL;
case 1:
txtent = acc->cur->head->data;
acc->cur->head->data = NULL;
txtacc_entry_tailor (txtent);
+ grecs_list_append (acc->mem, txtent);
break;
default:
size = 0;
for (ep = acc->cur->head; ep; ep = ep->next)
{
@@ -155,15 +156,16 @@ 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;
}
void
txtacc_free_string (struct txtacc *acc, char *str)
{

Return to:

Send suggestions and report system problems to the System administrator.