From: Kevin Day Date: Sat, 16 Jan 2021 04:28:28 +0000 (-0600) Subject: Update: fix regressions due to recent mass structural changes and apply some updates. X-Git-Tag: 0.5.3~120 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=9357f6060cef45c352219b6f3b6201919e933632;p=fll Update: fix regressions due to recent mass structural changes and apply some updates. Fix typo in documentation 'object' should be 'name'. Remove *_quote_delete() and *_quote_destroy() functions. When I fixed the logic in some of the macros and the recently added functions, I failed to do so for some of the memory structure functions. This caused failures during the Featureless Make "make" compilation. I decided to go ahead and expand the macros, which was necessary for exposing the bug but I decided to keep them expanded. These are private functions and the macros are there for helpers not so much as a rule. The expansions directly call the f_memory_delete() and f_memory_destroy() functions (good thing I decided to keep those!). In some cases, use *_increase() functions where possible. Get rid of moe of the old FSS private functions that are now functional duplicates of functionality now provided by the f_type_aray, f_string, and f_memory. This will be an ongoing thing. Remove stale comments referencing "f_memory_out". A bug was discovered (not a regression) where I used incorrect logic and was acting on potentially unallocated memory when passing the contents_quoted to another function. Call the appropriate *_increase() function before getting the memory address to a content quote. This bug is also causing problems with the Featureless Make "make" process. --- diff --git a/level_0/f_console/c/console.c b/level_0/f_console/c/console.c index d271fee..98f8961 100644 --- a/level_0/f_console/c/console.c +++ b/level_0/f_console/c/console.c @@ -81,13 +81,11 @@ extern "C" { if (needs_value.used > 0) { i = needs_value.array[0]; - if (parameters.parameter[i].values.used + 1 > parameters.parameter[i].values.size) { - f_macro_array_lengths_t_resize(status, parameters.parameter[i].values, parameters.parameter[i].values.size + f_memory_default_allocation_step); + f_macro_array_lengths_t_increase(status, parameters.parameter[i].values) - if (F_status_is_error(status)) { - f_macro_string_lengths_t_delete_simple(needs_value); - return status; - } + if (F_status_is_error(status)) { + f_macro_string_lengths_t_delete_simple(needs_value); + return status; } parameters.parameter[i].result = f_console_result_additional; @@ -198,22 +196,18 @@ extern "C" { continue; } - if (parameters.parameter[i].locations.used + 1 > parameters.parameter[i].locations.size) { - f_macro_string_lengths_t_resize(status, parameters.parameter[i].locations, parameters.parameter[i].locations.size + f_memory_default_allocation_step); + f_macro_string_lengths_t_increase(status, parameters.parameter[i].locations) - if (F_status_is_error(status)) { - f_macro_string_lengths_t_delete_simple(needs_value); - return status; - } + if (F_status_is_error(status)) { + f_macro_string_lengths_t_delete_simple(needs_value); + return status; } - if (parameters.parameter[i].locations_sub.used == parameters.parameter[i].locations_sub.size) { - f_macro_string_lengths_t_resize(status, parameters.parameter[i].locations_sub, parameters.parameter[i].locations_sub.size + f_memory_default_allocation_step); + f_macro_string_lengths_t_increase(status, parameters.parameter[i].locations_sub) - if (F_status_is_error(status)) { - f_macro_string_lengths_t_delete_simple(needs_value); - return status; - } + if (F_status_is_error(status)) { + f_macro_string_lengths_t_delete_simple(needs_value); + return status; } parameters.parameter[i].locations.array[parameters.parameter[i].locations.used++] = location; @@ -262,22 +256,18 @@ extern "C" { if (strncmp(arguments.argv[location], parameters.parameter[i].symbol_other, argument_length + 1) != 0) continue; - if (parameters.parameter[i].locations.used == parameters.parameter[i].locations.size) { - f_macro_string_lengths_t_resize(status, parameters.parameter[i].locations, parameters.parameter[i].locations.size + f_memory_default_allocation_step); + f_macro_string_lengths_t_increase(status, parameters.parameter[i].locations) - if (F_status_is_error(status)) { - f_macro_string_lengths_t_delete_simple(needs_value); - return status; - } + if (F_status_is_error(status)) { + f_macro_string_lengths_t_delete_simple(needs_value); + return status; } - if (parameters.parameter[i].locations_sub.used == parameters.parameter[i].locations_sub.size) { - f_macro_string_lengths_t_resize(status, parameters.parameter[i].locations_sub, parameters.parameter[i].locations_sub.size + f_memory_default_allocation_step); + f_macro_string_lengths_t_increase(status, parameters.parameter[i].locations_sub) - if (F_status_is_error(status)) { - f_macro_string_lengths_t_delete_simple(needs_value); - return status; - } + if (F_status_is_error(status)) { + f_macro_string_lengths_t_delete_simple(needs_value); + return status; } parameters.parameter[i].locations.array[parameters.parameter[i].locations.used++] = location; diff --git a/level_0/f_fss/c/fss_named.h b/level_0/f_fss/c/fss_named.h index 060f8a1..a728c84 100644 --- a/level_0/f_fss/c/fss_named.h +++ b/level_0/f_fss/c/fss_named.h @@ -22,7 +22,7 @@ extern "C" { * The objects, contents, and quotess should each be of the same used and size. * Any deviation to this would require implementing custom equivelents to the standard management macros. * - * object: The name representing this set. + * name: The name representing this set. * objects: The array of objects. * contents: The array of contents. * quotess: The array of quote for each content. @@ -39,7 +39,7 @@ extern "C" { #define f_fss_named_t_initialize { f_fss_object_t_initialize, f_fss_objects_t_initialize, f_fss_contents_t_initialize, f_fss_quotess_t_initialize } #define f_macro_fss_named_t_clear(named) \ - f_macro_fss_object_t_clear(named.object) \ + f_macro_fss_object_t_clear(named.name) \ f_macro_fss_objects_t_clear(named.objects) \ f_macro_fss_contents_t_clear(named.contents) \ f_macro_fss_quotess_t_clear(named.quotess) diff --git a/level_0/f_fss/c/fss_set.c b/level_0/f_fss/c/fss_set.c index 38f4ff1..d6d5201 100644 --- a/level_0/f_fss/c/fss_set.c +++ b/level_0/f_fss/c/fss_set.c @@ -138,26 +138,6 @@ extern "C" { } #endif // _di_f_fss_set_quote_decrease_by_ -#ifndef _di_f_fss_set_quote_delete_ - f_status_t f_fss_set_quote_delete(f_fss_set_quote_t *set_quote) { - #ifndef _di_level_0_parameter_checking_ - if (!set_quote) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return private_f_fss_set_quote_resize(0, set_quote); - } -#endif // _di_f_fss_set_quote_delete_ - -#ifndef _di_f_fss_set_quote_destroy_ - f_status_t f_fss_set_quote_destroy(f_fss_set_quote_t *set_quote) { - #ifndef _di_level_0_parameter_checking_ - if (!set_quote) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return private_f_fss_set_quote_adjust(0, set_quote); - } -#endif // _di_f_fss_set_quote_destroy_ - #ifndef _di_f_fss_set_quote_increase_ f_status_t f_fss_set_quote_increase(f_fss_set_quote_t *set_quote) { #ifndef _di_level_0_parameter_checking_ diff --git a/level_0/f_fss/c/fss_set.h b/level_0/f_fss/c/fss_set.h index d88e045..42419b7 100644 --- a/level_0/f_fss/c/fss_set.h +++ b/level_0/f_fss/c/fss_set.h @@ -111,8 +111,8 @@ extern "C" { #define f_macro_fss_set_quote_t_resize(status, set_quote, length) status = f_fss_set_quote_resize(length, &set_quote); #define f_macro_fss_set_quote_t_adjust(status, set_quote, length) status = f_fss_set_quote_adjust(length, &set_quote); - #define f_macro_fss_set_quote_t_delete_simple(set_quote) f_fss_set_quote_delete(&set_quote); - #define f_macro_fss_set_quote_t_destroy_simple(set_quote) f_fss_set_quote_destroy(&set_quote); + #define f_macro_fss_set_quote_t_delete_simple(set_quote) f_fss_set_quote_resize(0, &set_quote); + #define f_macro_fss_set_quote_t_destroy_simple(set_quote) f_fss_set_quote_adjust(0, &set_quote); #define f_macro_fss_set_quote_t_increase(status, set_quote) status = f_fss_set_quote_increase(&set_quote); #define f_macro_fss_set_quote_t_increase_by(status, set_quote, amount) status = f_fss_set_quote_increase_by(amount, &set_quote); @@ -339,36 +339,6 @@ extern "C" { #endif // _di_f_fss_set_quote_decrease_by_ /** - * Delete the array of set_quote. - * - * @param ranges - * The ranges to delete. - * - * @return - * F_none on success. - * - * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_f_fss_set_quote_delete_ - extern f_status_t f_fss_set_quote_delete(f_fss_set_quote_t *ranges); -#endif // _di_f_fss_set_quote_delete_ - -/** - * Delete the array of set_quote. - * - * @param set_quote - * The set_quote to destroy. - * - * @return - * F_none on success. - * - * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_f_fss_set_quote_destroy_ - extern f_status_t f_fss_set_quote_destroy(f_fss_set_quote_t *set_quote); -#endif // _di_f_fss_set_quote_destroy_ - -/** * Increase the size of the set_quote array, but only if necessary. * * If the given length is too large for the buffer, then attempt to set_quote max buffer size (f_array_length_t_size). diff --git a/level_0/f_memory/c/memory-common.h b/level_0/f_memory/c/memory-common.h index 0c8dbdd..9903240 100644 --- a/level_0/f_memory/c/memory-common.h +++ b/level_0/f_memory/c/memory-common.h @@ -205,11 +205,9 @@ extern "C" { #ifndef _di_f_macro_memory_structures_resize_ #define f_macro_memory_structures_resize(status, structures, type_structure, type_structures, length, type_length) \ status = F_none; \ - if (length < structures.size) { \ - for (register type_length _macro__i = structures.size - length; _macro__i < structures.size; ++_macro__i) { \ - status = f_memory_structure_resize(0, sizeof(type_structure), (void **) &structures.array[_macro__i].array, &structures.array[_macro__i].used, &structures.array[_macro__i].size); \ - if (F_status_is_error(status)) break; \ - } \ + for (register type_length _macro__i = length; _macro__i < structures.size; ++_macro__i) { \ + status = f_memory_structure_resize(0, sizeof(type_structure), (void **) &structures.array[_macro__i].array, &structures.array[_macro__i].used, &structures.array[_macro__i].size); \ + if (F_status_is_error(status)) break; \ } \ if (F_status_is_error_not(status)) status = f_memory_structure_resize(0, sizeof(type_structures), (void **) &structures.array, &structures.used, &structures.size); #endif // _di_f_macro_memory_structures_resize_ @@ -227,11 +225,9 @@ extern "C" { #ifndef _di_f_macro_memory_structures_adjust_ #define f_macro_memory_structures_adjust(status, structures, type_structure, type_structures, length, type_length) \ status = F_none; \ - if (length < structures.size) { \ - for (register type_length _macro__i = structures.size - length; _macro__i < structures.size; ++_macro__i) { \ - status = f_memory_structure_adjust(0, sizeof(type_structure), (void **) &structures.array[_macro__i].array, &structures.array[_macro__i].used, &structures.array[_macro__i].size); \ - if (F_status_is_error(status)) break; \ - } \ + for (register type_length _macro__i = length; _macro__i < structures.size; ++_macro__i) { \ + status = f_memory_structure_adjust(0, sizeof(type_structure), (void **) &structures.array[_macro__i].array, &structures.array[_macro__i].used, &structures.array[_macro__i].size); \ + if (F_status_is_error(status)) break; \ } \ if (F_status_is_error_not(status)) status = f_memory_structure_adjust(0, sizeof(type_structures), (void **) &structures.array, &structures.used, &structures.size); #endif // _di_f_macro_memory_structures_adjust_ diff --git a/level_0/f_type_array/c/private-type_array.c b/level_0/f_type_array/c/private-type_array.c index bcb8884..0fb08b5 100644 --- a/level_0/f_type_array/c/private-type_array.c +++ b/level_0/f_type_array/c/private-type_array.c @@ -9,7 +9,24 @@ extern "C" { f_status_t private_f_type_cellss_adjust(const f_array_length_t length, f_cellss_t *cellss) { f_status_t status = F_none; - f_macro_memory_structures_adjust(status, (*cellss), f_cell_t, f_cells_t, length, f_array_length_t) + for (f_array_length_t i = length; i < cellss->size; ++i) { + + status = f_memory_destroy(cellss->array[i].size, sizeof(f_cells_t), (void **) & cellss->array[i].array); + if (F_status_is_error(status)) return status; + + cellss->array[i].size = 0; + cellss->array[i].used = 0; + } // for + + status = f_memory_adjust(cellss->size, length, sizeof(f_cells_t), (void **) & cellss->array); + + if (F_status_is_error_not(status)) { + cellss->size = length; + + if (cellss->used > cellss->size) { + cellss->used = length; + } + } return status; } @@ -19,7 +36,24 @@ extern "C" { f_status_t private_f_type_cellss_resize(const f_array_length_t length, f_cellss_t *cellss) { f_status_t status = F_none; - f_macro_memory_structures_resize(status, (*cellss), f_cell_t, f_cells_t, length, f_array_length_t) + for (f_array_length_t i = length; i < cellss->size; ++i) { + + status = f_memory_delete(cellss->array[i].size, sizeof(f_cells_t), (void **) & cellss->array[i].array); + if (F_status_is_error(status)) return status; + + cellss->array[i].size = 0; + cellss->array[i].used = 0; + } // for + + status = f_memory_resize(cellss->size, length, sizeof(f_cells_t), (void **) & cellss->array); + + if (F_status_is_error_not(status)) { + cellss->size = length; + + if (cellss->used > cellss->size) { + cellss->used = length; + } + } return status; } @@ -29,7 +63,24 @@ extern "C" { f_status_t private_f_type_array_lengthss_adjust(const f_array_length_t length, f_array_lengthss_t *array_lengthss) { f_status_t status = F_none; - f_macro_memory_structures_adjust(status, (*array_lengthss), f_array_length_t, f_array_lengths_t, length, f_array_length_t) + for (f_array_length_t i = length; i < array_lengthss->size; ++i) { + + status = f_memory_destroy(array_lengthss->array[i].size, sizeof(f_array_lengths_t), (void **) & array_lengthss->array[i].array); + if (F_status_is_error(status)) return status; + + array_lengthss->array[i].size = 0; + array_lengthss->array[i].used = 0; + } // for + + status = f_memory_adjust(array_lengthss->size, length, sizeof(f_array_lengths_t), (void **) & array_lengthss->array); + + if (F_status_is_error_not(status)) { + array_lengthss->size = length; + + if (array_lengthss->used > array_lengthss->size) { + array_lengthss->used = length; + } + } return status; } @@ -39,7 +90,24 @@ extern "C" { f_status_t private_f_type_array_lengthss_resize(const f_array_length_t length, f_array_lengthss_t *array_lengthss) { f_status_t status = F_none; - f_macro_memory_structures_resize(status, (*array_lengthss), f_array_length_t, f_array_lengths_t, length, f_array_length_t) + for (f_array_length_t i = length; i < array_lengthss->size; ++i) { + + status = f_memory_delete(array_lengthss->array[i].size, sizeof(f_array_lengths_t), (void **) & array_lengthss->array[i].array); + if (F_status_is_error(status)) return status; + + array_lengthss->array[i].size = 0; + array_lengthss->array[i].used = 0; + } // for + + status = f_memory_resize(array_lengthss->size, length, sizeof(f_array_lengths_t), (void **) & array_lengthss->array); + + if (F_status_is_error_not(status)) { + array_lengthss->size = length; + + if (array_lengthss->used > array_lengthss->size) { + array_lengthss->used = length; + } + } return status; } @@ -49,7 +117,24 @@ extern "C" { f_status_t private_f_type_int8ss_adjust(const f_array_length_t length, f_int8ss_t *int8ss) { f_status_t status = F_none; - f_macro_memory_structures_adjust(status, (*int8ss), int8_t, f_int8s_t, length, f_array_length_t) + for (f_array_length_t i = length; i < int8ss->size; ++i) { + + status = f_memory_destroy(int8ss->array[i].size, sizeof(f_int8s_t), (void **) & int8ss->array[i].array); + if (F_status_is_error(status)) return status; + + int8ss->array[i].size = 0; + int8ss->array[i].used = 0; + } // for + + status = f_memory_adjust(int8ss->size, length, sizeof(f_int8s_t), (void **) & int8ss->array); + + if (F_status_is_error_not(status)) { + int8ss->size = length; + + if (int8ss->used > int8ss->size) { + int8ss->used = length; + } + } return status; } @@ -59,7 +144,24 @@ extern "C" { f_status_t private_f_type_int8ss_resize(const f_array_length_t length, f_int8ss_t *int8ss) { f_status_t status = F_none; - f_macro_memory_structures_resize(status, (*int8ss), int8_t, f_int8s_t, length, f_array_length_t) + for (f_array_length_t i = length; i < int8ss->size; ++i) { + + status = f_memory_delete(int8ss->array[i].size, sizeof(f_int8s_t), (void **) & int8ss->array[i].array); + if (F_status_is_error(status)) return status; + + int8ss->array[i].size = 0; + int8ss->array[i].used = 0; + } // for + + status = f_memory_resize(int8ss->size, length, sizeof(f_int8s_t), (void **) & int8ss->array); + + if (F_status_is_error_not(status)) { + int8ss->size = length; + + if (int8ss->used > int8ss->size) { + int8ss->used = length; + } + } return status; } @@ -69,7 +171,24 @@ extern "C" { f_status_t private_f_type_uint8ss_adjust(const f_array_length_t length, f_uint8ss_t *uint8ss) { f_status_t status = F_none; - f_macro_memory_structures_adjust(status, (*uint8ss), uint8_t, f_uint8s_t, length, f_array_length_t) + for (f_array_length_t i = length; i < uint8ss->size; ++i) { + + status = f_memory_destroy(uint8ss->array[i].size, sizeof(f_uint8s_t), (void **) & uint8ss->array[i].array); + if (F_status_is_error(status)) return status; + + uint8ss->array[i].size = 0; + uint8ss->array[i].used = 0; + } // for + + status = f_memory_adjust(uint8ss->size, length, sizeof(f_uint8s_t), (void **) & uint8ss->array); + + if (F_status_is_error_not(status)) { + uint8ss->size = length; + + if (uint8ss->used > uint8ss->size) { + uint8ss->used = length; + } + } return status; } @@ -79,7 +198,24 @@ extern "C" { f_status_t private_f_type_uint8ss_resize(const f_array_length_t length, f_uint8ss_t *uint8ss) { f_status_t status = F_none; - f_macro_memory_structures_resize(status, (*uint8ss), uint8_t, f_uint8s_t, length, f_array_length_t) + for (f_array_length_t i = length; i < uint8ss->size; ++i) { + + status = f_memory_delete(uint8ss->array[i].size, sizeof(f_uint8s_t), (void **) & uint8ss->array[i].array); + if (F_status_is_error(status)) return status; + + uint8ss->array[i].size = 0; + uint8ss->array[i].used = 0; + } // for + + status = f_memory_resize(uint8ss->size, length, sizeof(f_uint8s_t), (void **) & uint8ss->array); + + if (F_status_is_error_not(status)) { + uint8ss->size = length; + + if (uint8ss->used > uint8ss->size) { + uint8ss->used = length; + } + } return status; } @@ -89,7 +225,24 @@ extern "C" { f_status_t private_f_type_int16ss_adjust(const f_array_length_t length, f_int16ss_t *int16ss) { f_status_t status = F_none; - f_macro_memory_structures_adjust(status, (*int16ss), int16_t, f_int16s_t, length, f_array_length_t) + for (f_array_length_t i = length; i < int16ss->size; ++i) { + + status = f_memory_destroy(int16ss->array[i].size, sizeof(f_int16s_t), (void **) & int16ss->array[i].array); + if (F_status_is_error(status)) return status; + + int16ss->array[i].size = 0; + int16ss->array[i].used = 0; + } // for + + status = f_memory_adjust(int16ss->size, length, sizeof(f_int16s_t), (void **) & int16ss->array); + + if (F_status_is_error_not(status)) { + int16ss->size = length; + + if (int16ss->used > int16ss->size) { + int16ss->used = length; + } + } return status; } @@ -99,7 +252,24 @@ extern "C" { f_status_t private_f_type_int16ss_resize(const f_array_length_t length, f_int16ss_t *int16ss) { f_status_t status = F_none; - f_macro_memory_structures_resize(status, (*int16ss), int16_t, f_int16s_t, length, f_array_length_t) + for (f_array_length_t i = length; i < int16ss->size; ++i) { + + status = f_memory_delete(int16ss->array[i].size, sizeof(f_int16s_t), (void **) & int16ss->array[i].array); + if (F_status_is_error(status)) return status; + + int16ss->array[i].size = 0; + int16ss->array[i].used = 0; + } // for + + status = f_memory_resize(int16ss->size, length, sizeof(f_int16s_t), (void **) & int16ss->array); + + if (F_status_is_error_not(status)) { + int16ss->size = length; + + if (int16ss->used > int16ss->size) { + int16ss->used = length; + } + } return status; } @@ -109,7 +279,24 @@ extern "C" { f_status_t private_f_type_uint16ss_adjust(const f_array_length_t length, f_uint16ss_t *uint16ss) { f_status_t status = F_none; - f_macro_memory_structures_adjust(status, (*uint16ss), uint16_t, f_uint16s_t, length, f_array_length_t) + for (f_array_length_t i = length; i < uint16ss->size; ++i) { + + status = f_memory_destroy(uint16ss->array[i].size, sizeof(f_uint16s_t), (void **) & uint16ss->array[i].array); + if (F_status_is_error(status)) return status; + + uint16ss->array[i].size = 0; + uint16ss->array[i].used = 0; + } // for + + status = f_memory_adjust(uint16ss->size, length, sizeof(f_uint16s_t), (void **) & uint16ss->array); + + if (F_status_is_error_not(status)) { + uint16ss->size = length; + + if (uint16ss->used > uint16ss->size) { + uint16ss->used = length; + } + } return status; } @@ -119,7 +306,24 @@ extern "C" { f_status_t private_f_type_uint16ss_resize(const f_array_length_t length, f_uint16ss_t *uint16ss) { f_status_t status = F_none; - f_macro_memory_structures_resize(status, (*uint16ss), uint16_t, f_uint16s_t, length, f_array_length_t) + for (f_array_length_t i = length; i < uint16ss->size; ++i) { + + status = f_memory_delete(uint16ss->array[i].size, sizeof(f_uint8s_t), (void **) & uint16ss->array[i].array); + if (F_status_is_error(status)) return status; + + uint16ss->array[i].size = 0; + uint16ss->array[i].used = 0; + } // for + + status = f_memory_resize(uint16ss->size, length, sizeof(f_uint8s_t), (void **) & uint16ss->array); + + if (F_status_is_error_not(status)) { + uint16ss->size = length; + + if (uint16ss->used > uint16ss->size) { + uint16ss->used = length; + } + } return status; } @@ -129,7 +333,24 @@ extern "C" { f_status_t private_f_type_int32ss_adjust(const f_array_length_t length, f_int32ss_t *int32ss) { f_status_t status = F_none; - f_macro_memory_structures_adjust(status, (*int32ss), int32_t, f_int32s_t, length, f_array_length_t) + for (f_array_length_t i = length; i < int32ss->size; ++i) { + + status = f_memory_destroy(int32ss->array[i].size, sizeof(f_int32s_t), (void **) & int32ss->array[i].array); + if (F_status_is_error(status)) return status; + + int32ss->array[i].size = 0; + int32ss->array[i].used = 0; + } // for + + status = f_memory_adjust(int32ss->size, length, sizeof(f_int32s_t), (void **) & int32ss->array); + + if (F_status_is_error_not(status)) { + int32ss->size = length; + + if (int32ss->used > int32ss->size) { + int32ss->used = length; + } + } return status; } @@ -139,7 +360,24 @@ extern "C" { f_status_t private_f_type_int32ss_resize(const f_array_length_t length, f_int32ss_t *int32ss) { f_status_t status = F_none; - f_macro_memory_structures_resize(status, (*int32ss), int32_t, f_int32s_t, length, f_array_length_t) + for (f_array_length_t i = length; i < int32ss->size; ++i) { + + status = f_memory_delete(int32ss->array[i].size, sizeof(f_int32s_t), (void **) & int32ss->array[i].array); + if (F_status_is_error(status)) return status; + + int32ss->array[i].size = 0; + int32ss->array[i].used = 0; + } // for + + status = f_memory_resize(int32ss->size, length, sizeof(f_int32s_t), (void **) & int32ss->array); + + if (F_status_is_error_not(status)) { + int32ss->size = length; + + if (int32ss->used > int32ss->size) { + int32ss->used = length; + } + } return status; } @@ -149,7 +387,24 @@ extern "C" { f_status_t private_f_type_uint32ss_adjust(const f_array_length_t length, f_uint32ss_t *uint32ss) { f_status_t status = F_none; - f_macro_memory_structures_adjust(status, (*uint32ss), uint32_t, f_uint32s_t, length, f_array_length_t) + for (f_array_length_t i = length; i < uint32ss->size; ++i) { + + status = f_memory_destroy(uint32ss->array[i].size, sizeof(f_uint32s_t), (void **) & uint32ss->array[i].array); + if (F_status_is_error(status)) return status; + + uint32ss->array[i].size = 0; + uint32ss->array[i].used = 0; + } // for + + status = f_memory_adjust(uint32ss->size, length, sizeof(f_uint32s_t), (void **) & uint32ss->array); + + if (F_status_is_error_not(status)) { + uint32ss->size = length; + + if (uint32ss->used > uint32ss->size) { + uint32ss->used = length; + } + } return status; } @@ -159,7 +414,24 @@ extern "C" { f_status_t private_f_type_uint32ss_resize(const f_array_length_t length, f_uint32ss_t *uint32ss) { f_status_t status = F_none; - f_macro_memory_structures_resize(status, (*uint32ss), uint32_t, f_uint32s_t, length, f_array_length_t) + for (f_array_length_t i = length; i < uint32ss->size; ++i) { + + status = f_memory_delete(uint32ss->array[i].size, sizeof(f_uint32s_t), (void **) & uint32ss->array[i].array); + if (F_status_is_error(status)) return status; + + uint32ss->array[i].size = 0; + uint32ss->array[i].used = 0; + } // for + + status = f_memory_resize(uint32ss->size, length, sizeof(f_uint32s_t), (void **) & uint32ss->array); + + if (F_status_is_error_not(status)) { + uint32ss->size = length; + + if (uint32ss->used > uint32ss->size) { + uint32ss->used = length; + } + } return status; } @@ -169,7 +441,24 @@ extern "C" { f_status_t private_f_type_int64ss_adjust(const f_array_length_t length, f_int64ss_t *int64ss) { f_status_t status = F_none; - f_macro_memory_structures_adjust(status, (*int64ss), int64_t, f_int64s_t, length, f_array_length_t) + for (f_array_length_t i = length; i < int64ss->size; ++i) { + + status = f_memory_destroy(int64ss->array[i].size, sizeof(f_int64s_t), (void **) & int64ss->array[i].array); + if (F_status_is_error(status)) return status; + + int64ss->array[i].size = 0; + int64ss->array[i].used = 0; + } // for + + status = f_memory_adjust(int64ss->size, length, sizeof(f_int64s_t), (void **) & int64ss->array); + + if (F_status_is_error_not(status)) { + int64ss->size = length; + + if (int64ss->used > int64ss->size) { + int64ss->used = length; + } + } return status; } @@ -179,7 +468,24 @@ extern "C" { f_status_t private_f_type_int64ss_resize(const f_array_length_t length, f_int64ss_t *int64ss) { f_status_t status = F_none; - f_macro_memory_structures_resize(status, (*int64ss), int64_t, f_int64s_t, length, f_array_length_t) + for (f_array_length_t i = length; i < int64ss->size; ++i) { + + status = f_memory_delete(int64ss->array[i].size, sizeof(f_int64s_t), (void **) & int64ss->array[i].array); + if (F_status_is_error(status)) return status; + + int64ss->array[i].size = 0; + int64ss->array[i].used = 0; + } // for + + status = f_memory_resize(int64ss->size, length, sizeof(f_int64s_t), (void **) & int64ss->array); + + if (F_status_is_error_not(status)) { + int64ss->size = length; + + if (int64ss->used > int64ss->size) { + int64ss->used = length; + } + } return status; } @@ -189,7 +495,24 @@ extern "C" { f_status_t private_f_type_uint64ss_adjust(const f_array_length_t length, f_uint64ss_t *uint64ss) { f_status_t status = F_none; - f_macro_memory_structures_adjust(status, (*uint64ss), uint64_t, f_uint64s_t, length, f_array_length_t) + for (f_array_length_t i = length; i < uint64ss->size; ++i) { + + status = f_memory_destroy(uint64ss->array[i].size, sizeof(f_uint64s_t), (void **) & uint64ss->array[i].array); + if (F_status_is_error(status)) return status; + + uint64ss->array[i].size = 0; + uint64ss->array[i].used = 0; + } // for + + status = f_memory_adjust(uint64ss->size, length, sizeof(f_uint64s_t), (void **) & uint64ss->array); + + if (F_status_is_error_not(status)) { + uint64ss->size = length; + + if (uint64ss->used > uint64ss->size) { + uint64ss->used = length; + } + } return status; } @@ -199,7 +522,24 @@ extern "C" { f_status_t private_f_type_uint64ss_resize(const f_array_length_t length, f_uint64ss_t *uint64ss) { f_status_t status = F_none; - f_macro_memory_structures_resize(status, (*uint64ss), uint64_t, f_uint64s_t, length, f_array_length_t) + for (f_array_length_t i = length; i < uint64ss->size; ++i) { + + status = f_memory_delete(uint64ss->array[i].size, sizeof(f_uint64s_t), (void **) & uint64ss->array[i].array); + if (F_status_is_error(status)) return status; + + uint64ss->array[i].size = 0; + uint64ss->array[i].used = 0; + } // for + + status = f_memory_resize(uint64ss->size, length, sizeof(f_uint64s_t), (void **) & uint64ss->array); + + if (F_status_is_error_not(status)) { + uint64ss->size = length; + + if (uint64ss->used > uint64ss->size) { + uint64ss->used = length; + } + } return status; } @@ -209,7 +549,24 @@ extern "C" { f_status_t private_f_type_int128ss_adjust(const f_array_length_t length, f_int128ss_t *int128ss) { f_status_t status = F_none; - f_macro_memory_structures_adjust(status, (*int128ss), f_int128_t, f_int128s_t, length, f_array_length_t) + for (f_array_length_t i = length; i < int128ss->size; ++i) { + + status = f_memory_destroy(int128ss->array[i].size, sizeof(f_int128s_t), (void **) & int128ss->array[i].array); + if (F_status_is_error(status)) return status; + + int128ss->array[i].size = 0; + int128ss->array[i].used = 0; + } // for + + status = f_memory_adjust(int128ss->size, length, sizeof(f_int128s_t), (void **) & int128ss->array); + + if (F_status_is_error_not(status)) { + int128ss->size = length; + + if (int128ss->used > int128ss->size) { + int128ss->used = length; + } + } return status; } @@ -219,7 +576,24 @@ extern "C" { f_status_t private_f_type_int128ss_resize(const f_array_length_t length, f_int128ss_t *int128ss) { f_status_t status = F_none; - f_macro_memory_structures_resize(status, (*int128ss), f_int128_t, f_int128s_t, length, f_array_length_t) + for (f_array_length_t i = length; i < int128ss->size; ++i) { + + status = f_memory_delete(int128ss->array[i].size, sizeof(f_int128s_t), (void **) & int128ss->array[i].array); + if (F_status_is_error(status)) return status; + + int128ss->array[i].size = 0; + int128ss->array[i].used = 0; + } // for + + status = f_memory_resize(int128ss->size, length, sizeof(f_int128s_t), (void **) & int128ss->array); + + if (F_status_is_error_not(status)) { + int128ss->size = length; + + if (int128ss->used > int128ss->size) { + int128ss->used = length; + } + } return status; } @@ -229,7 +603,24 @@ extern "C" { f_status_t private_f_type_uint128ss_adjust(const f_array_length_t length, f_uint128ss_t *uint128ss) { f_status_t status = F_none; - f_macro_memory_structures_adjust(status, (*uint128ss), f_uint128_t, f_uint128s_t, length, f_array_length_t) + for (f_array_length_t i = length; i < uint128ss->size; ++i) { + + status = f_memory_destroy(uint128ss->array[i].size, sizeof(f_uint128s_t), (void **) & uint128ss->array[i].array); + if (F_status_is_error(status)) return status; + + uint128ss->array[i].size = 0; + uint128ss->array[i].used = 0; + } // for + + status = f_memory_adjust(uint128ss->size, length, sizeof(f_uint128s_t), (void **) & uint128ss->array); + + if (F_status_is_error_not(status)) { + uint128ss->size = length; + + if (uint128ss->used > uint128ss->size) { + uint128ss->used = length; + } + } return status; } @@ -239,7 +630,24 @@ extern "C" { f_status_t private_f_type_uint128ss_resize(const f_array_length_t length, f_uint128ss_t *uint128ss) { f_status_t status = F_none; - f_macro_memory_structures_resize(status, (*uint128ss), f_uint128_t, f_uint128s_t, length, f_array_length_t) + for (f_array_length_t i = length; i < uint128ss->size; ++i) { + + status = f_memory_delete(uint128ss->array[i].size, sizeof(f_uint128s_t), (void **) & uint128ss->array[i].array); + if (F_status_is_error(status)) return status; + + uint128ss->array[i].size = 0; + uint128ss->array[i].used = 0; + } // for + + status = f_memory_resize(uint128ss->size, length, sizeof(f_uint128s_t), (void **) & uint128ss->array); + + if (F_status_is_error_not(status)) { + uint128ss->size = length; + + if (uint128ss->used > uint128ss->size) { + uint128ss->used = length; + } + } return status; } diff --git a/level_1/fl_fss/c/fss_basic_list.c b/level_1/fl_fss/c/fss_basic_list.c index c5f3111..bc39242 100644 --- a/level_1/fl_fss/c/fss_basic_list.c +++ b/level_1/fl_fss/c/fss_basic_list.c @@ -698,7 +698,7 @@ extern "C" { slash_count = 1; if (do_prepend) { - status = private_fl_fss_destination_prepend(prepend, destination); + status = f_string_dynamic_prepend(*prepend, destination); if (F_status_is_error(status)) break; do_prepend = F_false; @@ -755,7 +755,7 @@ extern "C" { start = range->start++; if (do_prepend) { - status = private_fl_fss_destination_prepend(prepend, destination); + status = f_string_dynamic_prepend(*prepend, destination); if (F_status_is_error(status)) break; do_prepend = F_false; @@ -810,7 +810,7 @@ extern "C" { if (content.string[range->start] != f_fss_delimit_placeholder) { if (do_prepend) { - status = private_fl_fss_destination_prepend(prepend, destination); + status = f_string_dynamic_prepend(*prepend, destination); if (F_status_is_error(status)) break; do_prepend = F_false; diff --git a/level_1/fl_fss/c/fss_embedded_list.c b/level_1/fl_fss/c/fss_embedded_list.c index 4b019e9..31f3631 100644 --- a/level_1/fl_fss/c/fss_embedded_list.c +++ b/level_1/fl_fss/c/fss_embedded_list.c @@ -266,7 +266,7 @@ extern "C" { return status; } - status = private_fl_fss_nest_increase(found); + f_macro_fss_nest_t_increase(status, (*found)); if (F_status_is_error(status)) return status; f_string_lengths_t positions_start = f_string_lengths_t_initialize; @@ -646,7 +646,7 @@ extern "C" { } if (buffer.string[range->start] == f_fss_eol) { - status = private_fl_fss_nest_increase(found); + f_macro_fss_nest_t_increase(status, (*found)); if (F_status_is_error(status)) break; if (found->depth[depth].used == found->depth[depth].size) { @@ -699,7 +699,7 @@ extern "C" { private_fl_macro_fss_nest_return_on_overflow_delimited((buffer), (*range), (*found), positions_start, objects, F_none_eos, F_none_stop) f_macro_string_lengths_t_delete_simple(positions_start); - private_fl_fss_objects_delete(&objects); + f_macro_fss_objects_t_delete_simple(objects); return FL_fss_found_content; } @@ -798,7 +798,7 @@ extern "C" { } // while f_macro_string_lengths_t_delete_simple(positions_start); - private_fl_fss_objects_delete(&objects); + f_macro_fss_objects_t_delete_simple(objects); delimits->used = delimits_used; comments->used = comments_used; @@ -1084,7 +1084,7 @@ extern "C" { slash_count = 1; if (do_prepend) { - status = private_fl_fss_destination_prepend(prepend, destination); + status = f_string_dynamic_prepend(*prepend, destination); if (F_status_is_error(status)) break; do_prepend = F_false; @@ -1159,7 +1159,7 @@ extern "C" { start = range->start++; if (do_prepend) { - status = private_fl_fss_destination_prepend(prepend, destination); + status = f_string_dynamic_prepend(*prepend, destination); if (F_status_is_error(status)) break; do_prepend = F_false; @@ -1234,7 +1234,7 @@ extern "C" { if (content.string[range->start] != f_fss_delimit_placeholder) { if (do_prepend) { - status = private_fl_fss_destination_prepend(prepend, destination); + status = f_string_dynamic_prepend(*prepend, destination); if (F_status_is_error(status)) break; do_prepend = F_false; diff --git a/level_1/fl_fss/c/fss_extended_list.c b/level_1/fl_fss/c/fss_extended_list.c index f4395f4..4016f74 100644 --- a/level_1/fl_fss/c/fss_extended_list.c +++ b/level_1/fl_fss/c/fss_extended_list.c @@ -674,7 +674,7 @@ extern "C" { slash_count = 1; if (do_prepend) { - status = private_fl_fss_destination_prepend(prepend, destination); + status = f_string_dynamic_prepend(*prepend, destination); if (F_status_is_error(status)) break; do_prepend = F_false; @@ -743,7 +743,7 @@ extern "C" { start = range->start++; if (do_prepend) { - status = private_fl_fss_destination_prepend(prepend, destination); + status = f_string_dynamic_prepend(*prepend, destination); if (F_status_is_error(status)) break; do_prepend = F_false; @@ -818,7 +818,7 @@ extern "C" { if (content.string[range->start] != f_fss_delimit_placeholder) { if (do_prepend) { - status = private_fl_fss_destination_prepend(prepend, destination); + status = f_string_dynamic_prepend(*prepend, destination); if (F_status_is_error(status)) break; do_prepend = F_false; diff --git a/level_1/fl_fss/c/private-fss.c b/level_1/fl_fss/c/private-fss.c index 6e36f41..912c2d7 100644 --- a/level_1/fl_fss/c/private-fss.c +++ b/level_1/fl_fss/c/private-fss.c @@ -1007,57 +1007,6 @@ extern "C" { } #endif // !defined(_di_fl_fss_basic_object_write_string_) || !defined(_di_fl_fss_extended_object_write_string_) || !defined(_di_fl_fss_extended_content_write_string_) -#if !defined(_di_fl_fss_basic_list_content_write_string_) || !defined(_di_fl_fss_extended_list_content_write_string_) - f_status_t private_fl_fss_destination_prepend(const f_string_static_t *prepend, f_string_dynamic_t *destination) { - - if (!prepend || !prepend->used) { - return F_none; - } - - { - const f_status_t status = f_string_dynamic_increase_by(prepend->used, destination); - if (F_status_is_error(status)) return status; - } - - for (f_string_length_t i = 0; i < prepend->used; i++) { - destination->string[destination->used++] = prepend->string[i]; - } // for - - return F_none; - } -#endif // !defined(_di_fl_fss_basic_list_content_write_string_) || !defined(_di_fl_fss_extended_list_content_write_string_) - -#if !defined(_di_fl_fss_embedded_list_object_read_) || !defined(_di_fl_fss_embedded_list_content_read_) - f_status_t private_fl_fss_nest_increase(f_fss_nest_t *nest) { - - if (nest->used + 1 > nest->size) { - f_array_length_t size = nest->used + f_fss_default_allocation_step; - - if (size > f_string_length_t_size) { - if (nest->used + 1 > f_array_length_t_size) { - return F_status_set_error(F_array_too_large); - } - - size = f_array_length_t_size; - } - - f_status_t status = F_none; - - f_macro_fss_nest_t_resize(status, (*nest), size); - - return status; - } - - return F_none; - } -#endif // !defined(_di_fl_fss_embedded_list_object_read_) || !defined(_di_fl_fss_embedded_list_content_read_) - -#if !defined(_di_fl_fss_embedded_list_content_read_) - void private_fl_fss_objects_delete(f_fss_objects_t *objects) { - f_macro_fss_objects_t_delete_simple((*objects)); - } -#endif // !defined(_di_fl_fss_embedded_list_content_read_) - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_1/fl_fss/c/private-fss.h b/level_1/fl_fss/c/private-fss.h index 8fae830..f2e2809 100644 --- a/level_1/fl_fss/c/private-fss.h +++ b/level_1/fl_fss/c/private-fss.h @@ -187,60 +187,6 @@ extern "C" { extern f_status_t private_fl_fss_basic_write(const bool object_as, const f_string_static_t object, const f_fss_quote_t quoted, f_string_range_t *range, f_string_dynamic_t *destination) f_gcc_attribute_visibility_internal; #endif // !defined(fl_fss_basic_object_write_string) || !defined(fl_fss_extended_object_write_string) || !defined(_di_fl_fss_extended_content_write_string_) -/** - * Prepend the given string onto the destination buffer, allocating space as necessary. - * - * @param prepend - * A string to prepend at the start of each line, such as spaces. - * Set the pointer address to 0 to disable. - * @param destination - * The destination buffer to prepend to. - * - * @return - * F_none on success. - * F_memory_not (with error bit) on out of memory. - * F_string_too_large (with error bit) if increased string length is too large to store in the destination. - * - * @see fl_fss_basic_list_content_write_string() - * @see fl_fss_extended_list_content_write_string() - */ -#if !defined(_di_fl_fss_basic_list_content_write_string_) || !defined(_di_fl_fss_extended_list_content_write_string_) - extern f_status_t private_fl_fss_destination_prepend(const f_string_static_t *prepend, f_string_dynamic_t *destination) f_gcc_attribute_visibility_internal; -#endif // !defined(_di_fl_fss_basic_list_content_write_string_) || !defined(_di_fl_fss_extended_list_content_write_string_) - -/** - * Increase the size of a given nest buffer, but only if necessary. - * - * @param nest - * The nest buffer to increment. - * - * @return - * F_none on success. - * F_memory_not (with error bit) on out of memory. - * F_array_too_large (with error bit) if new length is larger than max array length. - * - * @see fl_fss_embedded_list_object_read() - * @see fl_fss_embedded_list_content_read() - */ -#if !defined(_di_fl_fss_embedded_list_object_read_) || !defined(_di_fl_fss_embedded_list_content_read_) - extern f_status_t private_fl_fss_nest_increase(f_fss_nest_t *nest) f_gcc_attribute_visibility_internal; -#endif // !defined(_di_fl_fss_embedded_list_object_read_) || !defined(_di_fl_fss_embedded_list_content_read_) - -/** - * Private implementation for deleting fss objects. - * - * Intended to be shared to each of the different implementation variations. - * - * @param objects - * The objects to delete. - * - * @see f_macro_fss_objects_t_delete_simple() - * @see fl_fss_embedded_list_content_read() - */ -#if !defined(_di_fl_fss_embedded_list_content_read_) - extern void private_fl_fss_objects_delete(f_fss_objects_t *objects) f_gcc_attribute_visibility_internal; -#endif // !defined(_di_fl_fss_embedded_list_content_read_) - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_1/fl_fss/c/private-fss_macro.h b/level_1/fl_fss/c/private-fss_macro.h index 141daff..cdaf7e3 100644 --- a/level_1/fl_fss/c/private-fss_macro.h +++ b/level_1/fl_fss/c/private-fss_macro.h @@ -88,14 +88,14 @@ extern "C" { delimits.used = delimits_used; \ comments.used = comments_used; \ f_macro_string_lengths_t_delete_simple(positions); \ - private_fl_fss_objects_delete(&objects); \ + f_macro_fss_objects_t_delete_simple(objects); \ return eos_status; \ } \ else if (range.start > range.stop) { \ delimits.used = delimits_used; \ comments.used = comments_used; \ f_macro_string_lengths_t_delete_simple(positions); \ - private_fl_fss_objects_delete(&objects); \ + f_macro_fss_objects_t_delete_simple(objects); \ return stop_status; \ } #endif // _di_fl_macro_fss_nest_return_on_overflow_ @@ -104,12 +104,12 @@ extern "C" { #define private_fl_macro_fss_nest_return_on_overflow_delimited(buffer, range, found, positions, objects, eos_status, stop_status) \ if (range.start >= buffer.used) { \ f_macro_string_lengths_t_delete_simple(positions); \ - private_fl_fss_objects_delete(&objects); \ + f_macro_fss_objects_t_delete_simple(objects); \ return eos_status; \ } \ else if (range.start > range.stop) { \ f_macro_string_lengths_t_delete_simple(positions); \ - private_fl_fss_objects_delete(&objects); \ + f_macro_fss_objects_t_delete_simple(objects); \ return stop_status; \ } #endif // _di_fl_macro_fss_nest_return_on_overflow_delimited_ diff --git a/level_1/fl_utf/c/private-utf.h b/level_1/fl_utf/c/private-utf.h index 9348449..5877c85 100644 --- a/level_1/fl_utf/c/private-utf.h +++ b/level_1/fl_utf/c/private-utf.h @@ -30,7 +30,6 @@ extern "C" { * @return * F_none on success. * F_data_not if source length is 0. - * F_memory_out (with error bit) on out of memory. * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if the combined string is too large. @@ -59,7 +58,6 @@ extern "C" { * @return * F_none on success. * F_data_not if source length is 0. - * F_memory_out (with error bit) on out of memory. * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if the combined string is too large. @@ -149,7 +147,6 @@ extern "C" { * * @return * F_none on success. - * F_memory_out (with error bit) on out of memory. * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if the combined string is too large. @@ -175,7 +172,6 @@ extern "C" { * * @return * F_none on success. - * F_memory_out (with error bit) on out of memory. * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if the combined string is too large. @@ -204,7 +200,6 @@ extern "C" { * @return * F_none on success. * F_data_not on success but only whitespace found. - * F_memory_out (with error bit) on out of memory. * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. * diff --git a/level_1/fl_utf/c/utf.h b/level_1/fl_utf/c/utf.h index 0f46d78..5190028 100644 --- a/level_1/fl_utf/c/utf.h +++ b/level_1/fl_utf/c/utf.h @@ -46,8 +46,7 @@ extern "C" { * * @return * F_none on success. - * F_data_not_eos if source length is 0. - * F_memory_out (with error bit) on out of memory. + * F_data_not_eos if source length is 0.. * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if the combined string is too large. @@ -72,7 +71,6 @@ extern "C" { * @return * F_none on success. * F_data_not_eos if source length is 0. - * F_memory_out (with error bit) on out of memory. * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if the combined string is too large. @@ -97,7 +95,6 @@ extern "C" { * @return * F_none on success. * F_data_not_eos if source length is 0. - * F_memory_out (with error bit) on out of memory. * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if the combined string is too large. @@ -121,7 +118,6 @@ extern "C" { * @return * F_none on success. * F_data_not_eos if source length is 0. - * F_memory_out (with error bit) on out of memory. * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if the combined string is too large. @@ -194,7 +190,6 @@ extern "C" { * @return * F_none on success. * F_data_not_eos if source length is 0. - * F_memory_out (with error bit) on out of memory. * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if the combined string is too large. @@ -214,7 +209,6 @@ extern "C" { * @return * F_none on success. * F_data_not_eos if source length is 0. - * F_memory_out (with error bit) on out of memory. * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if the combined string is too large. @@ -236,7 +230,6 @@ extern "C" { * @return * F_none on success. * F_data_not_eos if source length is 0. - * F_memory_out (with error bit) on out of memory. * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if the combined string is too large. @@ -258,7 +251,6 @@ extern "C" { * @return * F_none on success. * F_data_not_eos if source length is 0. - * F_memory_out (with error bit) on out of memory. * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if the combined string is too large. @@ -331,7 +323,6 @@ extern "C" { * @return * F_none on success. * F_data_not_eos if source length is 0. - * F_memory_out (with error bit) on out of memory. * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if the combined string is too large. @@ -359,7 +350,6 @@ extern "C" { * @return * F_none on success. * F_data_not_eos if source length is 0. - * F_memory_out (with error bit) on out of memory. * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if the combined string is too large. @@ -385,7 +375,6 @@ extern "C" { * @return * F_none on success. * F_data_not_eos if source length is 0. - * F_memory_out (with error bit) on out of memory. * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if the combined string is too large. @@ -413,7 +402,6 @@ extern "C" { * @return * F_none on success. * F_data_not_eos if source length is 0. - * F_memory_out (with error bit) on out of memory. * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if the combined string is too large. @@ -436,7 +424,6 @@ extern "C" { * F_none on success. * F_data_not_eos if source length is 0. * F_data_not_stop if range.start > range.stop. - * F_memory_out (with error bit) on out of memory. * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if the combined string is too large. @@ -461,7 +448,6 @@ extern "C" { * F_none on success. * F_data_not_eos if source length is 0. * F_data_not_stop if range.start > range.stop. - * F_memory_out (with error bit) on out of memory. * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if the combined string is too large. @@ -488,7 +474,6 @@ extern "C" { * F_none on success. * F_data_not_eos if source length is 0. * F_data_not_stop if range.start > range.stop. - * F_memory_out (with error bit) on out of memory. * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if the combined string is too large. @@ -513,7 +498,6 @@ extern "C" { * F_none on success. * F_data_not_eos if source length is 0. * F_data_not_stop if range.start > range.stop. - * F_memory_out (with error bit) on out of memory. * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if the combined string is too large. @@ -595,7 +579,6 @@ extern "C" { * F_none on success. * F_data_not_eos if source length is 0. * F_data_not_stop if range.start > range.stop. - * F_memory_out (with error bit) on out of memory. * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if the combined string is too large. @@ -626,7 +609,6 @@ extern "C" { * F_none on success. * F_data_not_eos if source length is 0. * F_data_not_stop if range.start > range.stop. - * F_memory_out (with error bit) on out of memory. * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if the combined string is too large. @@ -655,7 +637,6 @@ extern "C" { * F_none on success. * F_data_not_eos if source length is 0. * F_data_not_stop if range.start > range.stop. - * F_memory_out (with error bit) on out of memory. * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if the combined string is too large. @@ -686,7 +667,6 @@ extern "C" { * F_none on success. * F_data_not_eos if source length is 0. * F_data_not_stop if range.start > range.stop. - * F_memory_out (with error bit) on out of memory. * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if the combined string is too large. @@ -711,7 +691,6 @@ extern "C" { * F_none on success. * F_data_not_eos if source length is 0. * F_data_not_stop if range.start > range.stop. - * F_memory_out (with error bit) on out of memory. * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if the combined string is too large. @@ -738,7 +717,6 @@ extern "C" { * F_none on success. * F_data_not_eos if source length is 0. * F_data_not_stop if range.start > range.stop. - * F_memory_out (with error bit) on out of memory. * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if the combined string is too large. @@ -765,7 +743,6 @@ extern "C" { * F_none on success. * F_data_not_eos if source length is 0. * F_data_not_stop if range.start > range.stop. - * F_memory_out (with error bit) on out of memory. * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if the combined string is too large. @@ -790,7 +767,6 @@ extern "C" { * F_none on success. * F_data_not_eos if source length is 0. * F_data_not_stop if range.start > range.stop. - * F_memory_out (with error bit) on out of memory. * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if the combined string is too large. @@ -813,7 +789,6 @@ extern "C" { * F_none on success. * F_data_not_eos if source length is 0. * F_data_not_stop if range.start > range.stop. - * F_memory_out (with error bit) on out of memory. * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if the combined string is too large. @@ -838,7 +813,6 @@ extern "C" { * F_none on success. * F_data_not_eos if source length is 0. * F_data_not_stop if range.start > range.stop. - * F_memory_out (with error bit) on out of memory. * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if the combined string is too large. @@ -863,7 +837,6 @@ extern "C" { * F_none on success. * F_data_not_eos if source length is 0. * F_data_not_stop if range.start > range.stop. - * F_memory_out (with error bit) on out of memory. * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if the combined string is too large. @@ -886,7 +859,6 @@ extern "C" { * F_none on success. * F_data_not_eos if source length is 0. * F_data_not_stop if range.start > range.stop. - * F_memory_out (with error bit) on out of memory. * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if the combined string is too large. @@ -912,7 +884,6 @@ extern "C" { * F_none on success. * F_data_not_eos if source length is 0. * F_data_not_stop if range.start > range.stop. - * F_memory_out (with error bit) on out of memory. * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if the combined string is too large. @@ -940,7 +911,6 @@ extern "C" { * F_none on success. * F_data_not_eos if source length is 0. * F_data_not_stop if range.start > range.stop. - * F_memory_out (with error bit) on out of memory. * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. */ @@ -1190,7 +1160,6 @@ extern "C" { * @return * F_none on success. * F_data_not_eos if source length is 0. - * F_memory_out (with error bit) on out of memory. * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if the combined string is too large. @@ -1220,7 +1189,6 @@ extern "C" { * @return * F_none on success. * F_data_not_eos if source length is 0. - * F_memory_out (with error bit) on out of memory. * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if the combined string is too large. @@ -1248,7 +1216,6 @@ extern "C" { * @return * F_none on success. * F_data_not_eos if source length is 0. - * F_memory_out (with error bit) on out of memory. * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if the combined string is too large. @@ -1278,7 +1245,6 @@ extern "C" { * @return * F_none on success. * F_data_not_eos if source length is 0. - * F_memory_out (with error bit) on out of memory. * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if the combined string is too large. @@ -1302,7 +1268,6 @@ extern "C" { * @return * F_none on success. * F_data_not_eos if source length is 0. - * F_memory_out (with error bit) on out of memory. * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if the combined string is too large. @@ -1328,7 +1293,6 @@ extern "C" { * @return * F_none on success. * F_data_not_eos if source length is 0. - * F_memory_out (with error bit) on out of memory. * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if the combined string is too large. @@ -1355,7 +1319,6 @@ extern "C" { * @return * F_none on success. * F_data_not_eos if source length is 0. - * F_memory_out (with error bit) on out of memory. * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if the combined string is too large. @@ -1382,7 +1345,6 @@ extern "C" { * @return * F_none on success. * F_data_not_eos if source length is 0. - * F_memory_out (with error bit) on out of memory. * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if the combined string is too large. @@ -1407,7 +1369,6 @@ extern "C" { * @return * F_none on success. * F_data_not_eos if source length is 0. - * F_memory_out (with error bit) on out of memory. * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. * @@ -1437,7 +1398,6 @@ extern "C" { * @return * F_none on success. * F_data_not_eos if source length is 0. - * F_memory_out (with error bit) on out of memory. * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. * @@ -1511,7 +1471,6 @@ extern "C" { * F_data_not_stop if range.start > range.stop. * F_complete_not_utf (with error bit) if character is an incomplete UTF-8 fragment. * F_complete_not_utf_stop (with error bit) if the stop location is reached before the complete UTF-8 character can be processed. - * F_memory_out (with error bit) on out of memory. * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. * F_utf (with error bit) if a character in the string is an invalid UTF-8 character. @@ -1542,7 +1501,6 @@ extern "C" { * F_data_not_stop if range.start > range.stop. * F_complete_not_utf (with error bit) if character is an incomplete UTF-8 fragment. * F_complete_not_utf_stop (with error bit) if the stop location is reached before the complete UTF-8 character can be processed. - * F_memory_out (with error bit) on out of memory. * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. * F_utf (with error bit) if a character in the string is an invalid UTF-8 character. diff --git a/level_2/fll_fss/c/fss_basic.c b/level_2/fll_fss/c/fss_basic.c index db6a969..644c3b6 100644 --- a/level_2/fll_fss/c/fss_basic.c +++ b/level_2/fll_fss/c/fss_basic.c @@ -51,10 +51,8 @@ extern "C" { objects_quoted->used++; } - if (contents->array[contents->used].used == contents->array[contents->used].size) { - f_macro_fss_content_t_increase(status2, contents->array[contents->used]) - if (F_status_is_error(status2)) return status2; - } + f_macro_fss_content_t_increase(status2, contents->array[contents->used]) + if (F_status_is_error(status2)) return status2; contents->used++; @@ -88,10 +86,8 @@ extern "C" { else if (status == FL_fss_found_object_content_not) { found_data = F_true; - if (contents->array[contents->used].used == contents->array[contents->used].size) { - f_macro_fss_content_t_increase(status2, contents->array[contents->used]) - if (F_status_is_error(status2)) return status2; - } + f_macro_fss_content_t_increase(status2, contents->array[contents->used]) + if (F_status_is_error(status2)) return status2; break; } diff --git a/level_2/fll_fss/c/fss_basic_list.c b/level_2/fll_fss/c/fss_basic_list.c index 93f4ae6..73f1540 100644 --- a/level_2/fll_fss/c/fss_basic_list.c +++ b/level_2/fll_fss/c/fss_basic_list.c @@ -36,10 +36,8 @@ extern "C" { if (status == FL_fss_found_object || status == FL_fss_found_object_content_not) { objects->used++; - if (contents->array[contents->used].used == contents->array[contents->used].size) { - f_macro_fss_delimits_t_increase(status2, contents->array[contents->used]) - if (F_status_is_error(status2)) return status2; - } + f_macro_fss_delimits_t_increase(status2, contents->array[contents->used]) + if (F_status_is_error(status2)) return status2; contents->used++; @@ -73,10 +71,8 @@ extern "C" { else if (status == FL_fss_found_object_content_not) { found_data = F_true; - if (contents->array[contents->used].used == contents->array[contents->used].size) { - f_macro_fss_content_t_increase(status2, contents->array[contents->used]) - if (F_status_is_error(status2)) return status2; - } + f_macro_fss_content_t_increase(status2, contents->array[contents->used]) + if (F_status_is_error(status2)) return status2; break; } diff --git a/level_2/fll_fss/c/fss_extended.c b/level_2/fll_fss/c/fss_extended.c index 1c239eb..c310841 100644 --- a/level_2/fll_fss/c/fss_extended.c +++ b/level_2/fll_fss/c/fss_extended.c @@ -23,34 +23,33 @@ extern "C" { f_fss_quotes_t *quoted_content = 0; do { + if (objects->used == objects->size) { - f_macro_fss_objects_t_resize(status2, (*objects), objects->used + f_fss_default_allocation_step); + f_macro_fss_objects_t_increase(status2, (*objects)); if (F_status_is_error(status2)) return status2; - f_macro_fss_contents_t_resize(status2, (*contents), contents->used + f_fss_default_allocation_step); + f_macro_fss_contents_t_increase(status2, (*contents)); if (F_status_is_error(status2)) return status2; if (objects_quoted) { - f_macro_fss_quotes_t_resize(status2, (*objects_quoted), objects_quoted->used + f_fss_default_allocation_step); + f_macro_fss_quotes_t_increase(status2, (*objects_quoted)); if (F_status_is_error(status2)) return status2; } if (contents_quoted) { - f_macro_fss_quotess_t_resize(status2, (*contents_quoted), contents_quoted->used + f_fss_default_allocation_step); + f_macro_fss_quotess_t_increase(status2, (*contents_quoted)); if (F_status_is_error(status2)) return status2; } } do { + if (objects_quoted) { quoted_object = &objects_quoted->array[objects_quoted->used]; } status = fl_fss_extended_object_read(buffer, range, &objects->array[objects->used], quoted_object, objects_delimits); - - if (F_status_is_error(status)) { - return status; - } + if (F_status_is_error(status)) return status; if (range->start >= range->stop || range->start >= buffer.used) { if (status == FL_fss_found_object || status == FL_fss_found_object_content_not) { @@ -60,14 +59,15 @@ extern "C" { objects_quoted->used++; } - if (contents->array[contents->used].used == contents->array[contents->used].size) { - f_macro_fss_content_t_increase(status2, contents->array[contents->used]) - if (F_status_is_error(status2)) return status2; - } + f_macro_fss_content_t_increase(status2, contents->array[contents->used]) + if (F_status_is_error(status2)) return status2; contents->used++; if (contents_quoted) { + f_macro_fss_quotes_t_increase(status2, contents_quoted->array[contents_quoted->used]) + if (F_status_is_error(status2)) return status2; + contents_quoted->used++; } @@ -81,19 +81,21 @@ extern "C" { return F_none_stop; } - else { - if (range->start >= buffer.used) { - return F_data_not_eos; - } - return F_data_not_stop; + if (range->start >= buffer.used) { + return F_data_not_eos; } + + return F_data_not_stop; } if (status == FL_fss_found_object) { found_data = F_true; if (contents_quoted) { + f_macro_fss_quotes_t_increase(status2, contents_quoted->array[contents_quoted->used]) + if (F_status_is_error(status2)) return status2; + quoted_content = &contents_quoted->array[contents_quoted->used]; } @@ -107,12 +109,6 @@ extern "C" { } else if (status == FL_fss_found_object_content_not) { found_data = F_true; - - if (contents->array[contents->used].used == contents->array[contents->used].size) { - f_macro_fss_content_t_increase(status2, contents->array[contents->used]) - if (F_status_is_error(status2)) return status2; - } - break; } diff --git a/level_2/fll_fss/c/fss_extended_list.c b/level_2/fll_fss/c/fss_extended_list.c index 90342c3..0ec81ff 100644 --- a/level_2/fll_fss/c/fss_extended_list.c +++ b/level_2/fll_fss/c/fss_extended_list.c @@ -36,10 +36,8 @@ extern "C" { if (status == FL_fss_found_object || status == FL_fss_found_object_content_not) { objects->used++; - if (contents->array[contents->used].used == contents->array[contents->used].size) { - f_macro_fss_content_t_increase(status2, contents->array[contents->used]) - if (F_status_is_error(status2)) return status2; - } + f_macro_fss_content_t_increase(status2, contents->array[contents->used]) + if (F_status_is_error(status2)) return status2; contents->used++; @@ -73,10 +71,8 @@ extern "C" { else if (status == FL_fss_found_object_content_not) { found_data = F_true; - if (contents->array[contents->used].used == contents->array[contents->used].size) { - f_macro_fss_content_t_increase(status2, contents->array[contents->used]) - if (F_status_is_error(status2)) return status2; - } + f_macro_fss_content_t_increase(status2, contents->array[contents->used]) + if (F_status_is_error(status2)) return status2; break; } diff --git a/level_2/fll_program/c/program.c b/level_2/fll_program/c/program.c index 5f63c0a..e26b6b4 100644 --- a/level_2/fll_program/c/program.c +++ b/level_2/fll_program/c/program.c @@ -231,10 +231,8 @@ extern "C" { status = F_none; } else { - if (destination->used == destination->size) { - f_macro_string_dynamics_t_resize(status, (*destination), destination->size + f_memory_default_allocation_step); - if (F_status_is_error(status)) return status; - } + f_macro_string_dynamics_t_increase(status, (*destination)); + if (F_status_is_error(status)) return status; destination->array[destination->used] = ripped; destination->used++; diff --git a/level_2/fll_program/c/program.h b/level_2/fll_program/c/program.h index 450392b..d87be09 100644 --- a/level_2/fll_program/c/program.h +++ b/level_2/fll_program/c/program.h @@ -223,7 +223,6 @@ extern "C" { * F_none on success. * F_data_not if nothing to rip, no allocations or reallocations are performed. * F_array_too_large (with error bit) if a buffer would exceed max length. - * F_memory_out (with error bit) on out of memory. * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. * @@ -252,7 +251,6 @@ extern "C" { * @return * F_none on success. * F_data_not if nothing to rip, no allocations or reallocations are performed. - * F_memory_out (with error bit) on out of memory. * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if the combined string is too large. @@ -280,7 +278,6 @@ extern "C" { * @return * F_none on success. * F_data_not if nothing to rip, no allocations or reallocations are performed. - * F_memory_out (with error bit) on out of memory. * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. * @@ -311,7 +308,6 @@ extern "C" { * @return * F_none on success. * F_data_not if nothing to rip, no allocations or reallocations are performed. - * F_memory_out (with error bit) on out of memory. * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if the combined string is too large. diff --git a/level_3/fake/c/private-build.c b/level_3/fake/c/private-build.c index c994981..953e625 100644 --- a/level_3/fake/c/private-build.c +++ b/level_3/fake/c/private-build.c @@ -1599,7 +1599,7 @@ extern "C" { setting_mode_lengths[j] = settings_length[j] + 1 + modes->array[i].used; - f_macro_string_dynamic_t_resize(*status, settings_mode_name_dynamic[j], setting_mode_lengths[j]); + f_macro_string_dynamic_t_resize(*status, settings_mode_name_dynamic[j], setting_mode_lengths[j]); if (F_status_is_error(*status)) { function = " f_macro_string_dynamic_t_resize";