From dd7e73ec6c990c23a08d4e82f050804caa9789df Mon Sep 17 00:00:00 2001 From: Thomas Schmucker Date: Sun, 21 Jun 2020 11:12:18 +0200 Subject: Benutze unterschiedliche Callback-Argumente für die Memory- und Error-Callback-Handler MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- csv.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'csv.c') diff --git a/csv.c b/csv.c index 1456d6e..d8321bd 100644 --- a/csv.c +++ b/csv.c @@ -50,7 +50,7 @@ INLINE void csv_fatal_error(const char *msg, const csv_options_t * const csv_options) { if ( csv_options->cb_error != NULL ) { - (*csv_options->cb_error)(msg, csv_options->cb_arg); + (*csv_options->cb_error)(msg, csv_options->cb_error_arg); } fprintf(stderr, "fatal error: %s\n", msg); @@ -95,7 +95,7 @@ csv_string_append(csv_string_t *csv_string, char ch, const csv_options_t * const if ( csv_string->pos == csv_string->cap ) { /* grow if needed */ if ( csv_string->str == NULL ) { /* first call? */ - if ( (csv_string->str = csv_options->cb_allocate(INITIAL_CAP, 1, csv_options->cb_arg)) == NULL ) { + if ( (csv_string->str = csv_options->cb_allocate(INITIAL_CAP, 1, csv_options->cb_memory_arg)) == NULL ) { csv_fatal_error("out of memory...", csv_options); return; } @@ -104,7 +104,7 @@ csv_string_append(csv_string_t *csv_string, char ch, const csv_options_t * const } else { /* subsequent call */ int cap = (csv_string->cap * 3) / 2; /* *= 1.5 */ - char *str = csv_options->cb_reallocate(csv_string->str, cap, 1, csv_options->cb_arg); + char *str = csv_options->cb_reallocate(csv_string->str, cap, 1, csv_options->cb_memory_arg); if ( str == NULL ) { csv_fatal_error("out of memory...", csv_options); return; @@ -123,7 +123,7 @@ csv_string_free(csv_string_t *csv_string, const csv_options_t * const csv_option assert(csv_string != NULL); assert(csv_options != NULL); - csv_options->cb_free(csv_string->str, csv_string->cap, csv_options->cb_arg); + csv_options->cb_free(csv_string->str, csv_string->cap, csv_options->cb_memory_arg); /* call *_init() for sane default values; prevent possible double-free */ csv_string_init(csv_string); @@ -159,7 +159,7 @@ csv_field_append(csv_field_t *csv_field, int idx, const csv_options_t * const cs if ( csv_field->pos == csv_field->cap ) { /* grow if needed */ if ( csv_field->fields == NULL ) { - if ( (csv_field->fields = csv_options->cb_allocate(INITIAL_CAP, sizeof(csv_field->fields[0]), csv_options->cb_arg)) == NULL ) { + if ( (csv_field->fields = csv_options->cb_allocate(INITIAL_CAP, sizeof(csv_field->fields[0]), csv_options->cb_memory_arg)) == NULL ) { csv_fatal_error("out of memory", csv_options); return; } @@ -168,7 +168,7 @@ csv_field_append(csv_field_t *csv_field, int idx, const csv_options_t * const cs } else { int cap = (csv_field->cap * 3) / 2; /* *= 1.5 */ - int *fields = csv_options->cb_reallocate(csv_field->fields, cap, sizeof(csv_field->fields[0]), csv_options->cb_arg); + int *fields = csv_options->cb_reallocate(csv_field->fields, cap, sizeof(csv_field->fields[0]), csv_options->cb_memory_arg); if ( fields == NULL ) { csv_fatal_error("out of memory", csv_options); return; @@ -187,7 +187,7 @@ csv_field_free(csv_field_t *csv_field, const csv_options_t * const csv_options) assert(csv_field != NULL); assert(csv_options != NULL); - csv_options->cb_free(csv_field->fields, csv_field->cap, csv_options->cb_arg); + csv_options->cb_free(csv_field->fields, csv_field->cap, csv_options->cb_memory_arg); csv_field_init(csv_field); } -- cgit v1.3