From 8e48b931091cbc99abeffacc7af80f363495ec23 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Sat, 14 Dec 2013 23:14:09 +0000 Subject: Remove client allocation function. --- src/charset/codec.c | 12 +++--------- src/charset/codecs/codec_8859.c | 6 +----- src/charset/codecs/codec_ascii.c | 8 ++------ src/charset/codecs/codec_ext8.c | 6 +----- src/charset/codecs/codec_impl.h | 4 ---- src/charset/codecs/codec_utf16.c | 8 ++------ src/charset/codecs/codec_utf8.c | 6 +----- 7 files changed, 10 insertions(+), 40 deletions(-) (limited to 'src/charset') diff --git a/src/charset/codec.c b/src/charset/codec.c index ed095cc..3267f1f 100644 --- a/src/charset/codec.c +++ b/src/charset/codec.c @@ -29,8 +29,6 @@ static parserutils_charset_handler *handler_table[] = { * Create a charset codec * * \param charset Target charset - * \param alloc Memory (de)allocation function - * \param pw Pointer to client-specific private data (may be NULL) * \param codec Pointer to location to receive codec instance * \return PARSERUTILS_OK on success, * PARSERUTILS_BADPARM on bad parameters, @@ -38,7 +36,6 @@ static parserutils_charset_handler *handler_table[] = { * PARSERUTILS_BADENCODING on unsupported charset */ parserutils_error parserutils_charset_codec_create(const char *charset, - parserutils_alloc alloc, void *pw, parserutils_charset_codec **codec) { parserutils_charset_codec *c; @@ -46,7 +43,7 @@ parserutils_error parserutils_charset_codec_create(const char *charset, const parserutils_charset_aliases_canon * canon; parserutils_error error; - if (charset == NULL || alloc == NULL || codec == NULL) + if (charset == NULL || codec == NULL) return PARSERUTILS_BADPARM; /* Canonicalise parserutils_charset name. */ @@ -66,7 +63,7 @@ parserutils_error parserutils_charset_codec_create(const char *charset, return PARSERUTILS_BADENCODING; /* Instantiate class */ - error = (*handler)->create(canon->name, alloc, pw, &c); + error = (*handler)->create(canon->name, &c); if (error != PARSERUTILS_OK) return error; @@ -75,9 +72,6 @@ parserutils_error parserutils_charset_codec_create(const char *charset, c->errormode = PARSERUTILS_CHARSET_CODEC_ERROR_LOOSE; - c->alloc = alloc; - c->alloc_pw = pw; - *codec = c; return PARSERUTILS_OK; @@ -97,7 +91,7 @@ parserutils_error parserutils_charset_codec_destroy( codec->handler.destroy(codec); - codec->alloc(codec, 0, codec->alloc_pw); + free(codec); return PARSERUTILS_OK; } diff --git a/src/charset/codecs/codec_8859.c b/src/charset/codecs/codec_8859.c index d323ca0..0ab4c32 100644 --- a/src/charset/codecs/codec_8859.c +++ b/src/charset/codecs/codec_8859.c @@ -64,7 +64,6 @@ typedef struct charset_8859_codec { static bool charset_8859_codec_handles_charset(const char *charset); static parserutils_error charset_8859_codec_create(const char *charset, - parserutils_alloc alloc, void *pw, parserutils_charset_codec **codec); static parserutils_error charset_8859_codec_destroy( parserutils_charset_codec *codec); @@ -123,15 +122,12 @@ bool charset_8859_codec_handles_charset(const char *charset) * Create an ISO-8859-n codec * * \param charset The charset to read from / write to - * \param alloc Memory (de)allocation function - * \param pw Pointer to client-specific private data (may be NULL) * \param codec Pointer to location to receive codec * \return PARSERUTILS_OK on success, * PARSERUTILS_BADPARM on bad parameters, * PARSERUTILS_NOMEM on memory exhausion */ parserutils_error charset_8859_codec_create(const char *charset, - parserutils_alloc alloc, void *pw, parserutils_charset_codec **codec) { uint32_t i; @@ -149,7 +145,7 @@ parserutils_error charset_8859_codec_create(const char *charset, assert(table != NULL); - c = alloc(NULL, sizeof(charset_8859_codec), pw); + c = malloc(sizeof(charset_8859_codec)); if (c == NULL) return PARSERUTILS_NOMEM; diff --git a/src/charset/codecs/codec_ascii.c b/src/charset/codecs/codec_ascii.c index b73280c..64991df 100644 --- a/src/charset/codecs/codec_ascii.c +++ b/src/charset/codecs/codec_ascii.c @@ -37,8 +37,7 @@ typedef struct charset_ascii_codec { static bool charset_ascii_codec_handles_charset(const char *charset); static parserutils_error charset_ascii_codec_create( - const char *charset, parserutils_alloc alloc, void *pw, - parserutils_charset_codec **codec); + const char *charset, parserutils_charset_codec **codec); static parserutils_error charset_ascii_codec_destroy( parserutils_charset_codec *codec); static parserutils_error charset_ascii_codec_encode( @@ -90,22 +89,19 @@ bool charset_ascii_codec_handles_charset(const char *charset) * Create a US-ASCII codec * * \param charset The charset to read from / write to - * \param alloc Memory (de)allocation function - * \param pw Pointer to client-specific private data (may be NULL) * \param codec Pointer to location to receive codec * \return PARSERUTILS_OK on success, * PARSERUTILS_BADPARM on bad parameters, * PARSERUTILS_NOMEM on memory exhausion */ parserutils_error charset_ascii_codec_create(const char *charset, - parserutils_alloc alloc, void *pw, parserutils_charset_codec **codec) { charset_ascii_codec *c; UNUSED(charset); - c = alloc(NULL, sizeof(charset_ascii_codec), pw); + c = malloc(sizeof(charset_ascii_codec)); if (c == NULL) return PARSERUTILS_NOMEM; diff --git a/src/charset/codecs/codec_ext8.c b/src/charset/codecs/codec_ext8.c index 5e7cb8a..eb9c898 100644 --- a/src/charset/codecs/codec_ext8.c +++ b/src/charset/codecs/codec_ext8.c @@ -58,7 +58,6 @@ typedef struct charset_ext8_codec { static bool charset_ext8_codec_handles_charset(const char *charset); static parserutils_error charset_ext8_codec_create(const char *charset, - parserutils_alloc alloc, void *pw, parserutils_charset_codec **codec); static parserutils_error charset_ext8_codec_destroy( parserutils_charset_codec *codec); @@ -117,15 +116,12 @@ bool charset_ext8_codec_handles_charset(const char *charset) * Create an extended 8bit codec * * \param charset The charset to read from / write to - * \param alloc Memory (de)allocation function - * \param pw Pointer to client-specific private data (may be NULL) * \param codec Pointer to location to receive codec * \return PARSERUTILS_OK on success, * PARSERUTILS_BADPARM on bad parameters, * PARSERUTILS_NOMEM on memory exhausion */ parserutils_error charset_ext8_codec_create(const char *charset, - parserutils_alloc alloc, void *pw, parserutils_charset_codec **codec) { uint32_t i; @@ -143,7 +139,7 @@ parserutils_error charset_ext8_codec_create(const char *charset, assert(table != NULL); - c = alloc(NULL, sizeof(charset_ext8_codec), pw); + c = malloc(sizeof(charset_ext8_codec)); if (c == NULL) return PARSERUTILS_NOMEM; diff --git a/src/charset/codecs/codec_impl.h b/src/charset/codecs/codec_impl.h index 09f622c..a14a3f6 100644 --- a/src/charset/codecs/codec_impl.h +++ b/src/charset/codecs/codec_impl.h @@ -21,9 +21,6 @@ struct parserutils_charset_codec { parserutils_charset_codec_errormode errormode; /**< error mode */ - parserutils_alloc alloc; /**< allocation function */ - void *alloc_pw; /**< private word */ - struct { parserutils_error (*destroy)(parserutils_charset_codec *codec); parserutils_error (*encode)(parserutils_charset_codec *codec, @@ -42,7 +39,6 @@ struct parserutils_charset_codec { typedef struct parserutils_charset_handler { bool (*handles_charset)(const char *charset); parserutils_error (*create)(const char *charset, - parserutils_alloc alloc, void *pw, parserutils_charset_codec **codec); } parserutils_charset_handler; diff --git a/src/charset/codecs/codec_utf16.c b/src/charset/codecs/codec_utf16.c index 8dbcae1..19d8bbb 100644 --- a/src/charset/codecs/codec_utf16.c +++ b/src/charset/codecs/codec_utf16.c @@ -42,8 +42,7 @@ typedef struct charset_utf16_codec { } charset_utf16_codec; static bool charset_utf16_codec_handles_charset(const char *charset); -static parserutils_error charset_utf16_codec_create( - const char *charset, parserutils_alloc alloc, void *pw, +static parserutils_error charset_utf16_codec_create(const char *charset, parserutils_charset_codec **codec); static parserutils_error charset_utf16_codec_destroy( parserutils_charset_codec *codec); @@ -82,22 +81,19 @@ bool charset_utf16_codec_handles_charset(const char *charset) * Create a UTF-16 codec * * \param charset The charset to read from / write to - * \param alloc Memory (de)allocation function - * \param pw Pointer to client-specific private data (may be NULL) * \param codec Pointer to location to receive codec * \return PARSERUTILS_OK on success, * PARSERUTILS_BADPARM on bad parameters, * PARSERUTILS_NOMEM on memory exhausion */ parserutils_error charset_utf16_codec_create(const char *charset, - parserutils_alloc alloc, void *pw, parserutils_charset_codec **codec) { charset_utf16_codec *c; UNUSED(charset); - c = alloc(NULL, sizeof(charset_utf16_codec), pw); + c = malloc(sizeof(charset_utf16_codec)); if (c == NULL) return PARSERUTILS_NOMEM; diff --git a/src/charset/codecs/codec_utf8.c b/src/charset/codecs/codec_utf8.c index ceae951..4de7273 100644 --- a/src/charset/codecs/codec_utf8.c +++ b/src/charset/codecs/codec_utf8.c @@ -43,7 +43,6 @@ typedef struct charset_utf8_codec { static bool charset_utf8_codec_handles_charset(const char *charset); static parserutils_error charset_utf8_codec_create(const char *charset, - parserutils_alloc alloc, void *pw, parserutils_charset_codec **codec); static parserutils_error charset_utf8_codec_destroy( parserutils_charset_codec *codec); @@ -83,22 +82,19 @@ bool charset_utf8_codec_handles_charset(const char *charset) * Create a UTF-8 codec * * \param charset The charset to read from / write to - * \param alloc Memory (de)allocation function - * \param pw Pointer to client-specific private data (may be NULL) * \param codec Pointer to location to receive codec * \return PARSERUTILS_OK on success, * PARSERUTILS_BADPARM on bad parameters, * PARSERUTILS_NOMEM on memory exhausion */ parserutils_error charset_utf8_codec_create(const char *charset, - parserutils_alloc alloc, void *pw, parserutils_charset_codec **codec) { charset_utf8_codec *c; UNUSED(charset); - c = alloc(NULL, sizeof(charset_utf8_codec), pw); + c = malloc(sizeof(charset_utf8_codec)); if (c == NULL) return PARSERUTILS_NOMEM; -- cgit v1.2.3