summaryrefslogtreecommitdiffabout
path: root/src/dictionary.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/dictionary.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/dictionary.c') (more/less context) (ignore whitespace changes)
-rw-r--r--src/dictionary.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/dictionary.c b/src/dictionary.c
index b7baf05..2b995d4 100644
--- a/src/dictionary.c
+++ b/src/dictionary.c
@@ -45,14 +45,13 @@ static struct dictionary_descr dictionary_tab[] = {
{ "external", NULL, NULL, NULL, NULL, NULL, NULL, NULL }
};
struct dictionary *
dictionary_new (enum dictionary_id id, enum dictionary_type type)
{
- struct dictionary *mp = xmalloc (sizeof mp[0]);
- memset (mp, 0, sizeof mp[0]);
+ struct dictionary *mp = grecs_zalloc (sizeof mp[0]);
mp->id = id;
mp->type = type;
return mp;
}
int
@@ -89,12 +88,14 @@ dictionary_open (struct dictionary *dict)
}
int
dictionary_close (struct dictionary *dict, void *handle)
{
struct dictionary_descr *mp = dictionary_tab + dict->type;
+ if (mp->free)
+ mp->free (dict, handle);
if (!mp->close)
return 0;
return mp->close (dict, handle);
}
int
@@ -183,13 +184,13 @@ dictionary_result (struct dictionary *dict, void *handle,
void
dictionary_copy_result (struct dictionary *dict, const char *res, size_t size)
{
if (dict->result_size < size + 1)
{
dict->result_size = size + 1;
- dict->result = x2realloc (dict->result, &dict->result_size);
+ dict->result = grecs_realloc (dict->result, dict->result_size);
}
memcpy (dict->result, res, size);
dict->result[size] = 0;
}
/* Quote non-printable characters in INPUT. Point *OUTPUT to the malloc'ed
@@ -203,23 +204,23 @@ dictionary_quote_string (struct dictionary *dict, void *handle,
size_t size;
int quote;
char *output;
if (!input)
{
- *poutput = xmalloc (1);
+ *poutput = grecs_malloc (1);
(*poutput)[0] = 0;
*psize = 1;
return 0;
}
if (mp->quote)
return mp->quote (dict, handle, input, poutput, psize);
size = wordsplit_c_quoted_length (input, 0, &quote);
- output = xmalloc (size + 1);
+ output = grecs_malloc (size + 1);
wordsplit_c_quote_copy (output, input, 0);
output[size] = 0;
*poutput = output;
if (psize)
*psize = size;

Return to:

Send suggestions and report system problems to the System administrator.