From: Kevin Day Date: Wed, 19 Jul 2023 04:11:32 +0000 (-0500) Subject: Progress: Continue memory array related changes, replacing the f_memory_structure... X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=aafcfc8bae81976748cb7c2651c19ff22c3ce33c;p=fll Progress: Continue memory array related changes, replacing the f_memory_structure entirely. The f_memory_array set of functions now fully replaces the f_memory_structure functions and related macros. I think those structure macros are nifty but they are not in use enough anymore and the f_memory_array structure is what I am going forward with. There is still an enormouse amount of changes to do. --- diff --git a/build/disable/level_0/f_fss.h b/build/disable/level_0/f_fss.h index d1c2f97..56ca48f 100644 --- a/build/disable/level_0/f_fss.h +++ b/build/disable/level_0/f_fss.h @@ -84,11 +84,22 @@ #define _di_f_fss_simple_packet_d_ #define _di_f_fss_simple_packet_identify_ #define _di_f_fss_simple_packet_ranges_adjust_ +#define _di_f_fss_simple_packet_ranges_append_ +#define _di_f_fss_simple_packet_ranges_append_all_ #define _di_f_fss_simple_packet_ranges_decimate_by_ #define _di_f_fss_simple_packet_ranges_decrease_by_ #define _di_f_fss_simple_packet_ranges_increase_ #define _di_f_fss_simple_packet_ranges_increase_by_ #define _di_f_fss_simple_packet_ranges_resize_ +#define _di_f_fss_simple_packet_rangess_adjust_ +#define _di_f_fss_simple_packet_rangess_append_ +#define _di_f_fss_simple_packet_rangess_append_all_ +#define _di_f_fss_simple_packet_rangess_decimate_by_ +#define _di_f_fss_simple_packet_rangess_decrease_by_ +#define _di_f_fss_simple_packet_rangess_increase_ +#define _di_f_fss_simple_packet_rangess_increase_by_ +#define _di_f_fss_simple_packet_rangess_resize_ +#define _di_f_fss_simple_packet_rangess_t_ #define _di_f_fss_simple_packet_ranges_t_ #define _di_f_fss_simple_packet_range_t_ #define _di_f_fss_skip_past_delimit_ diff --git a/build/disable/level_0/f_memory.h b/build/disable/level_0/f_memory.h index 3543d66..59df8a5 100644 --- a/build/disable/level_0/f_memory.h +++ b/build/disable/level_0/f_memory.h @@ -1,36 +1,13 @@ #define _di_f_memory_adjust_ +#define _di_f_memory_array_adjust_ +#define _di_f_memory_array_decimate_by_ +#define _di_f_memory_array_decrease_by_ +#define _di_f_memory_array_increase_ +#define _di_f_memory_array_increase_by_ +#define _di_f_memory_array_resize_ #define _di_f_memory_default_d_ #define _di_f_memory_delete_ #define _di_f_memory_destroy_ #define _di_f_memory_new_ #define _di_f_memory_new_aligned_ #define _di_f_memory_resize_ -#define _di_f_memory_structure_adjust_ -#define _di_f_memory_structure_decimate_by_ -#define _di_f_memory_structure_decrease_by_ -#define _di_f_memory_structure_increase_ -#define _di_f_memory_structure_increase_by_ -#define _di_f_memory_structure_resize_ -#define _di_macro_f_memory_structure_adjust_ -#define _di_macro_f_memory_structure_clear_ -#define _di_macro_f_memory_structure_decimate_by_ -#define _di_macro_f_memory_structure_decrease_by_ -#define _di_macro_f_memory_structure_delete_ -#define _di_macro_f_memory_structure_delete_simple_ -#define _di_macro_f_memory_structure_destroy_ -#define _di_macro_f_memory_structure_destroy_simple_ -#define _di_macro_f_memory_structure_increase_ -#define _di_macro_f_memory_structure_increase_by_ -#define _di_macro_f_memory_structure_increment_ -#define _di_macro_f_memory_structure_resize_ -#define _di_macro_f_memory_structures_adjust_ -#define _di_macro_f_memory_structures_clear_ -#define _di_macro_f_memory_structures_decimate_by_ -#define _di_macro_f_memory_structures_decrease_by_ -#define _di_macro_f_memory_structures_delete_ -#define _di_macro_f_memory_structures_delete_simple_ -#define _di_macro_f_memory_structures_destroy_ -#define _di_macro_f_memory_structures_destroy_simple_ -#define _di_macro_f_memory_structures_increase_ -#define _di_macro_f_memory_structures_increase_by_ -#define _di_macro_f_memory_structures_resize_ diff --git a/build/level_0/settings b/build/level_0/settings index d6222c8..520533c 100644 --- a/build/level_0/settings +++ b/build/level_0/settings @@ -48,7 +48,7 @@ build_sources_library fss.c fss/common.c fss/item.c fss/named.c fss/nest.c fss/q build_sources_library fss/private-item.c fss/private-named.c fss/private-nest.c fss/private-set.c fss/private-set_quote.c fss/private-simple_packet.c build_sources_library iki.c iki/common.c iki/data.c private-iki.c iki/private-data.c build_sources_library limit.c limit/set.c limit/value.c limit/private-set.c limit/private-value.c -build_sources_library memory.c memory/array.c memory/structure.c +build_sources_library memory.c memory/array.c build_sources_library private-memory.c memory/private-array.c build_sources_library network.c build_sources_library parse.c parse/utf.c @@ -107,7 +107,7 @@ build_sources_headers file.h file/common.h file/stream.h build_sources_headers fss.h fss/common.h fss/item.h fss/named.h fss/nest.h fss/quote.h fss/set.h fss/set_quote.h fss/simple_packet.h build_sources_headers iki.h iki/common.h iki/data.h build_sources_headers limit.h limit/set.h limit/value.h -build_sources_headers memory.h memory/array.h memory/common.h memory/structure.h +build_sources_headers memory.h memory/array.h memory/common.h build_sources_headers network.h network/common.h build_sources_headers parse.h parse/utf.h build_sources_headers path.h path/common.h diff --git a/build/monolithic/settings b/build/monolithic/settings index e60f0d7..fef20f6 100644 --- a/build/monolithic/settings +++ b/build/monolithic/settings @@ -48,7 +48,7 @@ build_sources_library level_0/fss.c level_0/fss/common.c level_0/fss/item.c leve build_sources_library level_0/fss/private-item.c level_0/fss/private-named.c level_0/fss/private-nest.c level_0/fss/private-set.c level_0/fss/private-set_quote.c level_0/fss/private-simple_packet.c build_sources_library level_0/iki.c level_0/iki/common.c level_0/iki/data.c level_0/private-iki.c level_0/iki/private-data.c build_sources_library level_0/limit.c level_0/limit/set.c level_0/limit/value.c level_0/limit/private-set.c level_0/limit/private-value.c -build_sources_library level_0/memory.c level_0/memory/array.c level_0/memory/structure.c +build_sources_library level_0/memory.c level_0/memory/array.c build_sources_library level_0/private-memory.c level_0/memory/private-array.c build_sources_library level_0/network.c build_sources_library level_0/parse.c level_0/parse/utf.c @@ -129,7 +129,7 @@ build_sources_headers level_0/file.h level_0/file/common.h level_0/file/stream.h build_sources_headers level_0/fss.h level_0/fss/common.h level_0/fss/item.h level_0/fss/named.h level_0/fss/nest.h level_0/fss/quote.h level_0/fss/set.h level_0/fss/set_quote.h level_0/fss/simple_packet.h build_sources_headers level_0/iki.h level_0/iki/common.h level_0/iki/data.h build_sources_headers level_0/limit.h level_0/limit/set.h level_0/limit/value.h -build_sources_headers level_0/memory.h level_0/memory/array.h level_0/memory/common.h level_0/memory/structure.h +build_sources_headers level_0/memory.h level_0/memory/array.h level_0/memory/common.h build_sources_headers level_0/network.h level_0/network/common.h build_sources_headers level_0/parse.h level_0/parse/utf.h build_sources_headers level_0/path.h level_0/path/common.h diff --git a/build/stand_alone/fake.config.h b/build/stand_alone/fake.config.h index 1e63de8..52bea47 100644 --- a/build/stand_alone/fake.config.h +++ b/build/stand_alone/fake.config.h @@ -401,13 +401,13 @@ //#define _di_f_file_name_directory_ //#define _di_f_file_open_ #define _di_f_file_open_at_ -//#define _di_f_file_open_mode_append_s_ //#define _di_f_file_open_mode_read_append_s_ //#define _di_f_file_open_mode_read_s_ //#define _di_f_file_open_mode_read_truncate_s_ //#define _di_f_file_open_mode_read_write_s_ //#define _di_f_file_open_mode_s_ -//#define _di_f_file_open_mode_truncate_s_ +//#define _di_f_file_open_mode_write_append_s_ +//#define _di_f_file_open_mode_write_truncate_s_ //#define _di_f_file_operation_access_s_ //#define _di_f_file_operation_analyze_s_ #define _di_f_file_operation_append_s_ @@ -1179,19 +1179,13 @@ #define _di_f_memory_array_decrease_by_ #define _di_f_memory_array_increase_ #define _di_f_memory_array_increase_by_ -#define _di_f_memory_array_resize_ +//#define _di_f_memory_array_resize_ //#define _di_f_memory_default_d_ //#define _di_f_memory_delete_ #define _di_f_memory_destroy_ #define _di_f_memory_new_ #define _di_f_memory_new_aligned_ //#define _di_f_memory_resize_ -#define _di_f_memory_structure_adjust_ -#define _di_f_memory_structure_decimate_by_ -#define _di_f_memory_structure_decrease_by_ -#define _di_f_memory_structure_increase_ -#define _di_f_memory_structure_increase_by_ -#define _di_f_memory_structure_resize_ //#define _di_f_mode_t_ @@ -1527,7 +1521,7 @@ #define _di_f_socket_message_flag_e_ #define _di_f_socket_name_host_ #define _di_f_socket_name_peer_ -#define _di_f_socket_option_d_ +#define _di_f_socket_option_e_ #define _di_f_socket_option_get_ #define _di_f_socket_option_set_ #define _di_f_socket_protocol_e_ @@ -1554,7 +1548,7 @@ #define _di_f_socketss_t_ #define _di_f_sockets_t_ #define _di_f_socket_t_ -#define _di_f_socket_type_d_ +#define _di_f_socket_type_e_ #define _di_f_socket_write_ #define _di_f_socket_write_message_ #define _di_f_socket_write_stream_ diff --git a/build/stand_alone/fake.settings b/build/stand_alone/fake.settings index 972b5a5..5aff6fe 100644 --- a/build/stand_alone/fake.settings +++ b/build/stand_alone/fake.settings @@ -46,7 +46,8 @@ build_sources_program fll/level_0/fss.c fll/level_0/fss/common.c fll/level_0/fss build_sources_program fll/level_0/fss/private-item.c fll/level_0/fss/private-named.c fll/level_0/fss/private-nest.c fll/level_0/fss/private-set.c fll/level_0/fss/private-set_quote.c fll/level_0/fss/private-simple_packet.c build_sources_program fll/level_0/iki.c fll/level_0/private-iki.c fll/level_0/iki/common.c fll/level_0/iki/private-data.c fll/level_0/iki/data.c build_sources_program fll/level_0/limit.c fll/level_0/limit/set.c fll/level_0/limit/value.c fll/level_0/limit/private-set.c fll/level_0/limit/private-value.c -build_sources_program fll/level_0/memory.c fll/level_0/private-memory.c fll/level_0/memory/structure.c +build_sources_program fll/level_0/memory.c fll/level_0/memory/array.c +build_sources_program fll/level_0/private-memory.c fll/level_0/memory/private-array.c build_sources_program fll/level_0/parse.c fll/level_0/parse/utf.c build_sources_program fll/level_0/path.c fll/level_0/private-path.c fll/level_0/path/common.c build_sources_program fll/level_0/pipe.c diff --git a/level_0/f_directory/c/directory/private-type.c b/level_0/f_directory/c/directory/private-type.c index c46c6d9..890c911 100644 --- a/level_0/f_directory/c/directory/private-type.c +++ b/level_0/f_directory/c/directory/private-type.c @@ -8,53 +8,36 @@ extern "C" { #if !defined(_di_f_directory_statuss_adjust_) || !defined(_di_f_directory_statuss_decimate_by_) f_status_t private_f_directory_statuss_adjust(const f_number_unsigned_t length, f_directory_statuss_t * const statuss) { - f_status_t status = F_none; + { + f_status_t status = F_none; - for (f_number_unsigned_t i = length; i < statuss->size; ++i) { + for (f_number_unsigned_t i = length; i < statuss->size; ++i) { - status = f_string_dynamic_adjust(0, &statuss->array[i].path); - if (F_status_is_error(status)) return status; - } // for - - status = f_memory_adjust(statuss->size, length, sizeof(f_directory_status_t), (void **) & statuss->array); - - if (F_status_is_error_not(status)) { - statuss->size = length; - - if (statuss->used > statuss->size) { - statuss->used = length; - } + status = f_string_dynamic_adjust(0, &statuss->array[i].path); + if (F_status_is_error(status)) return status; + } // for } - if (F_status_is_error(status)) return status; - - return F_none; + return f_memory_array_adjust(length, sizeof(f_directory_status_t), (void **) &statuss->array, &statuss->used, &statuss->size); } #endif // !defined(_di_f_directory_statuss_adjust_) || !defined(_di_f_directory_statuss_decimate_by_) -#if !defined(_di_f_directory_statuss_decrease_by_) || !defined(_di_f_directory_statuss_increase_) || !defined(_di_f_directory_statuss_increase_by_) || !defined(_di_f_directory_statuss_resize_) +#if !defined(_di_f_directory_statuss_decrease_by_) || !defined(_di_f_directory_statuss_resize_) f_status_t private_f_directory_statuss_resize(const f_number_unsigned_t length, f_directory_statuss_t * const statuss) { - f_status_t status = F_none; - - for (f_number_unsigned_t i = length; i < statuss->size; ++i) { - - status = f_string_dynamic_resize(0, &statuss->array[i].path); - if (F_status_is_error(status)) return status; - } // for - - status = f_memory_resize(statuss->size, length, sizeof(f_directory_status_t), (void **) & statuss->array); - if (F_status_is_error(status)) return status; + { + f_status_t status = F_none; - statuss->size = length; + for (f_number_unsigned_t i = length; i < statuss->size; ++i) { - if (statuss->used > statuss->size) { - statuss->used = length; + status = f_string_dynamic_resize(0, &statuss->array[i].path); + if (F_status_is_error(status)) return status; + } // for } - return F_none; + return f_memory_array_resize(length, sizeof(f_directory_status_t), (void **) &statuss->array, &statuss->used, &statuss->size); } -#endif // !defined(_di_f_directory_statuss_decrease_by_) || !defined(_di_f_directory_statuss_increase_) || !defined(_di_f_directory_statuss_increase_by_) || !defined(_di_f_directory_statuss_resize_) +#endif // !defined(_di_f_directory_statuss_decrease_by_) || !defined(_di_f_directory_statuss_resize_) #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_directory/c/directory/private-type.h b/level_0/f_directory/c/directory/private-type.h index 6131478..251c379 100644 --- a/level_0/f_directory/c/directory/private-type.h +++ b/level_0/f_directory/c/directory/private-type.h @@ -26,16 +26,18 @@ extern "C" { * The statuss to adjust. * * @return - * F_none on success. + * Success from f_memory_array_adjust(). * - * Errors (with error bit) from: f_memory_adjust(). - * Errors (with error bit) from: private_f_directory_status_adjust(). + * F_parameter (with error bit) if a parameter is invalid. * - * @see private_f_directory_status_adjust() + * Errors (with error bit) from: f_memory_array_adjust(). + * Errors (with error bit) from: f_string_dynamic_adjust(). + * + * @see f_memory_array_adjust() + * @see f_string_dynamic_adjust() * * @see f_directory_statuss_adjust() * @see f_directory_statuss_decimate_by() - * @see f_memory_adjust() */ #if !defined(_di_f_directory_statuss_adjust_) || !defined(_di_f_directory_statuss_decimate_by_) extern f_status_t private_f_directory_statuss_adjust(const f_number_unsigned_t length, f_directory_statuss_t * const statuss) F_attribute_visibility_internal_d; @@ -52,21 +54,22 @@ extern "C" { * The statuss to resize. * * @return - * F_none on success. + * Success from f_memory_array_resize(). + * + * F_parameter (with error bit) if a parameter is invalid. * + * Errors (with error bit) from: f_memory_array_resize(). * Errors (with error bit) from: f_string_dynamic_resize(). * + * @see f_memory_array_resize() * @see f_string_dynamic_resize() * - * @see f_directory_statuss_decrease_by() - * @see f_directory_statuss_increase() - * @see f_directory_statuss_increase_by() * @see f_directory_statuss_resize() - * @see f_memory_resize() + * @see f_directory_statuss_decimate_by() */ -#if !defined(_di_f_directory_statuss_decrease_by_) || !defined(_di_f_directory_statuss_increase_) || !defined(_di_f_directory_statuss_increase_by_) || !defined(_di_f_directory_statuss_resize_) +#if !defined(_di_f_directory_statuss_decrease_by_) || !defined(_di_f_directory_statuss_resize_) extern f_status_t private_f_directory_statuss_resize(const f_number_unsigned_t length, f_directory_statuss_t * const statuss) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_directory_statuss_decrease_by_) || !defined(_di_f_directory_statuss_increase_) || !defined(_di_f_directory_statuss_increase_by_) || !defined(_di_f_directory_statuss_resize_) +#endif // !defined(_di_f_directory_statuss_decrease_by_) || !defined(_di_f_directory_statuss_resize_) #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_directory/c/directory/type.c b/level_0/f_directory/c/directory/type.c index ead2c3e..f3c7e68 100644 --- a/level_0/f_directory/c/directory/type.c +++ b/level_0/f_directory/c/directory/type.c @@ -91,11 +91,7 @@ extern "C" { if (!amount) return F_data_not; - if (statuss->size - amount > 0) { - return private_f_directory_statuss_adjust(statuss->size - amount, statuss); - } - - return private_f_directory_statuss_adjust(0, statuss); + return private_f_directory_statuss_adjust((statuss->size - amount > 0) ? statuss->size - amount : 0, statuss); } #endif // _di_f_directory_statuss_decimate_by_ @@ -107,11 +103,7 @@ extern "C" { if (!amount) return F_data_not; - if (statuss->size - amount > 0) { - return private_f_directory_statuss_resize(statuss->size - amount, statuss); - } - - return private_f_directory_statuss_resize(0, statuss); + return private_f_directory_statuss_resize((statuss->size - amount > 0) ? statuss->size - amount : 0, statuss); } #endif // _di_f_directory_statuss_decrease_by_ @@ -121,19 +113,7 @@ extern "C" { if (!statuss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (step && statuss->used + 1 > statuss->size) { - f_number_unsigned_t size = statuss->used + step; - - if (size > F_number_t_size_unsigned_d) { - if (statuss->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - - size = F_number_t_size_unsigned_d; - } - - return private_f_directory_statuss_resize(size, statuss); - } - - return F_data_not; + return f_memory_array_increase(step, sizeof(f_directory_status_t), (void **) &statuss->array, &statuss->used, &statuss->size); } #endif // _di_f_directory_statuss_increase_ @@ -143,15 +123,7 @@ extern "C" { if (!statuss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; - - if (statuss->used + amount > statuss->size) { - if (statuss->used + amount > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - - return private_f_directory_statuss_resize(statuss->used + amount, statuss); - } - - return F_data_not; + return f_memory_array_increase_by(amount, sizeof(f_directory_status_t), (void **) &statuss->array, &statuss->used, &statuss->size); } #endif // _di_f_directory_statuss_increase_by_ diff --git a/level_0/f_directory/c/directory/type.h b/level_0/f_directory/c/directory/type.h index 4620e5a..bab9b52 100644 --- a/level_0/f_directory/c/directory/type.h +++ b/level_0/f_directory/c/directory/type.h @@ -304,13 +304,15 @@ extern "C" { * The statuss structure to adjust. * * @return - * F_none on success. + * Success from f_memory_array_adjust(). * - * Errors (with error bit) from: f_memory_resize(). - * Errors (with error bit) from: f_string_dynamic_resize(). + * F_parameter (with error bit) if a parameter is invalid. * - * @see f_memory_resize() - * @see f_string_dynamic_resize() + * Errors (with error bit) from: f_memory_array_adjust(). + * Errors (with error bit) from: f_string_dynamic_adjust(). + * + * @see f_memory_array_adjust() + * @see f_string_dynamic_adjust() */ #ifndef _di_f_directory_statuss_adjust_ extern f_status_t f_directory_statuss_adjust(const f_number_unsigned_t length, f_directory_statuss_t * const statuss); @@ -329,14 +331,15 @@ extern "C" { * The statuss array to resize. * * @return - * F_none on success. - * F_data_not if amount is 0. + * Success from f_memory_array_adjust(). * - * Errors (with error bit) from: f_memory_resize(). - * Errors (with error bit) from: f_string_dynamic_resize(). + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_array_adjust(). + * Errors (with error bit) from: f_string_dynamic_adjust(). * - * @see f_memory_resize() - * @see f_string_dynamic_resize() + * @see f_memory_array_adjust() + * @see f_string_dynamic_adjust() */ #ifndef _di_f_directory_statuss_decimate_by_ extern f_status_t f_directory_statuss_decimate_by(const f_number_unsigned_t amount, f_directory_statuss_t * const statuss); @@ -355,14 +358,15 @@ extern "C" { * The statuss array to resize. * * @return - * F_none on success. - * F_data_not if amount is 0. + * Success from f_memory_array_resize(). + * + * F_parameter (with error bit) if a parameter is invalid. * - * Errors (with error bit) from: f_memory_resize(). + * Errors (with error bit) from: f_memory_array_resize(). * Errors (with error bit) from: f_string_dynamic_resize(). * - * @see f_memory_resize() - * @see f_string_dynamic_resize() + * @see f_memory_array_resize() + * @see f_string_dynamic_resize() */ #ifndef _di_f_directory_statuss_decrease_by_ extern f_status_t f_directory_statuss_decrease_by(const f_number_unsigned_t amount, f_directory_statuss_t * const statuss); @@ -381,14 +385,13 @@ extern "C" { * The statuss array to resize. * * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + 1 <= size). + * Success from f_memory_array_increase(). * - * Errors (with error bit) from: f_memory_resize(). - * Errors (with error bit) from: f_string_dynamic_resize(). + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_array_increase(). * - * @see f_memory_resize() - * @see f_string_dynamic_resize() + * @see f_memory_array_increase() */ #ifndef _di_f_directory_statuss_increase_ extern f_status_t f_directory_statuss_increase(const f_number_unsigned_t step, f_directory_statuss_t * const statuss); @@ -407,14 +410,13 @@ extern "C" { * The statuss array to resize. * * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + amount <= size). + * Success from f_memory_array_increase_by(). * - * Errors (with error bit) from: f_memory_resize(). - * Errors (with error bit) from: f_string_dynamic_resize(). + * F_parameter (with error bit) if a parameter is invalid. * - * @see f_memory_resize() - * @see f_string_dynamic_resize() + * Errors (with error bit) from: f_memory_array_increase_by(). + * + * @see f_memory_array_increase_by() */ #ifndef _di_f_directory_statuss_increase_by_ extern f_status_t f_directory_statuss_increase_by(const f_number_unsigned_t amount, f_directory_statuss_t * const statuss); @@ -429,13 +431,15 @@ extern "C" { * The directory status array to resize. * * @return - * F_none on success. + * Success from f_memory_array_resize(). * - * Errors (with error bit) from: f_memory_resize(). + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_array_resize(). * Errors (with error bit) from: f_string_dynamic_resize(). * - * @see f_memory_resize() - * @see f_string_dynamic_resize() + * @see f_memory_array_resize() + * @see f_string_dynamic_resize() */ #ifndef _di_f_directory_statuss_resize_ extern f_status_t f_directory_statuss_resize(const f_number_unsigned_t length, f_directory_statuss_t * const statuss); diff --git a/level_0/f_fss/c/fss/item.c b/level_0/f_fss/c/fss/item.c index ef6325c..9d2e877 100644 --- a/level_0/f_fss/c/fss/item.c +++ b/level_0/f_fss/c/fss/item.c @@ -22,9 +22,8 @@ extern "C" { #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - if (items->size > amount) return private_f_fss_items_adjust(items->size - amount, items); - return private_f_fss_items_adjust(0, items); + return private_f_fss_items_adjust((items->size > amount) ? items->size - amount : 0, items); } #endif // _di_f_fss_items_decimate_by_ @@ -35,9 +34,8 @@ extern "C" { #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - if (items->size > amount) return private_f_fss_items_resize(items->size - amount, items); - return private_f_fss_items_resize(0, items); + return private_f_fss_items_resize((items->size > amount) ? items->size - amount : 0, items); } #endif // _di_f_fss_items_decrease_by_ @@ -47,19 +45,7 @@ extern "C" { if (!items) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (step && items->used + 1 > items->size) { - f_number_unsigned_t size = items->used + step; - - if (size > F_number_t_size_unsigned_d) { - if (items->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - - size = F_number_t_size_unsigned_d; - } - - return private_f_fss_items_resize(size, items); - } - - return F_data_not; + return f_memory_array_increase(step, sizeof(f_fss_item_t), (void **) &items->array, &items->used, &items->size); } #endif // _di_f_fss_items_increase_ @@ -69,15 +55,7 @@ extern "C" { if (!items) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; - - if (items->used + amount > items->size) { - if (items->used + amount > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - - return private_f_fss_items_resize(items->used + amount, items); - } - - return F_data_not; + return f_memory_array_increase_by(amount, sizeof(f_fss_item_t), (void **) &items->array, &items->used, &items->size); } #endif // _di_f_fss_items_increase_by_ diff --git a/level_0/f_fss/c/fss/item.h b/level_0/f_fss/c/fss/item.h index 9f4b58c..d8ed268 100644 --- a/level_0/f_fss/c/fss/item.h +++ b/level_0/f_fss/c/fss/item.h @@ -103,8 +103,6 @@ extern "C" { #define macro_f_fss_items_t_initialize_1(array, size, used) { array, size, used } #define macro_f_fss_items_t_initialize_2(array, length) { array, length, length } - #define macro_f_fss_items_t_clear(items) macro_f_memory_structure_clear(items) - #define macro_f_fss_items_t_resize(status, items, length) status = f_fss_items_resize(length, &items); #define macro_f_fss_items_t_adjust(status, items, length) status = f_fss_items_adjust(length, &items); @@ -171,10 +169,15 @@ extern "C" { * The items array to resize. * * @return - * F_none on success. + * Success from f_memory_array_adjust(). * - * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_array_adjust(). + * Errors (with error bit) from: f_string_dynamic_adjust(). + * + * @see f_memory_array_adjust() + * @see f_string_dynamic_adjust() */ #ifndef _di_f_fss_items_decrease_by_ extern f_status_t f_fss_items_decrease_by(const f_number_unsigned_t amount, f_fss_items_t * const items); @@ -193,12 +196,13 @@ extern "C" { * The items array to resize. * * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + 1 <= size). + * Success from f_memory_array_increase(). * - * F_array_too_large (with error bit) if the new array length is too large. - * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_array_increase(). + * + * @see f_memory_array_increase() */ #ifndef _di_f_fss_items_increase_ extern f_status_t f_fss_items_increase(const f_number_unsigned_t step, f_fss_items_t * const items); @@ -217,12 +221,13 @@ extern "C" { * The items array to resize. * * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + amount <= size). + * Success from f_memory_array_increase_by(). * - * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. - * F_array_too_large (with error bit) if the new array length is too large. + * + * Errors (with error bit) from: f_memory_array_increase_by(). + * + * @see f_memory_array_increase_by() */ #ifndef _di_f_fss_items_increase_by_ extern f_status_t f_fss_items_increase_by(const f_number_unsigned_t amount, f_fss_items_t * const items); @@ -234,13 +239,18 @@ extern "C" { * @param length * The new size to use. * @param items - * The items array to adjust. + * The items array to resize. * * @return - * F_none on success. + * Success from f_memory_array_resize(). * - * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_array_resize(). + * Errors (with error bit) from: f_string_dynamic_resize(). + * + * @see f_memory_array_resize() + * @see f_string_dynamic_resize() */ #ifndef _di_f_fss_items_resize_ extern f_status_t f_fss_items_resize(const f_number_unsigned_t length, f_fss_items_t * const items); diff --git a/level_0/f_fss/c/fss/named.c b/level_0/f_fss/c/fss/named.c index 86f81a3..c41d115 100644 --- a/level_0/f_fss/c/fss/named.c +++ b/level_0/f_fss/c/fss/named.c @@ -22,9 +22,8 @@ extern "C" { #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - if (named->objects.size - amount > 0) return private_f_fss_named_adjust(named->objects.size - amount, named); - return private_f_fss_named_adjust(0, named); + return private_f_fss_named_adjust((named->objects.size - amount > 0) ? named->objects.size - amount : 0, named); } #endif // _di_f_fss_named_decimate_by_ @@ -35,9 +34,8 @@ extern "C" { #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - if (named->objects.size - amount > 0) return private_f_fss_named_resize(named->objects.size - amount, named); - return private_f_fss_named_resize(0, named); + return private_f_fss_named_resize((named->objects.size - amount > 0) ? named->objects.size - amount : 0, named); } #endif // _di_f_fss_named_decrease_by_ @@ -48,6 +46,8 @@ extern "C" { #endif // _di_level_0_parameter_checking_ if (step && named->objects.used + 1 > named->objects.size) { + if (named->objects.used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + f_number_unsigned_t size = named->objects.used + step; if (size > F_number_t_size_unsigned_d) { @@ -69,12 +69,16 @@ extern "C" { if (!named) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; + if (amount) { + if (named->objects.used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + + const f_number_unsigned_t length = named->objects.used + amount; - if (named->objects.used + amount > named->objects.size) { - if (named->objects.used + amount > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + if (length > named->objects.size) { + if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - return private_f_fss_named_resize(named->objects.used + amount, named); + return private_f_fss_named_resize(length, named); + } } return F_data_not; @@ -108,9 +112,8 @@ extern "C" { #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - if (nameds->size > amount) return private_f_fss_nameds_adjust(nameds->size - amount, nameds); - return private_f_fss_nameds_adjust(0, nameds); + return private_f_fss_nameds_adjust((nameds->size > amount) ? nameds->size - amount : 0, nameds); } #endif // _di_f_fss_nameds_decimate_by_ @@ -121,9 +124,8 @@ extern "C" { #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - if (nameds->size > amount) return private_f_fss_nameds_resize(nameds->size - amount, nameds); - return private_f_fss_nameds_resize(0, nameds); + return private_f_fss_nameds_resize((nameds->size > amount) ? nameds->size - amount : 0, nameds); } #endif // _di_f_fss_nameds_decrease_by_ @@ -133,19 +135,7 @@ extern "C" { if (!nameds) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (step && nameds->used + 1 > nameds->size) { - f_number_unsigned_t size = nameds->used + step; - - if (size > F_number_t_size_unsigned_d) { - if (nameds->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - - size = F_number_t_size_unsigned_d; - } - - return private_f_fss_nameds_resize(size, nameds); - } - - return F_data_not; + return f_memory_array_increase(step, sizeof(f_fss_named_t), (void **) &nameds->array, &nameds->used, &nameds->size); } #endif // _di_f_fss_nameds_increase_ @@ -155,15 +145,7 @@ extern "C" { if (!nameds) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; - - if (nameds->used + amount > nameds->size) { - if (nameds->used + amount > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - - return private_f_fss_nameds_resize(nameds->used + amount, nameds); - } - - return F_data_not; + return f_memory_array_increase_by(amount, sizeof(f_fss_named_t), (void **) &nameds->array, &nameds->used, &nameds->size); } #endif // _di_f_fss_nameds_increase_by_ diff --git a/level_0/f_fss/c/fss/named.h b/level_0/f_fss/c/fss/named.h index fbd9da6..248c9a6 100644 --- a/level_0/f_fss/c/fss/named.h +++ b/level_0/f_fss/c/fss/named.h @@ -80,8 +80,6 @@ extern "C" { #define macro_f_fss_nameds_t_initialize_1(array, size, used) { array, size, used } #define macro_f_fss_nameds_t_initialize_2(array, length) { array, length, length } - #define macro_f_fss_nameds_t_clear(nameds) macro_f_memory_structure_clear(nameds); - #define macro_f_fss_nameds_t_resize(status, nameds, length) status = f_fss_nameds_resize(length, &nameds); #define macro_f_fss_nameds_t_adjust(status, nameds, length) status = f_fss_nameds_adjust(length, &nameds); @@ -225,18 +223,27 @@ extern "C" { #endif // _di_f_fss_named_resize_ /** - * Resize the named array. + * Adjust the named array. * * @param length * The new size to use. * @param nameds - * The nameds array to resize. + * The nameds array to adjust. * * @return - * F_none on success. + * Success from f_memory_array_resize(). * - * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_array_resize(). + * Errors (with error bit) from: f_string_ranges_resize(). + * Errors (with error bit) from: f_string_rangess_resize(). + * Errors (with error bit) from: f_uint8ss_resize(). + * + * @see f_memory_array_resize() + * @see f_string_ranges_resize() + * @see f_string_rangess_resize() + * @see f_uint8ss_resize() */ #ifndef _di_f_fss_nameds_adjust_ extern f_status_t f_fss_nameds_adjust(const f_number_unsigned_t length, f_fss_nameds_t * const nameds); @@ -299,12 +306,13 @@ extern "C" { * The nameds array to resize. * * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + 1 <= size). + * Success from f_memory_array_increase(). * - * F_array_too_large (with error bit) if the new array length is too large. - * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_array_increase(). + * + * @see f_memory_array_increase() */ #ifndef _di_f_fss_nameds_increase_ extern f_status_t f_fss_nameds_increase(const f_number_unsigned_t step, f_fss_nameds_t * const nameds); @@ -323,12 +331,13 @@ extern "C" { * The nameds array to resize. * * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + amount <= size). + * Success from f_memory_array_increase_by(). * - * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. - * F_array_too_large (with error bit) if the new array length is too large. + * + * Errors (with error bit) from: f_memory_array_increase_by(). + * + * @see f_memory_array_increase_by() */ #ifndef _di_f_fss_nameds_increase_by_ extern f_status_t f_fss_nameds_increase_by(const f_number_unsigned_t amount, f_fss_nameds_t * const nameds); @@ -340,13 +349,22 @@ extern "C" { * @param length * The new size to use. * @param nameds - * The nameds array to adjust. + * The nameds array to resize. * * @return - * F_none on success. + * Success from f_memory_array_resize(). * - * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_array_resize(). + * Errors (with error bit) from: f_string_ranges_resize(). + * Errors (with error bit) from: f_string_rangess_resize(). + * Errors (with error bit) from: f_uint8ss_resize(). + * + * @see f_memory_array_resize() + * @see f_string_ranges_resize() + * @see f_string_rangess_resize() + * @see f_uint8ss_resize() */ #ifndef _di_f_fss_nameds_resize_ extern f_status_t f_fss_nameds_resize(const f_number_unsigned_t length, f_fss_nameds_t * const nameds); diff --git a/level_0/f_fss/c/fss/nest.c b/level_0/f_fss/c/fss/nest.c index 973e122..94f2085 100644 --- a/level_0/f_fss/c/fss/nest.c +++ b/level_0/f_fss/c/fss/nest.c @@ -23,9 +23,8 @@ extern "C" { #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - if (nest->size > amount) return private_f_fss_nest_adjust(nest->size - amount, nest); - return private_f_fss_nest_adjust(0, nest); + return private_f_fss_nest_adjust((nest->size > amount) ? nest->size - amount : 0, nest); } #endif // _di_f_fss_nest_decimate_by_ @@ -36,9 +35,8 @@ extern "C" { #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - if (nest->size > amount) return private_f_fss_nest_resize(nest->size - amount, nest); - return private_f_fss_nest_resize(0, nest); + return private_f_fss_nest_resize((nest->size > amount) ? nest->size - amount : 0, nest); } #endif // _di_f_fss_nest_decrease_by_ @@ -49,6 +47,8 @@ extern "C" { #endif // _di_level_0_parameter_checking_ if (step && nest->used + 1 > nest->size) { + if (nest->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + f_number_unsigned_t size = nest->used + step; if (size > F_number_t_size_unsigned_d) { @@ -70,12 +70,16 @@ extern "C" { if (!nest) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; + if (amount) { + if (nest->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - if (nest->used + amount > nest->size) { - if (nest->used + amount > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + const f_number_unsigned_t length = nest->used + amount; - return private_f_fss_nest_resize(nest->used + amount, nest); + if (length > nest->size) { + if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + + return private_f_fss_nest_resize(length, nest); + } } return F_data_not; @@ -135,6 +139,8 @@ extern "C" { #endif // _di_level_0_parameter_checking_ if (step && nests->used + 1 > nests->size) { + if (nests->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + f_number_unsigned_t size = nests->used + step; if (size > F_number_t_size_unsigned_d) { @@ -156,12 +162,16 @@ extern "C" { if (!nests) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; + if (amount) { + if (nests->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - if (nests->used + amount > nests->size) { - if (nests->used + amount > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + const f_number_unsigned_t length = nests->used + amount; - return private_f_fss_nests_resize(nests->used + amount, nests); + if (length > nests->size) { + if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + + return private_f_fss_nests_resize(length, nests); + } } return F_data_not; diff --git a/level_0/f_fss/c/fss/nest.h b/level_0/f_fss/c/fss/nest.h index 497fd8f..42ba73a 100644 --- a/level_0/f_fss/c/fss/nest.h +++ b/level_0/f_fss/c/fss/nest.h @@ -225,13 +225,16 @@ extern "C" { * @param length * The new size to use. * @param nests - * The nests array to resize. + * The nests array to adjust. * * @return - * F_none on success. + * Success from f_memory_array_adjust(). * - * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_array_adjust(). + * + * @see f_memory_array_adjust() */ #ifndef _di_f_fss_nests_adjust_ extern f_status_t f_fss_nests_adjust(const f_number_unsigned_t length, f_fss_nests_t * const nests); @@ -250,10 +253,13 @@ extern "C" { * The nests array to resize. * * @return - * F_none on success. + * Success from f_memory_array_adjust(). * - * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_array_adjust(). + * + * @see f_memory_array_adjust() */ #ifndef _di_f_fss_nests_decimate_by_ extern f_status_t f_fss_nests_decimate_by(const f_number_unsigned_t amount, f_fss_nests_t * const nests); @@ -272,10 +278,13 @@ extern "C" { * The nests array to resize. * * @return - * F_none on success. + * Success from f_memory_array_resize(). * - * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_array_resize(). + * + * @see f_memory_array_resize() */ #ifndef _di_f_fss_nests_decrease_by_ extern f_status_t f_fss_nests_decrease_by(const f_number_unsigned_t amount, f_fss_nests_t * const nests); @@ -294,12 +303,13 @@ extern "C" { * The nests array to resize. * * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + 1 <= size). + * Success from f_memory_array_increase(). * - * F_array_too_large (with error bit) if the new array length is too large. - * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_array_increase(). + * + * @see f_memory_array_increase() */ #ifndef _di_f_fss_nests_increase_ extern f_status_t f_fss_nests_increase(const f_number_unsigned_t step, f_fss_nests_t * const nests); @@ -318,12 +328,13 @@ extern "C" { * The nests array to resize. * * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + amount <= size). + * Success from f_memory_array_increase_by(). * - * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. - * F_array_too_large (with error bit) if the new array length is too large. + * + * Errors (with error bit) from: f_memory_array_increase_by(). + * + * @see f_memory_array_increase_by() */ #ifndef _di_f_fss_nests_increase_by_ extern f_status_t f_fss_nests_increase_by(const f_number_unsigned_t amount, f_fss_nests_t * const nests); @@ -335,13 +346,16 @@ extern "C" { * @param length * The new size to use. * @param nests - * The nests array to adjust. + * The nests array to resize. * * @return - * F_none on success. + * Success from f_memory_array_resize(). * - * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_array_resize(). + * + * @see f_memory_array_resize() */ #ifndef _di_f_fss_nests_resize_ extern f_status_t f_fss_nests_resize(const f_number_unsigned_t length, f_fss_nests_t * const nests); diff --git a/level_0/f_fss/c/fss/private-item.c b/level_0/f_fss/c/fss/private-item.c index 39c8e39..ab78342 100644 --- a/level_0/f_fss/c/fss/private-item.c +++ b/level_0/f_fss/c/fss/private-item.c @@ -16,16 +16,7 @@ extern "C" { if (F_status_is_error(status)) return status; } // for - status = f_memory_adjust(items->size, length, sizeof(f_fss_item_t), (void **) & items->array); - if (F_status_is_error(status)) return status; - - items->size = length; - - if (items->used > items->size) { - items->used = length; - } - - return F_none; + return f_memory_array_adjust(length, sizeof(f_fss_item_t), (void **) &items->array, &items->used, &items->size); } #endif // !defined(_di_f_fss_items_adjust_) || !defined(_di_f_fss_items_decimate_by_) @@ -40,16 +31,7 @@ extern "C" { if (F_status_is_error(status)) return status; } // for - status = f_memory_resize(items->size, length, sizeof(f_fss_item_t), (void **) & items->array); - if (F_status_is_error(status)) return status; - - items->size = length; - - if (items->used > items->size) { - items->used = length; - } - - return F_none; + return f_memory_array_resize(length, sizeof(f_fss_item_t), (void **) &items->array, &items->used, &items->size); } #endif // !defined(_di_f_fss_items_decrease_by_) || !defined(_di_f_fss_items_increase_) || !defined(_di_f_fss_items_increase_by_) || !defined(_di_f_fss_items_resize_) diff --git a/level_0/f_fss/c/fss/private-item.h b/level_0/f_fss/c/fss/private-item.h index 1e6b7cf..2435605 100644 --- a/level_0/f_fss/c/fss/private-item.h +++ b/level_0/f_fss/c/fss/private-item.h @@ -26,16 +26,15 @@ extern "C" { * The items to adjust. * * @return - * F_none on success. + * Success from f_memory_array_adjust(). * - * Errors (with error bit) from: macro_f_fss_item_t_adjust(). - * Errors (with error bit) from: f_memory_adjust(). + * F_parameter (with error bit) if a parameter is invalid. * - * @see macro_f_fss_item_t_adjust() + * Errors (with error bit) from: f_memory_array_adjust(). + * Errors (with error bit) from: f_string_dynamic_adjust(). * - * @see f_fss_items_adjust() - * @see f_fss_items_decimate_by() - * @see f_memory_adjust() + * @see f_memory_array_adjust() + * @see f_string_dynamic_adjust() */ #if !defined(_di_f_fss_items_adjust_) || !defined(_di_f_fss_items_decimate_by_) extern f_status_t private_f_fss_items_adjust(const f_number_unsigned_t length, f_fss_items_t * const items) F_attribute_visibility_internal_d; @@ -52,22 +51,19 @@ extern "C" { * The items to resize. * * @return - * F_none on success. + * Success from f_memory_array_resize(). * - * Errors (with error bit) from: macro_f_fss_item_t_resize(). - * Errors (with error bit) from: f_memory_resize(). + * F_parameter (with error bit) if a parameter is invalid. * - * @see macro_f_fss_item_t_resize() + * Errors (with error bit) from: f_memory_array_resize(). + * Errors (with error bit) from: f_string_dynamic_resize(). * - * @see f_fss_items_decrease_by() - * @see f_fss_items_increase() - * @see f_fss_items_increase_by() - * @see f_fss_items_resize() - * @see f_memory_resize() + * @see f_memory_array_resize() + * @see f_string_dynamic_resize() */ -#if !defined(_di_f_fss_items_decrease_by_) || !defined(_di_f_fss_items_increase_) || !defined(_di_f_fss_items_increase_by_) || !defined(_di_f_fss_items_resize_) +#if !defined(_di_f_fss_items_decrease_by_) || !defined(_di_f_fss_items_resize_) extern f_status_t private_f_fss_items_resize(const f_number_unsigned_t length, f_fss_items_t * const items) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_fss_items_decrease_by_) || !defined(_di_f_fss_items_increase_) || !defined(_di_f_fss_items_increase_by_) || !defined(_di_f_fss_items_resize_) +#endif // !defined(_di_f_fss_items_decrease_by_) || !defined(_di_f_fss_items_resize_) #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_fss/c/fss/private-named.c b/level_0/f_fss/c/fss/private-named.c index 1c3dddb..bfa04a3 100644 --- a/level_0/f_fss/c/fss/private-named.c +++ b/level_0/f_fss/c/fss/private-named.c @@ -21,7 +21,7 @@ extern "C" { } #endif // !defined(_di_f_fss_nameds_adjust_) || !defined(_di_f_fss_nameds_decimate_by_) -#if !defined(_di_f_fss_nameds_decrease_by_) || !defined(_di_f_fss_nameds_increase_) || !defined(_di_f_fss_nameds_increase_by_) || !defined(_di_f_fss_nameds_resize_) +#if !defined(_di_f_fss_nameds_decrease_by_) || !defined(_di_f_fss_nameds_resize_) f_status_t private_f_fss_named_resize(const f_number_unsigned_t length, f_fss_named_t * const named) { f_status_t status = f_string_ranges_resize(length, &named->objects); @@ -35,55 +35,41 @@ extern "C" { return F_none; } -#endif // !defined(_di_f_fss_nameds_decrease_by_) || !defined(_di_f_fss_nameds_increase_) || !defined(_di_f_fss_nameds_increase_by_) || !defined(_di_f_fss_nameds_resize_) +#endif // !defined(_di_f_fss_nameds_decrease_by_) || !defined(_di_f_fss_nameds_resize_) #if !defined(_di_f_fss_nameds_adjust_) || !defined(_di_f_fss_nameds_decimate_by_) f_status_t private_f_fss_nameds_adjust(const f_number_unsigned_t length, f_fss_nameds_t * const nameds) { - f_status_t status = F_none; + { + f_status_t status = F_none; - for (f_number_unsigned_t i = length; i < nameds->size; ++i) { + for (f_number_unsigned_t i = length; i < nameds->size; ++i) { - status = private_f_fss_named_adjust(0, &nameds->array[i]); - if (F_status_is_error(status)) return status; - } // for - - status = f_memory_adjust(nameds->size, length, sizeof(f_fss_named_t), (void **) & nameds->array); - if (F_status_is_error(status)) return status; - - nameds->size = length; - - if (nameds->used > nameds->size) { - nameds->used = length; + status = private_f_fss_named_adjust(0, &nameds->array[i]); + if (F_status_is_error(status)) return status; + } // for } - return F_none; + return f_memory_array_adjust(length, sizeof(f_fss_named_t), (void **) &nameds->array, &nameds->used, &nameds->size); } #endif // !defined(_di_f_fss_nameds_adjust_) || !defined(_di_f_fss_nameds_decimate_by_) -#if !defined(_di_f_fss_nameds_decrease_by_) || !defined(_di_f_fss_nameds_increase_) || !defined(_di_f_fss_nameds_increase_by_) || !defined(_di_f_fss_nameds_resize_) +#if !defined(_di_f_fss_nameds_decrease_by_) || !defined(_di_f_fss_nameds_resize_) f_status_t private_f_fss_nameds_resize(const f_number_unsigned_t length, f_fss_nameds_t * const nameds) { - f_status_t status = F_none; + { + f_status_t status = F_none; - for (f_number_unsigned_t i = length; i < nameds->size; ++i) { + for (f_number_unsigned_t i = length; i < nameds->size; ++i) { - status = private_f_fss_named_resize(0, &nameds->array[i]); - if (F_status_is_error(status)) return status; - } // for - - status = f_memory_resize(nameds->size, length, sizeof(f_fss_named_t), (void **) & nameds->array); - if (F_status_is_error(status)) return status; - - nameds->size = length; - - if (nameds->used > nameds->size) { - nameds->used = length; + status = private_f_fss_named_resize(0, &nameds->array[i]); + if (F_status_is_error(status)) return status; + } // for } - return F_none; + return f_memory_array_resize(length, sizeof(f_fss_named_t), (void **) &nameds->array, &nameds->used, &nameds->size); } -#endif // !defined(_di_f_fss_nameds_decrease_by_) || !defined(_di_f_fss_nameds_increase_) || !defined(_di_f_fss_nameds_increase_by_) || !defined(_di_f_fss_nameds_resize_) +#endif // !defined(_di_f_fss_nameds_decrease_by_) || !defined(_di_f_fss_nameds_resize_) #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_fss/c/fss/private-named.h b/level_0/f_fss/c/fss/private-named.h index aab003f..6d1f48c 100644 --- a/level_0/f_fss/c/fss/private-named.h +++ b/level_0/f_fss/c/fss/private-named.h @@ -56,22 +56,20 @@ extern "C" { * @return * F_none on success. * - * Errors (with error bit) from: macro_f_string_ranges_t_resize(). - * Errors (with error bit) from: macro_f_string_rangess_t_resize(). - * Errors (with error bit) from: macro_f_uint8ss_t_resize(). + * Errors (with error bit) from: f_string_ranges_resize(). + * Errors (with error bit) from: f_string_rangess_resize(). + * Errors (with error bit) from: f_uint8ss_resize(). * - * @see macro_f_string_ranges_t_resize() - * @see macro_f_string_rangess_t_resize() - * @see macro_f_uint8ss_t_resize() + * @see f_string_ranges_resize() + * @see f_string_rangess_resize() + * @see f_uint8ss_resize() * * @see f_fss_nameds_decrease_by() - * @see f_fss_nameds_incease() - * @see f_fss_nameds_incease_by() * @see f_fss_nameds_resize() */ -#if !defined(_di_f_fss_nameds_decrease_by_) || !defined(_di_f_fss_nameds_increase_) || !defined(_di_f_fss_nameds_increase_by_) || !defined(_di_f_fss_nameds_resize_) +#if !defined(_di_f_fss_nameds_decrease_by_) || !defined(_di_f_fss_nameds_resize_) extern f_status_t private_f_fss_named_resize(const f_number_unsigned_t length, f_fss_named_t * const named) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_fss_nameds_decrease_by_) || !defined(_di_f_fss_nameds_increase_) || !defined(_di_f_fss_nameds_increase_by_) || !defined(_di_f_fss_nameds_resize_) +#endif // !defined(_di_f_fss_nameds_decrease_by_) || !defined(_di_f_fss_nameds_resize_) /** * Private implementation for resizing. @@ -84,16 +82,22 @@ extern "C" { * The nameds to adjust. * * @return - * F_none on success. + * Success from f_memory_array_adjust(). + * + * F_parameter (with error bit) if a parameter is invalid. * - * Errors (with error bit) from: f_memory_adjust(). - * Errors (with error bit) from: private_f_fss_named_adjust(). + * Errors (with error bit) from: f_memory_array_adjust(). + * Errors (with error bit) from: f_string_ranges_resize(). + * Errors (with error bit) from: f_string_rangess_resize(). + * Errors (with error bit) from: f_uint8ss_resize(). * - * @see private_f_fss_named_adjust() + * @see f_string_ranges_resize() + * @see f_string_rangess_resize() + * @see f_uint8ss_resize() + * @see f_memory_array_adjust() * * @see f_fss_nameds_adjust() * @see f_fss_nameds_decimate_by() - * @see f_memory_adjust() */ #if !defined(_di_f_fss_nameds_adjust_) || !defined(_di_f_fss_nameds_decimate_by_) extern f_status_t private_f_fss_nameds_adjust(const f_number_unsigned_t length, f_fss_nameds_t * const nameds) F_attribute_visibility_internal_d; @@ -110,22 +114,26 @@ extern "C" { * The nameds to resize. * * @return - * F_none on success. + * Success from f_memory_array_resize(). + * + * F_parameter (with error bit) if a parameter is invalid. * - * Errors (with error bit) from: f_memory_resize(). - * Errors (with error bit) from: private_f_fss_named_resize(). + * Errors (with error bit) from: f_memory_array_resize(). + * Errors (with error bit) from: f_string_ranges_resize(). + * Errors (with error bit) from: f_string_rangess_resize(). + * Errors (with error bit) from: f_uint8ss_resize(). * - * @see private_f_fss_named_resize() + * @see f_memory_array_resize() + * @see f_string_ranges_resize() + * @see f_string_rangess_resize() + * @see f_uint8ss_resize() * * @see f_fss_nameds_decrease_by() - * @see f_fss_nameds_increase() - * @see f_fss_nameds_increase_by() * @see f_fss_nameds_resize() - * @see f_memory_resize() */ -#if !defined(_di_f_fss_nameds_decrease_by_) || !defined(_di_f_fss_nameds_increase_) || !defined(_di_f_fss_nameds_increase_by_) || !defined(_di_f_fss_nameds_resize_) +#if !defined(_di_f_fss_nameds_decrease_by_) || !defined(_di_f_fss_nameds_resize_) extern f_status_t private_f_fss_nameds_resize(const f_number_unsigned_t length, f_fss_nameds_t * const nameds) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_fss_nameds_decrease_by_) || !defined(_di_f_fss_nameds_increase_) || !defined(_di_f_fss_nameds_increase_by_) || !defined(_di_f_fss_nameds_resize_) +#endif // !defined(_di_f_fss_nameds_decrease_by_) || !defined(_di_f_fss_nameds_resize_) #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_fss/c/fss/private-nest.c b/level_0/f_fss/c/fss/private-nest.c index ce719a1..bf50fc9 100644 --- a/level_0/f_fss/c/fss/private-nest.c +++ b/level_0/f_fss/c/fss/private-nest.c @@ -9,98 +9,70 @@ extern "C" { #if !defined(_di_f_fss_nest_adjust_) || !defined(_di_f_fss_nest_decimate_by_) f_status_t private_f_fss_nest_adjust(const f_number_unsigned_t length, f_fss_nest_t * const nest) { - f_status_t status = F_none; + { + f_status_t status = F_none; - for (f_number_unsigned_t i = length; i < nest->size; ++i) { + for (f_number_unsigned_t i = length; i < nest->size; ++i) { - status = private_f_fss_items_adjust(0, &nest->depth[i]); - if (F_status_is_error(status)) return status; - } // for - - status = f_memory_adjust(nest->size, length, sizeof(f_fss_items_t), (void **) & nest->depth); - if (F_status_is_error(status)) return status; - - nest->size = length; - - if (nest->used > nest->size) { - nest->used = length; + status = private_f_fss_items_adjust(0, &nest->depth[i]); + if (F_status_is_error(status)) return status; + } // for } - return F_none; + return f_memory_array_adjust(length, sizeof(f_fss_items_t), (void **) &nest->depth, &nest->used, &nest->size); } #endif // !defined(_di_f_fss_nest_adjust_) || !defined(_di_f_fss_nest_decimate_by_) -#if !defined(_di_f_fss_nest_decrease_by_) || !defined(_di_f_fss_nest_increase_) || !defined(_di_f_fss_nest_increase_by_) || !defined(_di_f_fss_nest_resize_) +#if !defined(_di_f_fss_nest_decrease_by_) || !defined(_di_f_fss_nest_resize_) f_status_t private_f_fss_nest_resize(const f_number_unsigned_t length, f_fss_nest_t * const nest) { - f_status_t status = F_none; - - for (f_number_unsigned_t i = length; i < nest->size; ++i) { - - status = private_f_fss_items_resize(0, &nest->depth[i]); - if (F_status_is_error(status)) return status; - } // for - - status = f_memory_resize(nest->size, length, sizeof(f_fss_items_t), (void **) & nest->depth); - if (F_status_is_error(status)) return status; + { + f_status_t status = F_none; - nest->size = length; + for (f_number_unsigned_t i = length; i < nest->size; ++i) { - if (nest->used > nest->size) { - nest->used = length; + status = private_f_fss_items_resize(0, &nest->depth[i]); + if (F_status_is_error(status)) return status; + } // for } - return F_none; + return f_memory_array_resize(length, sizeof(f_fss_items_t), (void **) &nest->depth, &nest->used, &nest->size); } -#endif // !defined(_di_f_fss_nest_decrease_by_) || !defined(_di_f_fss_nest_increase_) || !defined(_di_f_fss_nest_increase_by_) || !defined(_di_f_fss_nest_resize_) +#endif // !defined(_di_f_fss_nest_decrease_by_) || !defined(_di_f_fss_nest_resize_) #if !defined(_di_f_fss_nests_adjust_) || !defined(_di_f_fss_nests_decimate_by_) f_status_t private_f_fss_nests_adjust(const f_number_unsigned_t length, f_fss_nests_t *nests) { - f_status_t status = F_none; + { + f_status_t status = F_none; - for (f_number_unsigned_t i = length; i < nests->size; ++i) { + for (f_number_unsigned_t i = length; i < nests->size; ++i) { - status = private_f_fss_nest_adjust(0, &nests->array[i]); - if (F_status_is_error(status)) return status; - } // for - - status = f_memory_adjust(nests->size, length, sizeof(f_fss_nest_t), (void **) & nests->array); - if (F_status_is_error(status)) return status; - - nests->size = length; - - if (nests->used > nests->size) { - nests->used = length; + status = private_f_fss_nest_adjust(0, &nests->array[i]); + if (F_status_is_error(status)) return status; + } // for } - return F_none; + return f_memory_array_adjust(length, sizeof(f_fss_nest_t), (void **) &nests->array, &nests->used, &nests->size); } #endif // !defined(_di_f_fss_nests_adjust_) || !defined(_di_f_fss_nests_decimate_by_) -#if !defined(_di_f_fss_nests_decrease_by_) || !defined(_di_f_fss_nests_increase_) || !defined(_di_f_fss_nests_increase_by_) || !defined(_di_f_fss_nests_resize_) +#if !defined(_di_f_fss_nests_decrease_by_) || !defined(_di_f_fss_nests_resize_) f_status_t private_f_fss_nests_resize(const f_number_unsigned_t length, f_fss_nests_t * const nests) { - f_status_t status = F_none; - - for (f_number_unsigned_t i = length; i < nests->size; ++i) { - - status = private_f_fss_nest_resize(0, &nests->array[i]); - if (F_status_is_error(status)) return status; - } // for - - status = f_memory_resize(nests->size, length, sizeof(f_fss_nest_t), (void **) & nests->array); - if (F_status_is_error(status)) return status; + { + f_status_t status = F_none; - nests->size = length; + for (f_number_unsigned_t i = length; i < nests->size; ++i) { - if (nests->used > nests->size) { - nests->used = length; + status = private_f_fss_nest_resize(0, &nests->array[i]); + if (F_status_is_error(status)) return status; + } // for } - return F_none; + return f_memory_array_resize(length, sizeof(f_fss_nest_t), (void **) &nests->array, &nests->used, &nests->size); } -#endif // !defined(_di_f_fss_nests_decrease_by_) || !defined(_di_f_fss_nests_increase_) || !defined(_di_f_fss_nests_increase_by_) || !defined(_di_f_fss_nests_resize_) +#endif // !defined(_di_f_fss_nests_decrease_by_) || !defined(_di_f_fss_nests_resize_) #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_fss/c/fss/private-nest.h b/level_0/f_fss/c/fss/private-nest.h index c38577e..78cd408 100644 --- a/level_0/f_fss/c/fss/private-nest.h +++ b/level_0/f_fss/c/fss/private-nest.h @@ -26,16 +26,18 @@ extern "C" { * The nest to adjust. * * @return - * F_none on success. + * Success from f_memory_array_adjust(). * - * Errors (with error bit) from: f_memory_adjust(). - * Errors (with error bit) from: macro_f_fss_nest_t_adjust(). + * F_parameter (with error bit) if a parameter is invalid. * - * @see macro_f_fss_nest_t_adjust() + * Errors (with error bit) from: f_memory_array_adjust(). + * Errors (with error bit) from: f_string_dynamic_adjust(). * - * @see f_fss_nest_adjust() - * @see f_fss_nest_decimate_by() - * @see f_memory_adjust() + * @see f_memory_array_adjust() + * @see f_string_dynamic_adjust() + * + * @see f_fss_nests_adjust() + * @see f_fss_nests_decimate_by() */ #if !defined(_di_f_fss_nest_adjust_) || !defined(_di_f_fss_nest_decimate_by_) extern f_status_t private_f_fss_nest_adjust(const f_number_unsigned_t length, f_fss_nest_t * const nest) F_attribute_visibility_internal_d; @@ -52,22 +54,22 @@ extern "C" { * The nest to resize. * * @return - * F_none on success. + * Success from f_memory_array_resize(). + * + * F_parameter (with error bit) if a parameter is invalid. * - * Errors (with error bit) from: f_memory_resize(). - * Errors (with error bit) from: macro_f_fss_nest_t_resize(). + * Errors (with error bit) from: f_memory_array_resize(). + * Errors (with error bit) from: f_string_dynamic_resize(). * - * @see macro_f_fss_nest_t_resize() + * @see f_memory_array_resize() + * @see f_string_dynamic_resize() * - * @see f_fss_nest_decrease_by() - * @see f_fss_nest_increase() - * @see f_fss_nest_increase_by() - * @see f_fss_nest_resize() - * @see f_memory_resize() + * @see f_fss_nests_decrease_by() + * @see f_fss_nests_resize() */ -#if !defined(_di_f_fss_nest_decrease_by_) || !defined(_di_f_fss_nest_increase_) || !defined(_di_f_fss_nest_increase_by_) || !defined(_di_f_fss_nest_resize_) +#if !defined(_di_f_fss_nest_decrease_by_) || !defined(_di_f_fss_nest_resize_) extern f_status_t private_f_fss_nest_resize(const f_number_unsigned_t length, f_fss_nest_t * const nest) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_fss_nest_decrease_by_) || !defined(_di_f_fss_nest_increase_) || !defined(_di_f_fss_nest_increase_by_) || !defined(_di_f_fss_nest_resize_) +#endif // !defined(_di_f_fss_nest_decrease_by_) || !defined(_di_f_fss_nest_resize_) /** * Private implementation for resizing. @@ -80,16 +82,18 @@ extern "C" { * The nests to adjust. * * @return - * F_none on success. + * Success from f_memory_array_adjust(). * - * Errors (with error bit) from: f_memory_adjust(). - * Errors (with error bit) from: macro_f_fss_nest_t_adjust(). + * F_parameter (with error bit) if a parameter is invalid. * - * @see macro_f_fss_nest_t_adjust() + * Errors (with error bit) from: f_memory_array_adjust(). + * Errors (with error bit) from: f_string_dynamic_adjust(). + * + * @see f_memory_array_adjust() + * @see f_string_dynamic_adjust() * * @see f_fss_nests_adjust() * @see f_fss_nests_decimate_by() - * @see f_memory_adjust() */ #if !defined(_di_f_fss_nests_adjust_) || !defined(_di_f_fss_nests_decimate_by_) extern f_status_t private_f_fss_nests_adjust(const f_number_unsigned_t length, f_fss_nests_t * const nests) F_attribute_visibility_internal_d; @@ -106,22 +110,22 @@ extern "C" { * The nests to resize. * * @return - * F_none on success. + * Success from f_memory_array_resize(). + * + * F_parameter (with error bit) if a parameter is invalid. * - * Errors (with error bit) from: f_memory_resize(). - * Errors (with error bit) from: macro_f_fss_nest_t_resize(). + * Errors (with error bit) from: f_memory_array_resize(). + * Errors (with error bit) from: f_string_dynamic_resize(). * - * @see macro_f_fss_nest_t_resize() + * @see f_memory_array_resize() + * @see f_string_dynamic_resize() * * @see f_fss_nests_decrease_by() - * @see f_fss_nests_increase() - * @see f_fss_nests_increase_by() * @see f_fss_nests_resize() - * @see f_memory_resize() */ -#if !defined(_di_f_fss_nests_decrease_by_) || !defined(_di_f_fss_nests_increase_) || !defined(_di_f_fss_nests_increase_by_) || !defined(_di_f_fss_nests_resize_) +#if !defined(_di_f_fss_nests_decrease_by_) || !defined(_di_f_fss_nests_resize_) extern f_status_t private_f_fss_nests_resize(const f_number_unsigned_t length, f_fss_nests_t * const nests) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_fss_nests_decrease_by_) || !defined(_di_f_fss_nests_increase_) || !defined(_di_f_fss_nests_increase_by_) || !defined(_di_f_fss_nests_resize_) +#endif // !defined(_di_f_fss_nests_decrease_by_) || !defined(_di_f_fss_nests_resize_) #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_fss/c/fss/private-set.c b/level_0/f_fss/c/fss/private-set.c index e0472e1..067a2ae 100644 --- a/level_0/f_fss/c/fss/private-set.c +++ b/level_0/f_fss/c/fss/private-set.c @@ -18,7 +18,7 @@ extern "C" { } #endif // !defined(_di_f_fss_set_adjust_) || !defined(_di_f_fss_set_decimate_by_) -#if !defined(_di_f_fss_set_decrease_by_) || !defined(_di_f_fss_set_increase_) || !defined(_di_f_fss_set_increase_by_) || !defined(_di_f_fss_set_resize_) +#if !defined(_di_f_fss_set_decrease_by_) || !defined(_di_f_fss_set_resize_) f_status_t private_f_fss_set_resize(const f_number_unsigned_t length, f_fss_set_t *set) { f_status_t status = f_string_ranges_resize(length, &set->objects); @@ -29,61 +29,47 @@ extern "C" { return F_none; } -#endif // !defined(_di_f_fss_set_decrease_by_) || !defined(_di_f_fss_set_increase_) || !defined(_di_f_fss_set_increase_by_) || !defined(_di_f_fss_set_resize_) +#endif // !defined(_di_f_fss_set_decrease_by_) || !defined(_di_f_fss_set_resize_) #if !defined(_di_f_fss_sets_adjust_) || !defined(_di_f_fss_sets_decimate_by_) f_status_t private_f_fss_sets_adjust(const f_number_unsigned_t length, f_fss_sets_t * const sets) { - f_status_t status = F_none; + { + f_status_t status = F_none; - for (f_number_unsigned_t i = length; i < sets->size; ++i) { + for (f_number_unsigned_t i = length; i < sets->size; ++i) { - status = f_string_ranges_adjust(0, &sets->array[i].objects); - if (F_status_is_error(status)) return status; + status = f_string_ranges_adjust(0, &sets->array[i].objects); + if (F_status_is_error(status)) return status; - status = f_string_rangess_adjust(0, &sets->array[i].contents); - if (F_status_is_error(status)) return status; - } // for - - status = f_memory_adjust(sets->size, length, sizeof(f_fss_set_t), (void **) & sets->array); - if (F_status_is_error(status)) return status; - - sets->size = length; - - if (sets->used > sets->size) { - sets->used = length; + status = f_string_rangess_adjust(0, &sets->array[i].contents); + if (F_status_is_error(status)) return status; + } // for } - return F_none; + return f_memory_array_adjust(length, sizeof(f_fss_set_t), (void **) &sets->array, &sets->used, &sets->size); } #endif // !defined(_di_f_fss_sets_adjust_) || !defined(_di_f_fss_sets_decimate_by_) -#if !defined(_di_f_fss_sets_decrease_by_) || !defined(_di_f_fss_sets_increase_) || !defined(_di_f_fss_sets_increase_by_) || !defined(_di_f_fss_sets_resize_) +#if !defined(_di_f_fss_sets_decrease_by_) || !defined(_di_f_fss_sets_resize_) f_status_t private_f_fss_sets_resize(const f_number_unsigned_t length, f_fss_sets_t * const sets) { - f_status_t status = F_none; + { + f_status_t status = F_none; - for (f_number_unsigned_t i = length; i < sets->size; ++i) { + for (f_number_unsigned_t i = length; i < sets->size; ++i) { - status = f_string_ranges_resize(0, &sets->array[i].objects); - if (F_status_is_error(status)) return status; + status = f_string_ranges_resize(0, &sets->array[i].objects); + if (F_status_is_error(status)) return status; - status = f_string_rangess_resize(0, &sets->array[i].contents); - if (F_status_is_error(status)) return status; - } // for - - status = f_memory_resize(sets->size, length, sizeof(f_fss_set_t), (void **) & sets->array); - if (F_status_is_error(status)) return status; - - sets->size = length; - - if (sets->used > sets->size) { - sets->used = length; + status = f_string_rangess_resize(0, &sets->array[i].contents); + if (F_status_is_error(status)) return status; + } // for } - return F_none; + return f_memory_array_resize(length, sizeof(f_fss_set_t), (void **) &sets->array, &sets->used, &sets->size); } -#endif // !defined(_di_f_fss_sets_decrease_by_) || !defined(_di_f_fss_sets_increase_) || !defined(_di_f_fss_sets_increase_by_) || !defined(_di_f_fss_sets_resize_) +#endif // !defined(_di_f_fss_sets_decrease_by_) || !defined(_di_f_fss_sets_resize_) #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_fss/c/fss/private-set.h b/level_0/f_fss/c/fss/private-set.h index 6c67ed3..82b3781 100644 --- a/level_0/f_fss/c/fss/private-set.h +++ b/level_0/f_fss/c/fss/private-set.h @@ -28,11 +28,11 @@ extern "C" { * @return * F_none on success. * - * Errors (with error bit) from: macro_f_string_rangess_t_adjust(). - * Errors (with error bit) from: macro_f_string_ranges_t_adjust(). + * Errors (with error bit) from: f_string_ranges_adjust(). + * Errors (with error bit) from: f_string_rangess_adjust(). * - * @see macro_f_string_rangess_t_adjust() - * @see macro_f_string_ranges_t_adjust() + * @see f_string_ranges_adjust() + * @see f_string_rangess_adjust() * * @see f_fss_set_adjust() * @see f_fss_set_decimate_by() @@ -54,20 +54,18 @@ extern "C" { * @return * F_none on success. * - * Errors (with error bit) from: macro_f_string_rangess_t_resize(). - * Errors (with error bit) from: macro_f_string_ranges_t_resize(). + * Errors (with error bit) from: f_string_ranges_resize(). + * Errors (with error bit) from: f_string_rangess_resize(). * - * @see macro_f_string_rangess_t_resize() - * @see macro_f_string_ranges_t_resize() + * @see f_string_ranges_resize + * @see f_string_rangess_resize()() * * @see f_fss_set_decrease_by() - * @see f_fss_set_increase() - * @see f_fss_set_increase_by() * @see f_fss_set_resize() */ -#if !defined(_di_f_fss_set_decrease_by_) || !defined(_di_f_fss_set_increase_) || !defined(_di_f_fss_set_increase_by_) || !defined(_di_f_fss_set_resize_) +#if !defined(_di_f_fss_set_decrease_by_) || !defined(_di_f_fss_set_resize_) extern f_status_t private_f_fss_set_resize(const f_number_unsigned_t length, f_fss_set_t * const set) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_fss_set_decrease_by_) || !defined(_di_f_fss_set_increase_) || !defined(_di_f_fss_set_increase_by_) || !defined(_di_f_fss_set_resize_) +#endif // !defined(_di_f_fss_set_decrease_by_) || !defined(_di_f_fss_set_resize_) /** * Private implementation for resizing. @@ -80,18 +78,20 @@ extern "C" { * The sets to adjust. * * @return - * F_none on success. + * Success from f_memory_array_adjust(). + * + * F_parameter (with error bit) if a parameter is invalid. * - * Errors (with error bit) from: macro_f_string_rangess_t_adjust(). - * Errors (with error bit) from: macro_f_string_ranges_t_adjust(). - * Errors (with error bit) from: f_memory_adjust(). + * Errors (with error bit) from: f_memory_array_adjust(). + * Errors (with error bit) from: f_string_ranges_adjust(). + * Errors (with error bit) from: f_string_rangess_adjust(). * - * @see macro_f_string_rangess_t_adjust() - * @see macro_f_string_ranges_t_adjust() + * @see f_memory_array_adjust() + * @see f_string_ranges_adjust() + * @see f_string_rangess_adjust() * * @see f_fss_sets_adjust() * @see f_fss_sets_decimate_by() - * @see f_memory_adjust() */ #if !defined(_di_f_fss_sets_adjust_) || !defined(_di_f_fss_sets_decimate_by_) extern f_status_t private_f_fss_sets_adjust(const f_number_unsigned_t length, f_fss_sets_t * const sets) F_attribute_visibility_internal_d; @@ -108,24 +108,24 @@ extern "C" { * The sets to resize. * * @return - * F_none on success. + * Success from f_memory_array_resize(). + * + * F_parameter (with error bit) if a parameter is invalid. * - * Errors (with error bit) from: macro_f_string_rangess_t_resize(). - * Errors (with error bit) from: macro_f_string_ranges_t_resize(). - * Errors (with error bit) from: f_memory_resize(). + * Errors (with error bit) from: f_memory_array_resize(). + * Errors (with error bit) from: f_string_ranges_resize(). + * Errors (with error bit) from: f_string_rangess_resize(). * - * @see macro_f_string_rangess_t_resize() - * @see macro_f_string_ranges_t_resize() + * @see f_memory_array_resize() + * @see f_string_ranges_resize() + * @see f_string_rangess_resize() * * @see f_fss_sets_decrease_by() - * @see f_fss_sets_increase() - * @see f_fss_sets_increase_by() * @see f_fss_sets_resize() - * @see f_memory_resize() */ -#if !defined(_di_f_fss_sets_decrease_by_) || !defined(_di_f_fss_sets_increase_) || !defined(_di_f_fss_sets_increase_by_) || !defined(_di_f_fss_sets_resize_) +#if !defined(_di_f_fss_sets_decrease_by_) || !defined(_di_f_fss_sets_resize_) extern f_status_t private_f_fss_sets_resize(const f_number_unsigned_t length, f_fss_sets_t * const sets) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_fss_sets_decrease_by_) || !defined(_di_f_fss_sets_increase_) || !defined(_di_f_fss_sets_increase_by_) || !defined(_di_f_fss_sets_resize_) +#endif // !defined(_di_f_fss_sets_decrease_by_) || !defined(_di_f_fss_sets_resize_) #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_fss/c/fss/private-set_quote.c b/level_0/f_fss/c/fss/private-set_quote.c index ee93a96..3324f43 100644 --- a/level_0/f_fss/c/fss/private-set_quote.c +++ b/level_0/f_fss/c/fss/private-set_quote.c @@ -24,7 +24,7 @@ extern "C" { } #endif // !defined(_di_f_fss_set_quote_adjust_) || !defined(_di_f_fss_set_quote_decimate_by_) -#if !defined(_di_f_fss_set_quote_decrease_by_) || !defined(_di_f_fss_set_quote_increase_) || !defined(_di_f_fss_set_quote_increase_by_) || !defined(_di_f_fss_set_quote_resize_) +#if !defined(_di_f_fss_set_quote_decrease_by_) || !defined(_di_f_fss_set_quote_resize_) f_status_t private_f_fss_set_quote_resize(const f_number_unsigned_t length, f_fss_set_quote_t * const set_quote) { f_status_t status = f_string_ranges_resize(length, &set_quote->objects); @@ -41,73 +41,59 @@ extern "C" { return F_none; } -#endif // !defined(_di_f_fss_set_quote_decrease_by_) || !defined(_di_f_fss_set_quote_increase_) || !defined(_di_f_fss_set_quote_increase_by_) || !defined(_di_f_fss_set_quote_resize_) +#endif // !defined(_di_f_fss_set_quote_decrease_by_) || !defined(_di_f_fss_set_quote_resize_) #if !defined(_di_f_fss_set_quotes_adjust_) || !defined(_di_f_fss_set_quotes_decimate_by_) f_status_t private_f_fss_set_quotes_adjust(const f_number_unsigned_t length, f_fss_set_quotes_t * const set_quotes) { - f_status_t status = F_none; + { + f_status_t status = F_none; - for (f_number_unsigned_t i = length; i < set_quotes->size; ++i) { + for (f_number_unsigned_t i = length; i < set_quotes->size; ++i) { - status = f_string_ranges_adjust(0, &set_quotes->array[i].objects); - if (F_status_is_error(status)) return status; + status = f_string_ranges_adjust(0, &set_quotes->array[i].objects); + if (F_status_is_error(status)) return status; - status = f_string_rangess_adjust(0, &set_quotes->array[i].contents); - if (F_status_is_error(status)) return status; + status = f_string_rangess_adjust(0, &set_quotes->array[i].contents); + if (F_status_is_error(status)) return status; - status = f_uint8s_adjust(0, &set_quotes->array[i].objects_quote); - if (F_status_is_error(status)) return status; + status = f_uint8s_adjust(0, &set_quotes->array[i].objects_quote); + if (F_status_is_error(status)) return status; - status = f_uint8ss_adjust(0, &set_quotes->array[i].contents_quote); - if (F_status_is_error(status)) return status; - } // for - - status = f_memory_adjust(set_quotes->size, length, sizeof(f_fss_set_quote_t), (void **) & set_quotes->array); - if (F_status_is_error(status)) return status; - - set_quotes->size = length; - - if (set_quotes->used > set_quotes->size) { - set_quotes->used = length; + status = f_uint8ss_adjust(0, &set_quotes->array[i].contents_quote); + if (F_status_is_error(status)) return status; + } // for } - return F_none; + return f_memory_array_adjust(length, sizeof(f_fss_set_quote_t), (void **) &set_quotes->array, &set_quotes->used, &set_quotes->size); } #endif // !defined(_di_f_fss_set_quotes_adjust_) || !defined(_di_f_fss_set_quotes_decimate_by_) -#if !defined(_di_f_fss_set_quotes_decrease_by_) || !defined(_di_f_fss_set_quotes_increase_) || !defined(_di_f_fss_set_quotes_increase_by_) || !defined(_di_f_fss_set_quotes_resize_) +#if !defined(_di_f_fss_set_quotes_decrease_by_) || !defined(_di_f_fss_set_quotes_resize_) f_status_t private_f_fss_set_quotes_resize(const f_number_unsigned_t length, f_fss_set_quotes_t * const set_quotes) { - f_status_t status = F_none; + { + f_status_t status = F_none; - for (f_number_unsigned_t i = length; i < set_quotes->size; ++i) { + for (f_number_unsigned_t i = length; i < set_quotes->size; ++i) { - status = f_string_ranges_resize(0, &set_quotes->array[i].objects); - if (F_status_is_error(status)) return status; + status = f_string_ranges_resize(0, &set_quotes->array[i].objects); + if (F_status_is_error(status)) return status; - status = f_string_rangess_resize(0, &set_quotes->array[i].contents); - if (F_status_is_error(status)) return status; + status = f_string_rangess_resize(0, &set_quotes->array[i].contents); + if (F_status_is_error(status)) return status; - status = f_uint8s_resize(0, &set_quotes->array[i].objects_quote); - if (F_status_is_error(status)) return status; + status = f_uint8s_resize(0, &set_quotes->array[i].objects_quote); + if (F_status_is_error(status)) return status; - status = f_uint8ss_resize(0, &set_quotes->array[i].contents_quote); - if (F_status_is_error(status)) return status; - } // for - - status = f_memory_resize(set_quotes->size, length, sizeof(f_fss_set_quote_t), (void **) & set_quotes->array); - if (F_status_is_error(status)) return status; - - set_quotes->size = length; - - if (set_quotes->used > set_quotes->size) { - set_quotes->used = length; + status = f_uint8ss_resize(0, &set_quotes->array[i].contents_quote); + if (F_status_is_error(status)) return status; + } // for } - return F_none; + return f_memory_array_resize(length, sizeof(f_fss_set_quote_t), (void **) &set_quotes->array, &set_quotes->used, &set_quotes->size); } -#endif // !defined(_di_f_fss_set_quotes_decrease_by_) || !defined(_di_f_fss_set_quotes_increase_) || !defined(_di_f_fss_set_quotes_increase_by_) || !defined(_di_f_fss_set_quotes_resize_) +#endif // !defined(_di_f_fss_set_quotes_decrease_by_) || !defined(_di_f_fss_set_quotes_resize_) #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_fss/c/fss/private-set_quote.h b/level_0/f_fss/c/fss/private-set_quote.h index 2e285ec..dd69307 100644 --- a/level_0/f_fss/c/fss/private-set_quote.h +++ b/level_0/f_fss/c/fss/private-set_quote.h @@ -28,15 +28,15 @@ extern "C" { * @return * F_none on success. * - * Errors (with error bit) from: macro_f_string_rangess_t_adjust(). - * Errors (with error bit) from: macro_f_string_ranges_t_adjust(). - * Errors (with error bit) from: macro_f_uint8s_t_adjust(). - * Errors (with error bit) from: macro_f_uint8ss_t_adjust(). + * Errors (with error bit) from: f_string_ranges_adjust(). + * Errors (with error bit) from: f_string_rangess_adjust(). + * Errors (with error bit) from: f_uint8s_adjust(). + * Errors (with error bit) from: f_uint8ss_adjust(). * - * @see macro_f_string_rangess_t_adjust() - * @see macro_f_string_ranges_t_adjust() - * @see macro_f_uint8s_t_adjust() - * @see macro_f_uint8ss_t_adjust() + * @see f_string_ranges_adjust() + * @see f_string_rangess_adjust() + * @see f_uint8s_adjust() + * @see f_uint8ss_adjust() * * @see f_fss_set_quote_adjust() * @see f_fss_set_quote_decimate_by() @@ -58,24 +58,22 @@ extern "C" { * @return * F_none on success. * - * Errors (with error bit) from: macro_f_string_rangess_t_resize(). - * Errors (with error bit) from: macro_f_string_ranges_t_resize(). - * Errors (with error bit) from: macro_f_uint8s_t_resize(). - * Errors (with error bit) from: macro_f_uint8ss_t_resize(). + * Errors (with error bit) from: f_string_ranges_resize(). + * Errors (with error bit) from: f_string_rangess_resize(). + * Errors (with error bit) from: f_uint8s_resize(). + * Errors (with error bit) from: f_uint8ss_resize(). * - * @see macro_f_string_rangess_t_resize() - * @see macro_f_string_ranges_t_resize() - * @see macro_f_uint8s_t_resize() - * @see macro_f_uint8ss_t_resize() + * @see f_string_ranges_resize() + * @see f_string_rangess_resize() + * @see f_uint8s_resize() + * @see f_uint8ss_resize() * * @see f_fss_set_quote_decrease_by() - * @see f_fss_set_quote_increase() - * @see f_fss_set_quote_increase_by() * @see f_fss_set_quote_resize() */ -#if !defined(_di_f_fss_set_quote_decrease_by_) || !defined(_di_f_fss_set_quote_increase_) || !defined(_di_f_fss_set_quote_increase_by_) || !defined(_di_f_fss_set_quote_resize_) +#if !defined(_di_f_fss_set_quote_decrease_by_) || !defined(_di_f_fss_set_quote_resize_) extern f_status_t private_f_fss_set_quote_resize(const f_number_unsigned_t length, f_fss_set_quote_t * const set_quote) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_fss_set_quote_decrease_by_) || !defined(_di_f_fss_set_quote_increase_) || !defined(_di_f_fss_set_quote_increase_by_) || !defined(_di_f_fss_set_quote_resize_) +#endif // !defined(_di_f_fss_set_quote_decrease_by_) || !defined(_di_f_fss_set_quote_resize_) /** * Private implementation for resizing. @@ -88,21 +86,24 @@ extern "C" { * The set_quotes to adjust. * * @return - * F_none on success. + * Success from f_memory_array_adjust(). + * + * F_parameter (with error bit) if a parameter is invalid. * - * Errors (with error bit) from: macro_f_string_rangess_t_adjust(). - * Errors (with error bit) from: macro_f_string_ranges_t_adjust(). - * Errors (with error bit) from: macro_f_uint8s_t_adjust(). - * Errors (with error bit) from: macro_f_uint8ss_t_adjust(). - * Errors (with error bit) from: f_memory_adjust(). + * Errors (with error bit) from: f_memory_array_adjust(). + * Errors (with error bit) from: f_string_ranges_adjust(). + * Errors (with error bit) from: f_string_rangess_adjust(). + * Errors (with error bit) from: f_uint8s_adjust(). + * Errors (with error bit) from: f_uint8ss_adjust(). * - * @see macro_f_string_rangess_t_adjust() - * @see macro_f_string_ranges_t_adjust() - * @see macro_f_uint8s_t_adjust() - * @see macro_f_uint8ss_t_adjust() + * @see f_memory_array_adjust() + * @see f_string_ranges_adjust() + * @see f_string_rangess_adjust() + * @see f_uint8s_adjust() + * @see f_uint8ss_adjust() * + * @see f_fss_set_quotes_decrease_by() * @see f_fss_set_quotes_adjust() - * @see f_fss_set_quotes_decimate_by() * @see f_memory_adjust() */ #if !defined(_di_f_fss_set_quotes_adjust_) || !defined(_di_f_fss_set_quotes_decimate_by_) @@ -120,28 +121,29 @@ extern "C" { * The set_quotes to resize. * * @return - * F_none on success. + * Success from f_memory_array_resize(). + * + * F_parameter (with error bit) if a parameter is invalid. * - * Errors (with error bit) from: macro_f_string_rangess_t_resize(). - * Errors (with error bit) from: macro_f_string_ranges_t_resize(). - * Errors (with error bit) from: macro_f_uint8s_t_resize(). - * Errors (with error bit) from: macro_f_uint8ss_t_resize(). - * Errors (with error bit) from: f_memory_resize(). + * Errors (with error bit) from: f_memory_array_resize(). + * Errors (with error bit) from: f_string_ranges_adjust(). + * Errors (with error bit) from: f_string_rangess_adjust(). + * Errors (with error bit) from: f_uint8s_adjust(). + * Errors (with error bit) from: f_uint8ss_adjust(). * - * @see macro_f_string_rangess_t_resize() - * @see macro_f_string_ranges_t_resize() - * @see macro_f_uint8s_t_resize() - * @see macro_f_uint8ss_t_resize() + * @see f_memory_array_resize() + * @see f_string_ranges_adjust() + * @see f_string_rangess_adjust() + * @see f_uint8s_adjust() + * @see f_uint8ss_adjust() * * @see f_fss_set_quotes_decrease_by() - * @see f_fss_set_quotes_increase() - * @see f_fss_set_quotes_increase_by() * @see f_fss_set_quotes_resize() * @see f_memory_resize() */ -#if !defined(_di_f_fss_set_quotes_decrease_by_) || !defined(_di_f_fss_set_quotes_increase_) || !defined(_di_f_fss_set_quotes_increase_by_) || !defined(_di_f_fss_set_quotes_resize_) +#if !defined(_di_f_fss_set_quotes_decrease_by_) || !defined(_di_f_fss_set_quotes_resize_) extern f_status_t private_f_fss_set_quotes_resize(const f_number_unsigned_t length, f_fss_set_quotes_t * const set_quotes) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_fss_set_quotes_decrease_by_) || !defined(_di_f_fss_set_quotes_increase_) || !defined(_di_f_fss_set_quotes_increase_by_) || !defined(_di_f_fss_set_quotes_resize_) +#endif // !defined(_di_f_fss_set_quotes_decrease_by_) || !defined(_di_f_fss_set_quotes_resize_) #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_fss/c/fss/private-simple_packet.c b/level_0/f_fss/c/fss/private-simple_packet.c index b9f45e2..704b12c 100644 --- a/level_0/f_fss/c/fss/private-simple_packet.c +++ b/level_0/f_fss/c/fss/private-simple_packet.c @@ -20,8 +20,10 @@ extern "C" { #if !defined(_di_f_fss_simple_packet_ranges_append_) || !defined(_di_f_fss_simple_packet_ranges_append_all_) || !defined(_di_f_fss_simple_packet_rangess_append_all_) extern f_status_t private_f_fss_simple_packet_ranges_append_all(const f_fss_simple_packet_ranges_t source, f_fss_simple_packet_ranges_t *destination) { - const f_status_t status = f_memory_array_increase_by(source.used, sizeof(f_fss_simple_packet_range_t), (void **) &destination->array, &destination->used, &destination->size); - if (F_status_is_error(status)) return status; + { + const f_status_t status = f_memory_array_increase_by(source.used, sizeof(f_fss_simple_packet_range_t), (void **) &destination->array, &destination->used, &destination->size); + if (F_status_is_error(status)) return status; + } for (f_number_unsigned_t i = 0; i < source.used; ++i) { destination->array[destination->used++] = source.array[i]; @@ -34,32 +36,36 @@ extern "C" { #if !defined(_di_f_fss_simple_packet_rangess_adjust_) || !defined(_di_f_fss_simple_packet_rangess_decimate_by_) f_status_t private_f_fss_simple_packet_rangess_adjust(const f_number_unsigned_t length, f_fss_simple_packet_rangess_t *rangess) { - f_status_t status = F_none; + { + f_status_t status = F_none; - for (f_number_unsigned_t i = length; i < rangess->size; ++i) { + for (f_number_unsigned_t i = length; i < rangess->size; ++i) { - status = f_memory_array_adjust(0, sizeof(f_fss_simple_packet_range_t), (void **) &rangess->array[i].array, &rangess->array[i].used, &rangess->array[i].size); - if (F_status_is_error(status)) return status; - } // for + status = f_memory_array_adjust(0, sizeof(f_fss_simple_packet_range_t), (void **) &rangess->array[i].array, &rangess->array[i].used, &rangess->array[i].size); + if (F_status_is_error(status)) return status; + } // for + } return f_memory_array_adjust(length, sizeof(f_fss_simple_packet_ranges_t), (void **) &rangess->array, &rangess->used, &rangess->size); } #endif // !defined(_di_f_fss_simple_packet_rangess_adjust_) || !defined(_di_f_fss_simple_packet_rangess_decimate_by_) -#if !defined(_di_f_fss_simple_packet_rangess_decrease_by_) || !defined(_di_f_fss_simple_packet_rangess_increase_) || !defined(_di_f_fss_simple_packet_rangess_increase_by_) || !defined(_di_f_fss_simple_packet_rangess_resize_) +#if !defined(_di_f_fss_simple_packet_rangess_decrease_by_) || !defined(_di_f_fss_simple_packet_rangess_resize_) f_status_t private_f_fss_simple_packet_rangess_resize(const f_number_unsigned_t length, f_fss_simple_packet_rangess_t *rangess) { - f_status_t status = F_none; + { + f_status_t status = F_none; - for (f_number_unsigned_t i = length; i < rangess->size; ++i) { + for (f_number_unsigned_t i = length; i < rangess->size; ++i) { - status = f_memory_array_resize(0, sizeof(f_fss_simple_packet_range_t), (void **) &rangess->array[i].array, &rangess->array[i].used, &rangess->array[i].size); - if (F_status_is_error(status)) return status; - } // for + status = f_memory_array_resize(0, sizeof(f_fss_simple_packet_range_t), (void **) &rangess->array[i].array, &rangess->array[i].used, &rangess->array[i].size); + if (F_status_is_error(status)) return status; + } // for + } return f_memory_array_resize(length, sizeof(f_fss_simple_packet_ranges_t), (void **) &rangess->array, &rangess->used, &rangess->size); } -#endif // !defined(_di_f_fss_simple_packet_rangess_decrease_by_) || !defined(_di_f_fss_simple_packet_rangess_increase_) || !defined(_di_f_fss_simple_packet_rangess_increase_by_) || !defined(_di_f_fss_simple_packet_rangess_resize_) +#endif // !defined(_di_f_fss_simple_packet_rangess_decrease_by_) || !defined(_di_f_fss_simple_packet_rangess_resize_) #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_fss/c/fss/private-simple_packet.h b/level_0/f_fss/c/fss/private-simple_packet.h index b30df70..f9639cd 100644 --- a/level_0/f_fss/c/fss/private-simple_packet.h +++ b/level_0/f_fss/c/fss/private-simple_packet.h @@ -26,11 +26,14 @@ extern "C" { * The destination lengths the source is appended onto. * * @return - * F_none on success. + * Success from f_memory_array_increase(). * - * Errors (with error bit) from: f_memory_resize(). + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_array_increase(). + * + * @see f_memory_array_increase() * - * @see f_memory_resize() * @see f_fss_simple_packet_ranges_append() * @see f_fss_simple_packet_rangess_append() */ @@ -49,11 +52,14 @@ extern "C" { * The destination lengths the source is appended onto. * * @return - * F_none on success. + * Success from f_memory_array_increase_by(). + * + * F_parameter (with error bit) if a parameter is invalid. * - * Errors (with error bit) from: f_memory_resize(). + * Errors (with error bit) from: f_memory_array_increase_by(). + * + * @see f_memory_array_increase_by() * - * @see f_memory_resize() * @see f_fss_simple_packet_ranges_append_all() * @see f_fss_simple_packet_rangess_append() * @see f_fss_simple_packet_rangess_append_all() @@ -73,18 +79,16 @@ extern "C" { * The rangess array to adjust. * * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + 1 <= size). + * Success from f_memory_array_adjust(). * - * F_array_too_large (with error bit) if new length is larger than max array length. - * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. * - * Errors (with error bit) from: f_memory_adjust(). - * Errors (with error bit) from: f_memory_destroy(). + * Errors (with error bit) from: f_memory_array_adjust(). + * + * @see f_memory_array_adjust() * + * @see f_fss_simple_packet_rangess_decrease_by() * @see f_fss_simple_packet_rangess_adjust() - * @see f_fss_simple_packet_rangess_decimate_by() */ #if !defined(_di_f_fss_simple_packet_rangess_adjust_) || !defined(_di_f_fss_simple_packet_rangess_decimate_by_) extern f_status_t private_f_fss_simple_packet_rangess_adjust(const f_number_unsigned_t length, f_fss_simple_packet_rangess_t *rangess) F_attribute_visibility_internal_d; @@ -101,24 +105,20 @@ extern "C" { * The rangess array to resize. * * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + 1 <= size). + * Success from f_memory_array_resize(). * - * F_array_too_large (with error bit) if new length is larger than max array length. - * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. * - * Errors (with error bit) from: f_memory_delete(). - * Errors (with error bit) from: f_memory_resize(). + * Errors (with error bit) from: f_memory_array_resize(). + * + * @see f_memory_array_resize() * * @see f_fss_simple_packet_rangess_decrease_by() - * @see f_fss_simple_packet_rangess_increase() - * @see f_fss_simple_packet_rangess_increase_by() * @see f_fss_simple_packet_rangess_resize() */ -#if !defined(_di_f_fss_simple_packet_rangess_decrease_by_) || !defined(_di_f_fss_simple_packet_rangess_increase_) || !defined(_di_f_fss_simple_packet_rangess_increase_by_) || !defined(_di_f_fss_simple_packet_rangess_resize_) +#if !defined(_di_f_fss_simple_packet_rangess_decrease_by_) || !defined(_di_f_fss_simple_packet_rangess_resize_) extern f_status_t private_f_fss_simple_packet_rangess_resize(const f_number_unsigned_t length, f_fss_simple_packet_rangess_t *rangess) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_fss_simple_packet_rangess_decrease_by_) || !defined(_di_f_fss_simple_packet_rangess_increase_) || !defined(_di_f_fss_simple_packet_rangess_increase_by_) || !defined(_di_f_fss_simple_packet_rangess_resize_) +#endif // !defined(_di_f_fss_simple_packet_rangess_decrease_by_) || !defined(_di_f_fss_simple_packet_rangess_resize_) #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_fss/c/fss/set.c b/level_0/f_fss/c/fss/set.c index 3f4b59f..dad2b5a 100644 --- a/level_0/f_fss/c/fss/set.c +++ b/level_0/f_fss/c/fss/set.c @@ -22,9 +22,8 @@ extern "C" { #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - if (set->objects.size - amount > 0) return private_f_fss_set_adjust(set->objects.size - amount, set); - return private_f_fss_set_adjust(0, set); + return private_f_fss_set_adjust((set->objects.size - amount > 0) ? set->objects.size - amount : 0, set); } #endif // _di_f_fss_set_decimate_by_ @@ -35,9 +34,8 @@ extern "C" { #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - if (set->objects.size - amount > 0) return private_f_fss_set_resize(set->objects.size - amount, set); - return private_f_fss_set_resize(0, set); + return private_f_fss_set_resize((set->objects.size - amount > 0) ? set->objects.size - amount : 0, set); } #endif // _di_f_fss_set_decrease_by_ @@ -48,6 +46,8 @@ extern "C" { #endif // _di_level_0_parameter_checking_ if (step && set->objects.used + 1 > set->objects.size) { + if (set->objects.used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + f_number_unsigned_t size = set->objects.used + step; if (size > F_number_t_size_unsigned_d) { @@ -69,12 +69,16 @@ extern "C" { if (!set) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; + if (amount) { + if (set->objects.used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + + const f_number_unsigned_t length = set->objects.used + amount; - if (set->objects.used + amount > set->objects.size) { - if (set->objects.used + amount > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + if (length > set->objects.size) { + if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - return private_f_fss_set_resize(set->objects.used + amount, set); + return private_f_fss_set_resize(length, set); + } } return F_data_not; @@ -108,9 +112,8 @@ extern "C" { #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - if (sets->size - amount > 0) return private_f_fss_sets_adjust(sets->size - amount, sets); - return private_f_fss_sets_adjust(0, sets); + return private_f_fss_sets_adjust((sets->size > amount) ? sets->size - amount : 0, sets); } #endif // _di_f_fss_sets_decimate_by_ @@ -121,9 +124,8 @@ extern "C" { #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - if (sets->size - amount > 0) return private_f_fss_sets_resize(sets->size - amount, sets); - return private_f_fss_sets_resize(0, sets); + return private_f_fss_sets_resize((sets->size > amount) ? sets->size - amount : 0, sets); } #endif // _di_f_fss_sets_decrease_by_ @@ -133,19 +135,7 @@ extern "C" { if (!sets) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (step && sets->used + 1 > sets->size) { - f_number_unsigned_t size = sets->used + step; - - if (size > F_number_t_size_unsigned_d) { - if (sets->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - - size = F_number_t_size_unsigned_d; - } - - return private_f_fss_sets_resize(size, sets); - } - - return F_data_not; + return f_memory_array_increase(step, sizeof(f_fss_set_t), (void **) &sets->array, &sets->used, &sets->size); } #endif // _di_f_fss_sets_increase_ @@ -155,15 +145,7 @@ extern "C" { if (!sets) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; - - if (sets->used + amount > sets->size) { - if (sets->used + amount > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - - return private_f_fss_sets_resize(sets->used + amount, sets); - } - - return F_data_not; + return f_memory_array_increase_by(amount, sizeof(f_fss_set_t), (void **) &sets->array, &sets->used, &sets->size); } #endif // _di_f_fss_sets_increase_by_ diff --git a/level_0/f_fss/c/fss/set.h b/level_0/f_fss/c/fss/set.h index cd834fc..394bf17 100644 --- a/level_0/f_fss/c/fss/set.h +++ b/level_0/f_fss/c/fss/set.h @@ -73,8 +73,6 @@ extern "C" { #define macro_f_fss_sets_t_initialize_1(array, size, used) { array, size, used } #define macro_f_fss_sets_t_initialize_2(array, length) { array, length, length } - #define macro_f_fss_sets_t_clear(sets) macro_f_memory_structure_t_clear(set.objects) - #define macro_f_fss_sets_t_resize(status, sets, length) status = f_fss_sets_resize(length, &sets); #define macro_f_fss_sets_t_adjust(status, sets, length) status = f_fss_sets_adjust(length, &sets); @@ -98,8 +96,13 @@ extern "C" { * @return * F_none on success. * - * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_string_ranges_adjust(). + * Errors (with error bit) from: f_string_rangess_adjust(). + * + * @see f_string_ranges_adjust() + * @see f_string_rangess_adjust() */ #ifndef _di_f_fss_set_adjust_ extern f_status_t f_fss_set_adjust(const f_number_unsigned_t length, f_fss_set_t * const set); @@ -121,8 +124,13 @@ extern "C" { * F_none on success. * F_data_not if amount is 0. * - * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_string_ranges_adjust(). + * Errors (with error bit) from: f_string_rangess_adjust(). + * + * @see f_string_ranges_adjust() + * @see f_string_rangess_adjust() */ #ifndef _di_f_fss_set_decimate_by_ extern f_status_t f_fss_set_decimate_by(const f_number_unsigned_t amount, f_fss_set_t * const set); @@ -142,9 +150,15 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * - * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_string_ranges_resize(). + * Errors (with error bit) from: f_string_rangess_resize(). + * + * @see f_string_ranges_resize() + * @see f_string_rangess_resize() */ #ifndef _di_f_fss_set_decrease_by_ extern f_status_t f_fss_set_decrease_by(const f_number_unsigned_t amount, f_fss_set_t * const set); @@ -169,6 +183,15 @@ extern "C" { * F_array_too_large (with error bit) if the new array length is too large. * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. + * + * @return + * Success from f_memory_array_resize(). + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_array_resize(). + * + * @see f_memory_array_resize() */ #ifndef _di_f_fss_set_increase_ extern f_status_t f_fss_set_increase(const f_number_unsigned_t step, f_fss_set_t * const set); @@ -193,6 +216,15 @@ extern "C" { * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. * F_array_too_large (with error bit) if the new array length is too large. + * + * @return + * Success from f_memory_array_resize(). + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_array_resize(). + * + * @see f_memory_array_resize() */ #ifndef _di_f_fss_set_increase_by_ extern f_status_t f_fss_set_increase_by(const f_number_unsigned_t amount, f_fss_set_t * const set); @@ -211,6 +243,15 @@ extern "C" { * * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. + * + * @return + * Success from f_memory_array_resize(). + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_array_resize(). + * + * @see f_memory_array_resize() */ #ifndef _di_f_fss_set_resize_ extern f_status_t f_fss_set_resize(const f_number_unsigned_t length, f_fss_set_t * const set); @@ -229,6 +270,15 @@ extern "C" { * * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. + * + * @return + * Success from f_memory_array_resize(). + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_array_resize(). + * + * @see f_memory_array_resize() */ #ifndef _di_f_fss_sets_adjust_ extern f_status_t f_fss_sets_adjust(const f_number_unsigned_t length, f_fss_sets_t * const sets); @@ -252,6 +302,15 @@ extern "C" { * * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. + * + * @return + * Success from f_memory_array_resize(). + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_array_resize(). + * + * @see f_memory_array_resize() */ #ifndef _di_f_fss_sets_decimate_by_ extern f_status_t f_fss_sets_decimate_by(const f_number_unsigned_t amount, f_fss_sets_t * const sets); @@ -274,6 +333,15 @@ extern "C" { * * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. + * + * @return + * Success from f_memory_array_resize(). + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_array_resize(). + * + * @see f_memory_array_resize() */ #ifndef _di_f_fss_sets_decrease_by_ extern f_status_t f_fss_sets_decrease_by(const f_number_unsigned_t amount, f_fss_sets_t * const sets); @@ -298,6 +366,15 @@ extern "C" { * F_array_too_large (with error bit) if the new array length is too large. * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. + * + * @return + * Success from f_memory_array_increase(). + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_array_increase(). + * + * @see f_memory_array_increase() */ #ifndef _di_f_fss_sets_increase_ extern f_status_t f_fss_sets_increase(const f_number_unsigned_t step, f_fss_sets_t * const sets); @@ -322,6 +399,15 @@ extern "C" { * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. * F_array_too_large (with error bit) if the new array length is too large. + * + * @return + * Success from f_memory_array_increase_by(). + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_array_increase_by(). + * + * @see f_memory_array_increase_by() */ #ifndef _di_f_fss_sets_increase_by_ extern f_status_t f_fss_sets_increase_by(const f_number_unsigned_t amount, f_fss_sets_t * const sets); @@ -333,13 +419,16 @@ extern "C" { * @param length * The new size to use. * @param sets - * The sets array to adjust. + * The sets array to resize. * * @return - * F_none on success. + * Success from f_memory_array_resize(). * - * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_array_resize(). + * + * @see f_memory_array_resize() */ #ifndef _di_f_fss_sets_resize_ extern f_status_t f_fss_sets_resize(const f_number_unsigned_t length, f_fss_sets_t * const sets); diff --git a/level_0/f_fss/c/fss/set_quote.c b/level_0/f_fss/c/fss/set_quote.c index 29b74be..39bf227 100644 --- a/level_0/f_fss/c/fss/set_quote.c +++ b/level_0/f_fss/c/fss/set_quote.c @@ -22,9 +22,8 @@ extern "C" { #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - if (set_quote->objects.size - amount > 0) return private_f_fss_set_quote_adjust(set_quote->objects.size - amount, set_quote); - return private_f_fss_set_quote_adjust(0, set_quote); + return private_f_fss_set_quote_adjust((set_quote->objects.size - amount > 0) ? set_quote->objects.size - amount : 0, set_quote); } #endif // _di_f_fss_set_quote_decimate_by_ @@ -35,9 +34,8 @@ extern "C" { #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - if (set_quote->objects.size - amount > 0) return private_f_fss_set_quote_resize(set_quote->objects.size - amount, set_quote); - return private_f_fss_set_quote_resize(0, set_quote); + return private_f_fss_set_quote_resize((set_quote->objects.size - amount > 0) ? set_quote->objects.size - amount : 0, set_quote); } #endif // _di_f_fss_set_quote_decrease_by_ @@ -48,6 +46,8 @@ extern "C" { #endif // _di_level_0_parameter_checking_ if (step && set_quote->objects.used + 1 > set_quote->objects.size) { + if (set_quote->objects.used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + f_number_unsigned_t size = set_quote->objects.used + step; if (size > F_number_t_size_unsigned_d) { @@ -69,12 +69,16 @@ extern "C" { if (!set_quote) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; + if (amount) { + if (set_quote->objects.used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + + const f_number_unsigned_t length = set_quote->objects.used + amount; - if (set_quote->objects.used + amount > set_quote->objects.size) { - if (set_quote->objects.used + amount > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + if (length > set_quote->objects.size) { + if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - return private_f_fss_set_quote_resize(set_quote->objects.used + amount, set_quote); + return private_f_fss_set_quote_resize(length, set_quote); + } } return F_data_not; @@ -108,9 +112,8 @@ extern "C" { #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - if (set_quotes->size - amount > 0) return private_f_fss_set_quotes_adjust(set_quotes->size - amount, set_quotes); - return private_f_fss_set_quotes_adjust(0, set_quotes); + return private_f_fss_set_quotes_adjust((set_quotes->size > amount) ? set_quotes->size - amount : 0, set_quotes); } #endif // _di_f_fss_set_quotes_decimate_by_ @@ -121,9 +124,8 @@ extern "C" { #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - if (set_quotes->size - amount > 0) return private_f_fss_set_quotes_resize(set_quotes->size - amount, set_quotes); - return private_f_fss_set_quotes_resize(0, set_quotes); + return private_f_fss_set_quotes_resize((set_quotes->size > amount) ? set_quotes->size - amount : 0, set_quotes); } #endif // _di_f_fss_set_quotes_decrease_by_ @@ -133,19 +135,7 @@ extern "C" { if (!set_quotes) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (step && set_quotes->used + 1 > set_quotes->size) { - f_number_unsigned_t size = set_quotes->used + step; - - if (size > F_number_t_size_unsigned_d) { - if (set_quotes->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - - size = F_number_t_size_unsigned_d; - } - - return private_f_fss_set_quotes_resize(size, set_quotes); - } - - return F_data_not; + return f_memory_array_increase(step, sizeof(f_fss_set_quote_t), (void **) &set_quotes->array, &set_quotes->used, &set_quotes->size); } #endif // _di_f_fss_set_quotes_increase_ @@ -155,15 +145,7 @@ extern "C" { if (!set_quotes) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; - - if (set_quotes->used + amount > set_quotes->size) { - if (set_quotes->used + amount > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - - return private_f_fss_set_quotes_resize(set_quotes->used + amount, set_quotes); - } - - return F_data_not; + return f_memory_array_increase_by(amount, sizeof(f_fss_set_quote_t), (void **) &set_quotes->array, &set_quotes->used, &set_quotes->size); } #endif // _di_f_fss_set_quotes_increase_by_ diff --git a/level_0/f_fss/c/fss/set_quote.h b/level_0/f_fss/c/fss/set_quote.h index cf9480d..968b9b1 100644 --- a/level_0/f_fss/c/fss/set_quote.h +++ b/level_0/f_fss/c/fss/set_quote.h @@ -80,8 +80,6 @@ extern "C" { #define macro_f_fss_set_quotes_t_initialize_1(array, size, used) { array, size, used } #define macro_f_fss_set_quotes_t_initialize_2(array, length) { array, length, length } - #define macro_f_fss_set_quotes_t_clear(nameds) macro_f_memory_structure_clear(nameds) - #define macro_f_fss_set_quotes_t_resize(status, set_quotes, length) status = f_fss_set_quotes_resize(length, &set_quotes); #define macro_f_fss_set_quotes_t_adjust(status, set_quotes, length) status = f_fss_set_quotes_adjust(length, &set_quotes); @@ -107,6 +105,16 @@ extern "C" { * * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_string_ranges_adjust(). + * Errors (with error bit) from: f_string_rangess_adjust(). + * Errors (with error bit) from: f_uint8s_adjust(). + * Errors (with error bit) from: f_uint8ss_adjust(). + * + * @see f_string_ranges_adjust() + * @see f_string_rangess_adjust() + * @see f_uint8s_adjust() + * @see f_uint8ss_adjust() */ #ifndef _di_f_fss_set_quote_adjust_ extern f_status_t f_fss_set_quote_adjust(const f_number_unsigned_t length, f_fss_set_quote_t * const set_quote); @@ -130,6 +138,16 @@ extern "C" { * * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_string_ranges_adjust(). + * Errors (with error bit) from: f_string_rangess_adjust(). + * Errors (with error bit) from: f_uint8s_adjust(). + * Errors (with error bit) from: f_uint8ss_adjust(). + * + * @see f_string_ranges_adjust() + * @see f_string_rangess_adjust() + * @see f_uint8s_adjust() + * @see f_uint8ss_adjust() */ #ifndef _di_f_fss_set_quote_decimate_by_ extern f_status_t f_fss_set_quote_decimate_by(const f_number_unsigned_t amount, f_fss_set_quote_t * const set_quote); @@ -152,6 +170,16 @@ extern "C" { * * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_string_ranges_resize(). + * Errors (with error bit) from: f_string_rangess_resize(). + * Errors (with error bit) from: f_uint8s_resize(). + * Errors (with error bit) from: f_uint8ss_resize(). + * + * @see f_string_ranges_resize() + * @see f_string_rangess_resize() + * @see f_uint8s_resize() + * @see f_uint8ss_resize() */ #ifndef _di_f_fss_set_quote_decrease_by_ extern f_status_t f_fss_set_quote_decrease_by(const f_number_unsigned_t amount, f_fss_set_quote_t * const set_quote); @@ -176,6 +204,18 @@ extern "C" { * F_array_too_large (with error bit) if the new array length is too large. * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_array_increase(). + * Errors (with error bit) from: f_string_ranges_resize(). + * Errors (with error bit) from: f_string_rangess_resize(). + * Errors (with error bit) from: f_uint8s_resize(). + * Errors (with error bit) from: f_uint8ss_resize(). + * + * @see f_memory_array_increase() + * @see f_string_ranges_resize() + * @see f_string_rangess_resize() + * @see f_uint8s_resize() + * @see f_uint8ss_resize() */ #ifndef _di_f_fss_set_quote_increase_ extern f_status_t f_fss_set_quote_increase(const f_number_unsigned_t step, f_fss_set_quote_t * const set_quote); @@ -200,6 +240,18 @@ extern "C" { * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. * F_array_too_large (with error bit) if the new array length is too large. + * + * Errors (with error bit) from: f_memory_array_increase_by(). + * Errors (with error bit) from: f_string_ranges_resize(). + * Errors (with error bit) from: f_string_rangess_resize(). + * Errors (with error bit) from: f_uint8s_resize(). + * Errors (with error bit) from: f_uint8ss_resize(). + * + * @see f_memory_array_increase_by() + * @see f_string_ranges_resize() + * @see f_string_rangess_resize() + * @see f_uint8s_resize() + * @see f_uint8ss_resize() */ #ifndef _di_f_fss_set_quote_increase_by_ extern f_status_t f_fss_set_quote_increase_by(const f_number_unsigned_t amount, f_fss_set_quote_t * const set_quote); @@ -218,6 +270,16 @@ extern "C" { * * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_string_ranges_resize(). + * Errors (with error bit) from: f_string_rangess_resize(). + * Errors (with error bit) from: f_uint8s_resize(). + * Errors (with error bit) from: f_uint8ss_resize(). + * + * @see f_string_ranges_resize() + * @see f_string_rangess_resize() + * @see f_uint8s_resize() + * @see f_uint8ss_resize() */ #ifndef _di_f_fss_set_quote_resize_ extern f_status_t f_fss_set_quote_resize(const f_number_unsigned_t length, f_fss_set_quote_t * const set_quote); @@ -236,6 +298,16 @@ extern "C" { * * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_string_ranges_adjust(). + * Errors (with error bit) from: f_string_rangess_adjust(). + * Errors (with error bit) from: f_uint8s_adjust(). + * Errors (with error bit) from: f_uint8ss_adjust(). + * + * @see f_string_ranges_adjust() + * @see f_string_rangess_adjust() + * @see f_uint8s_adjust() + * @see f_uint8ss_adjust() */ #ifndef _di_f_fss_set_quotes_adjust_ extern f_status_t f_fss_set_quotes_adjust(const f_number_unsigned_t length, f_fss_set_quotes_t * const set_quotes); @@ -259,6 +331,16 @@ extern "C" { * * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_string_ranges_adjust(). + * Errors (with error bit) from: f_string_rangess_adjust(). + * Errors (with error bit) from: f_uint8s_adjust(). + * Errors (with error bit) from: f_uint8ss_adjust(). + * + * @see f_string_ranges_adjust() + * @see f_string_rangess_adjust() + * @see f_uint8s_adjust() + * @see f_uint8ss_adjust() */ #ifndef _di_f_fss_set_quotes_decimate_by_ extern f_status_t f_fss_set_quotes_decimate_by(const f_number_unsigned_t amount, f_fss_set_quotes_t * const set_quotes); @@ -281,6 +363,16 @@ extern "C" { * * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_string_ranges_resize(). + * Errors (with error bit) from: f_string_rangess_resize(). + * Errors (with error bit) from: f_uint8s_resize(). + * Errors (with error bit) from: f_uint8ss_resize(). + * + * @see f_string_ranges_resize() + * @see f_string_rangess_resize() + * @see f_uint8s_resize() + * @see f_uint8ss_resize() */ #ifndef _di_f_fss_set_quotes_decrease_by_ extern f_status_t f_fss_set_quotes_decrease_by(const f_number_unsigned_t amount, f_fss_set_quotes_t * const set_quotes); @@ -305,6 +397,18 @@ extern "C" { * F_array_too_large (with error bit) if the new array length is too large. * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_array_increase(). + * Errors (with error bit) from: f_string_ranges_resize(). + * Errors (with error bit) from: f_string_rangess_resize(). + * Errors (with error bit) from: f_uint8s_resize(). + * Errors (with error bit) from: f_uint8ss_resize(). + * + * @see f_memory_array_increase() + * @see f_string_ranges_resize() + * @see f_string_rangess_resize() + * @see f_uint8s_resize() + * @see f_uint8ss_resize() */ #ifndef _di_f_fss_set_quotes_increase_ extern f_status_t f_fss_set_quotes_increase(const f_number_unsigned_t step, f_fss_set_quotes_t * const set_quotes); @@ -329,6 +433,18 @@ extern "C" { * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. * F_array_too_large (with error bit) if the new array length is too large. + * + * Errors (with error bit) from: f_memory_array_increase_by(). + * Errors (with error bit) from: f_string_ranges_resize(). + * Errors (with error bit) from: f_string_rangess_resize(). + * Errors (with error bit) from: f_uint8s_resize(). + * Errors (with error bit) from: f_uint8ss_resize(). + * + * @see f_memory_array_increase_by() + * @see f_string_ranges_resize() + * @see f_string_rangess_resize() + * @see f_uint8s_resize() + * @see f_uint8ss_resize() */ #ifndef _di_f_fss_set_quotes_increase_by_ extern f_status_t f_fss_set_quotes_increase_by(const f_number_unsigned_t amount, f_fss_set_quotes_t * const set_quotes); @@ -340,13 +456,22 @@ extern "C" { * @param length * The new size to use. * @param set_quotes - * The set_quotes array to adjust. + * The set_quotes array to resize. * * @return - * F_none on success. + * Success from f_memory_array_resize(). * - * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_string_ranges_resize(). + * Errors (with error bit) from: f_string_rangess_resize(). + * Errors (with error bit) from: f_uint8s_resize(). + * Errors (with error bit) from: f_uint8ss_resize(). + * + * @see f_string_ranges_resize() + * @see f_string_rangess_resize() + * @see f_uint8s_resize() + * @see f_uint8ss_resize() */ #ifndef _di_f_fss_set_quotes_resize_ extern f_status_t f_fss_set_quotes_resize(const f_number_unsigned_t length, f_fss_set_quotes_t * const set_quotes); diff --git a/level_0/f_fss/c/fss/simple_packet.h b/level_0/f_fss/c/fss/simple_packet.h index c09d7cd..ec447d9 100644 --- a/level_0/f_fss/c/fss/simple_packet.h +++ b/level_0/f_fss/c/fss/simple_packet.h @@ -84,8 +84,6 @@ extern "C" { #define macro_f_fss_simple_packet_ranges_t_initialize_1(array, size, used) { array, size, used } #define macro_f_fss_simple_packet_ranges_t_initialize_2(array, length) { array, length, length } - #define macro_f_fss_simple_packet_ranges_t_clear(simple_packet_ranges) macro_f_memory_structure_t_clear(simple_packet_range.objects) - #define macro_f_fss_simple_packet_ranges_t_resize(status, simple_packet_ranges, length) status = f_fss_simple_packet_ranges_resize(length, &simple_packet_ranges); #define macro_f_fss_simple_packet_ranges_t_adjust(status, simple_packet_ranges, length) status = f_fss_simple_packet_ranges_adjust(length, &simple_packet_ranges); @@ -119,8 +117,6 @@ extern "C" { #define macro_f_fss_simple_packet_rangess_t_initialize_1(array, size, used) { array, size, used } #define macro_f_fss_simple_packet_rangess_t_initialize_2(array, length) { array, length, length } - #define macro_f_fss_simple_packet_rangess_t_clear(simple_packet_rangess) macro_f_memory_structure_t_clear(simple_packet_ranges.objects) - #define macro_f_fss_simple_packet_rangess_t_resize(status, simple_packet_rangess, length) status = f_fss_simple_packet_rangess_resize(length, &simple_packet_rangess); #define macro_f_fss_simple_packet_rangess_t_adjust(status, simple_packet_rangess, length) status = f_fss_simple_packet_rangess_adjust(length, &simple_packet_rangess); @@ -533,7 +529,7 @@ extern "C" { * @param length * The new size to use. * @param rangess - * The rangess array to adjust. + * The rangess array to resize. * * @return * Success from f_memory_array_resize(). diff --git a/level_0/f_iki/c/iki/common.h b/level_0/f_iki/c/iki/common.h index b0b4cad..34de16c 100644 --- a/level_0/f_iki/c/iki/common.h +++ b/level_0/f_iki/c/iki/common.h @@ -248,8 +248,6 @@ extern "C" { #define macro_f_iki_datas_t_initialize_1(content, size, used) { array, size, used } #define macro_f_iki_datas_t_initialize_2(array, length) { array, length, length } - #define macro_f_iki_datas_t_clear(datas) macro_f_memory_structure_clear(datas) - #define macro_f_iki_datas_t_resize(status, datas, length) status = f_iki_datas_resize(length, &datas); #define macro_f_iki_datas_t_adjust(status, datas, length) status = f_iki_datas_adjust(length, &datas); @@ -283,8 +281,6 @@ extern "C" { #define macro_f_iki_datass_t_initialize_1(content, size, used) { array, size, used } #define macro_f_iki_datass_t_initialize_2(array, length) { array, length, length } - #define macro_f_iki_datass_t_clear(datas) macro_f_memory_structure_clear(datas) - #define macro_f_iki_datass_t_resize(status, datas, length) status = f_iki_datass_resize(length, &datas); #define macro_f_iki_datass_t_adjust(status, datas, length) status = f_iki_datass_adjust(length, &datas); diff --git a/level_0/f_iki/c/iki/data.c b/level_0/f_iki/c/iki/data.c index 039eeb5..9f8ca36 100644 --- a/level_0/f_iki/c/iki/data.c +++ b/level_0/f_iki/c/iki/data.c @@ -89,10 +89,7 @@ extern "C" { #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - - if (datas->size > amount) { - return private_f_iki_datas_adjust(datas->size - amount, datas); - } + if (datas->size > amount) return private_f_iki_datas_adjust(datas->size - amount, datas); return private_f_iki_datas_adjust(0, datas); } @@ -105,10 +102,7 @@ extern "C" { #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - - if (datas->size > amount) { - return private_f_iki_datas_resize(datas->size - amount, datas); - } + if (datas->size > amount) return private_f_iki_datas_resize(datas->size - amount, datas); return private_f_iki_datas_resize(0, datas); } @@ -121,12 +115,12 @@ extern "C" { #endif // _di_level_0_parameter_checking_ if (step && datas->used + 1 > datas->size) { + if (datas->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + f_number_unsigned_t size = datas->used + step; if (size > F_number_t_size_unsigned_d) { - if (datas->used + 1 > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + if (datas->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); size = F_number_t_size_unsigned_d; } @@ -144,14 +138,16 @@ extern "C" { if (!datas) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; + if (amount) { + if (datas->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - if (datas->used + amount > datas->size) { - if (datas->used + amount > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + const f_number_unsigned_t length = datas->used + amount; - return private_f_iki_datas_resize(datas->used + amount, datas); + if (length > datas->size) { + if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + + return private_f_iki_datas_resize(length, datas); + } } return F_data_not; @@ -238,10 +234,7 @@ extern "C" { #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - - if (datass->size > amount) { - return private_f_iki_datass_adjust(datass->size - amount, datass); - } + if (datass->size > amount) return private_f_iki_datass_adjust(datass->size - amount, datass); return private_f_iki_datass_adjust(0, datass); } @@ -254,10 +247,7 @@ extern "C" { #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - - if (datass->size > amount) { - return private_f_iki_datass_resize(datass->size - amount, datass); - } + if (datass->size > amount) return private_f_iki_datass_resize(datass->size - amount, datass); return private_f_iki_datass_resize(0, datass); } @@ -270,12 +260,12 @@ extern "C" { #endif // _di_level_0_parameter_checking_ if (step && datass->used + 1 > datass->size) { + if (datass->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + f_number_unsigned_t size = datass->used + step; if (size > F_number_t_size_unsigned_d) { - if (datass->used + 1 > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + if (datass->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); size = F_number_t_size_unsigned_d; } @@ -293,14 +283,16 @@ extern "C" { if (!datass) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; + if (amount) { + if (datass->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - if (datass->used + amount > datass->size) { - if (datass->used + amount > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + const f_number_unsigned_t length = datass->used + amount; - return private_f_iki_datass_resize(datass->used + amount, datass); + if (length > datass->size) { + if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + + return private_f_iki_datass_resize(length, datass); + } } return F_data_not; diff --git a/level_0/f_iki/c/iki/private-data.c b/level_0/f_iki/c/iki/private-data.c index aa11a69..5f9bf5a 100644 --- a/level_0/f_iki/c/iki/private-data.c +++ b/level_0/f_iki/c/iki/private-data.c @@ -8,9 +8,8 @@ extern "C" { #if !defined(_di_f_iki_datas_adjust_) || !defined(_di_f_iki_datas_decimate_by_) f_status_t private_f_iki_datas_adjust(const f_number_unsigned_t length, f_iki_datas_t *datas) { - if (datas->used + length > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + if (datas->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + if (datas->used + length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); f_status_t status = F_none; @@ -29,16 +28,7 @@ extern "C" { if (F_status_is_error(status)) return status; } // for - status = f_memory_adjust(datas->size, length, sizeof(f_iki_data_t), (void **) & datas->array); - if (F_status_is_error(status)) return status; - - datas->size = length; - - if (datas->used > datas->size) { - datas->used = length; - } - - return F_none; + return f_memory_array_adjust(length, sizeof(f_iki_data_t), (void **) &datas->array, &datas->used, &datas->size); } #endif // !defined(_di_f_iki_datas_adjust_) || !defined(_di_f_iki_datas_decimate_by_) @@ -128,9 +118,8 @@ extern "C" { #if !defined(_di_f_iki_datas_append_) || !defined(_di_f_iki_datas_decrease_by_) || !defined(_di_f_iki_datas_increase_) || !defined(_di_f_iki_datas_increase_by_) || !defined(_di_f_iki_datas_resize_) f_status_t private_f_iki_datas_resize(const f_number_unsigned_t length, f_iki_datas_t *datas) { - if (datas->used + length > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + if (datas->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + if (datas->used + length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); f_status_t status = F_none; @@ -149,16 +138,7 @@ extern "C" { if (F_status_is_error(status)) return status; } // for - status = f_memory_resize(datas->size, length, sizeof(f_iki_data_t), (void **) & datas->array); - if (F_status_is_error(status)) return status; - - datas->size = length; - - if (datas->used > datas->size) { - datas->used = length; - } - - return F_none; + return f_memory_array_resize(length, sizeof(f_iki_data_t), (void **) &datas->array, &datas->used, &datas->size); } #endif // !defined(_di_f_iki_datas_append_) || !defined(_di_f_iki_datas_decrease_by_) || !defined(_di_f_iki_datas_increase_) || !defined(_di_f_iki_datas_increase_by_) || !defined(_di_f_iki_datas_resize_) @@ -169,11 +149,8 @@ extern "C" { for (f_number_unsigned_t i = length; i < datass->size; ++i) { - status = f_memory_destroy(datass->array[i].size, sizeof(f_iki_datas_t), (void **) & datass->array[i].array); + status = private_f_iki_datas_adjust(0, &datass->array[i]); if (F_status_is_error(status)) return status; - - datass->array[i].size = 0; - datass->array[i].used = 0; } // for status = f_memory_adjust(datass->size, length, sizeof(f_iki_datas_t), (void **) & datass->array); diff --git a/level_0/f_limit/c/limit/set.h b/level_0/f_limit/c/limit/set.h index b0f2560..e32eadd 100644 --- a/level_0/f_limit/c/limit/set.h +++ b/level_0/f_limit/c/limit/set.h @@ -59,8 +59,6 @@ extern "C" { #define macro_f_limit_sets_t_initialize_1(array, size, used) { array, size, used } #define macro_f_limit_sets_t_initialize_2(array, length) { array, length, length } - #define macro_f_limit_sets_t_clear(sets) macro_f_memory_structure_clear(sets) - #define macro_f_limit_sets_t_resize(status, sets, length) status = f_limit_sets_resize(length, &sets); #define macro_f_limit_sets_t_adjust(status, sets, length) status = f_limit_sets_adjust(length, &sets); @@ -94,8 +92,6 @@ extern "C" { #define macro_f_limit_setss_t_initialize_1(array, size, used) { array, size, used } #define macro_f_limit_setss_t_initialize_2(array, length) { array, length, length } - #define macro_f_limit_setss_t_clear(setss) macro_f_memory_structure_clear(setss); - #define macro_f_limit_setss_t_resize(status, setss, length) status = f_limit_setss_resize(length, &setss); #define macro_f_limit_setss_t_adjust(status, setss, length) status = f_limit_setss_adjust(length, &setss); diff --git a/level_0/f_limit/c/limit/value.h b/level_0/f_limit/c/limit/value.h index 7768e51..9fd7419 100644 --- a/level_0/f_limit/c/limit/value.h +++ b/level_0/f_limit/c/limit/value.h @@ -55,8 +55,6 @@ extern "C" { #define macro_f_limit_values_t_initialize_1(content, size, used) { array, size, used } #define macro_f_limit_values_t_initialize_2(array, length) { array, length, length } - #define macro_f_limit_values_t_clear(values) macro_f_memory_structure_clear(values) - #define macro_f_limit_values_t_resize(status, values, length) status = f_limit_values_resize(length, &values); #define macro_f_limit_values_t_adjust(status, values, length) status = f_limit_values_adjust(length, &values); @@ -90,8 +88,6 @@ extern "C" { #define macro_f_limit_valuess_t_initialize_1(array, size, used) { array, size, used } #define macro_f_limit_valuess_t_initialize_2(array, length) { array, length, length } - #define macro_f_limit_valuess_t_clear(valuess) macro_f_memory_structure_clear(valuess); - #define macro_f_limit_valuess_t_resize(status, valuess, length) status = f_limit_valuess_resize(length, &valuess); #define macro_f_limit_valuess_t_adjust(status, valuess, length) status = f_limit_valuess_adjust(length, &valuess); diff --git a/level_0/f_memory/c/memory.h b/level_0/f_memory/c/memory.h index b3b9045..9f1ea8e 100644 --- a/level_0/f_memory/c/memory.h +++ b/level_0/f_memory/c/memory.h @@ -22,7 +22,6 @@ // FLL-0 memory includes. #include #include -#include #ifdef __cplusplus extern "C" { diff --git a/level_0/f_memory/c/memory/array.c b/level_0/f_memory/c/memory/array.c index 198dcee..75a6f04 100644 --- a/level_0/f_memory/c/memory/array.c +++ b/level_0/f_memory/c/memory/array.c @@ -28,9 +28,8 @@ extern "C" { #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - if (*size > amount) return private_f_memory_array_adjust(*size - amount, width, array, used, size); - return private_f_memory_array_adjust(0, width, array, used, size); + return private_f_memory_array_adjust((*size > amount) ? *size - amount : 0, width, array, used, size); } #endif // _di_f_memory_array_decimate_by_ @@ -43,9 +42,8 @@ extern "C" { #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - if (*size > amount) return private_f_memory_array_resize(*size - amount, width, array, used, size); - return private_f_memory_array_resize(0, width, array, used, size); + return private_f_memory_array_resize((*size > amount) ? *size - amount : 0, width, array, used, size); } #endif // _di_f_memory_array_decrease_by_ @@ -58,13 +56,12 @@ extern "C" { #endif // _di_level_0_parameter_checking_ if (step && *used + 1 > *size) { - f_number_unsigned_t length = *used + step; + if (*used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - if (step > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + f_number_unsigned_t length = *used + step; - if (*size > F_number_t_size_unsigned_d) { + if (length > F_number_t_size_unsigned_d) { if (*used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - if (*used + length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); length = F_number_t_size_unsigned_d; } @@ -84,12 +81,16 @@ extern "C" { if (!size) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; + if (amount) { + if (*used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - if (*used + amount > *size) { - if (*used + amount > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + const f_number_unsigned_t length = *used + amount; - return private_f_memory_array_resize(*used + amount, width, array, used, size); + if (length > *size) { + if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + + return private_f_memory_array_resize(length, width, array, used, size); + } } return F_data_not; @@ -104,6 +105,7 @@ extern "C" { if (!size) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (*used > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); return private_f_memory_array_resize(length, width, array, used, size); diff --git a/level_0/f_memory/c/memory/common.h b/level_0/f_memory/c/memory/common.h index d6e7428..2b018a7 100644 --- a/level_0/f_memory/c/memory/common.h +++ b/level_0/f_memory/c/memory/common.h @@ -42,370 +42,6 @@ extern "C" { #define F_memory_default_allocation_small_d 8 #endif // _di_f_memory_default_d_ -/** - * Reset a generic memory stucture to 0 (clear all values). - * - * This does not deallocate memory, be certain that memory is not allocated before calling this to avoid potential memory leaks. - * - * structure: the structure to operate on. - */ -#ifndef _di_macro_f_memory_structure_clear_ - #define macro_f_memory_structure_clear(structure) \ - structure.array = 0; \ - structure.size = 0; \ - structure.used = 0; -#endif // _di_macro_f_memory_structure_clear_ - -/** - * Resize a generic memory structure. - * - * status: the status to return. - * structure: the structure to operate on. - * type: the structure type. - * length: the new size of the array. - */ -#ifndef _di_macro_f_memory_structure_resize_ - #define macro_f_memory_structure_resize(status, structure, type, length) \ - status = f_memory_structure_resize(length, sizeof(type), (void **) &structure.array, &structure.used, &structure.size); -#endif // _di_macro_f_memory_structure_resize_ - -/** - * Adjust a generic memory structure. - * - * status: the status to return. - * structure: the structure to operate on. - * type: the structure type. - * length: the new size of the array. - */ -#ifndef _di_macro_f_memory_structure_adjust_ - #define macro_f_memory_structure_adjust(status, structure, type, length) \ - status = f_memory_structure_adjust(length, sizeof(type), (void **) &structure.array, &structure.used, &structure.size); -#endif // _di_macro_f_memory_structure_adjust_ - -/** - * Delete a generic memory structure. - * - * status: the status to return. - * structure: the structure to operate on. - * type: the structure type. - */ -#ifndef _di_macro_f_memory_structure_delete_ - #define macro_f_memory_structure_delete(status, structure, type) \ - status = f_memory_structure_resize(0, sizeof(type), (void **) &structure.array, &structure.used, &structure.size); -#endif // _di_macro_f_memory_structure_delete_ - -/** - * Destroy a generic memory structure. - * - * status: the status to return. - * structure: the structure to operate on. - * type: the structure type. - */ -#ifndef _di_macro_f_memory_structure_destroy_ - #define macro_f_memory_structure_destroy(status, structure, type) \ - status = f_memory_structure_adjust(0, sizeof(type), (void **) &structure.array, &structure.used, &structure.size); -#endif // _di_macro_f_memory_structure_destroy_ - -/** - * Delete a generic memory structure. - * - * structure: the structure to operate on. - * type: the structure type. - */ -#ifndef _di_macro_f_memory_structure_delete_simple_ - #define macro_f_memory_structure_delete_simple(structure, type) \ - f_memory_structure_resize(0, sizeof(type), (void **) &structure.array, &structure.used, &structure.size); -#endif // _di_macro_f_memory_structure_delete_simple_ - -/** - * Destroy a generic memory structure. - * - * structure: the structure to operate on. - * type: the structure type. - */ -#ifndef _di_macro_f_memory_structure_destroy_simple_ - #define macro_f_memory_structure_destroy_simple(structure, type) \ - f_memory_structure_adjust(0, sizeof(type), (void **) &structure.array, &structure.used, &structure.size); -#endif // _di_macro_f_memory_structure_destroy_simple_ - -/** - * Increase a generic memory structure. - * - * status: The status to return. - * step: The allocation step. - * structure: The structure to operate on. - * type: The structure type. - */ -#ifndef _di_macro_f_memory_structure_increase_ - #define macro_f_memory_structure_increase(status, step, structure, type) \ - status = f_memory_structure_increase(step, sizeof(type), (void **) &structure.array, &structure.used, &structure.size); -#endif // _di_macro_f_memory_structure_increase_ - -/** - * Increase a generic memory structure by some amount. - * - * status: The status to return. - * structure: The structure to operate on. - * type: The structure type. - * amount: The amount to increase the size of the array by. - */ -#ifndef _di_macro_f_memory_structure_increase_by_ - #define macro_f_memory_structure_increase_by(status, structure, type, amount) \ - status = f_memory_structure_increase_by(amount, sizeof(type), (void **) &structure.array, &structure.used, &structure.size); -#endif // _di_macro_f_memory_structure_increase_by_ - -/** - * Decrease a generic memory structure by some amount. - * - * status: The status to return. - * structure: The structure to operate on. - * type: The structure type. - * amount: The amount to decrease the size of the array by. - */ -#ifndef _di_macro_f_memory_structure_decrease_by_ - #define macro_f_memory_structure_decrease_by(status, structure, type, amount) \ - status = f_memory_structure_decrease_by(amount, sizeof(type), (void **) &structure.array, &structure.used, &structure.size); -#endif // _di_macro_f_memory_structure_decrease_by_ - -/** - * Decimate a generic memory structure by some amount. - * - * status: The status to return. - * structure: The structure to operate on. - * type: The structure type. - * amount: The amount to decimate the size of the array by. - */ -#ifndef _di_macro_f_memory_structure_decimate_by_ - #define macro_f_memory_structure_decimate_by(status, structure, type, amount) \ - status = f_memory_structure_decimate_by(amount, sizeof(type), (void **) &structure.array, &structure.used, &structure.size); -#endif // _di_macro_f_memory_structure_decimate_by_ - -/** - * Reset a generic memory stuctures to 0 (clear all values). - * - * This does not deallocate memory, be certain that memory is not allocated before calling this to avoid potential memory leaks. - * - * structures: the structures to operate on. - */ -#ifndef _di_macro_f_memory_structures_clear_ - #define macro_f_memory_structures_clear(structures) \ - structures.array = 0; \ - structures.size = 0; \ - structures.used = 0; -#endif // _di_macro_f_memory_structures_clear_ - -/** - * Resize a generic memory structures. - * - * status: The status to return. - * structures: The structures to operate on. - * type_stucture: The structure type. - * type_stuctures: The structures type. - * length: The new size of the array. - * type_length: The data type of the length variable type. - */ -#ifndef _di_macro_f_memory_structures_resize_ - #define macro_f_memory_structures_resize(status, structures, type_structure, type_structures, length, type_length) \ - status = F_none; \ - 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_macro_f_memory_structures_resize_ - -/** - * Adjust a generic memory structures. - * - * status: The status to return. - * structures: The structures to operate on. - * type_stucture: The structure type. - * type_stuctures: The structures type. - * length: The new size of the array. - * type_length: The data type of the length variable type. - */ -#ifndef _di_macro_f_memory_structures_adjust_ - #define macro_f_memory_structures_adjust(status, structures, type_structure, type_structures, length, type_length) \ - status = F_none; \ - 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_macro_f_memory_structures_adjust_ - -/** - * Delete a generic memory structures. - * - * status: The status to return. - * structures: The structures to operate on. - * type_stucture: The structure type. - * type_stuctures: The structures type. - */ -#ifndef _di_macro_f_memory_structures_delete_ - #define macro_f_memory_structures_delete(status, structures, type_structure, type_structures) \ - structures.used = structures.size; \ - while (structures.used) { \ - --structures.used; \ - status = f_memory_structure_resize(0, sizeof(type_structure), (void **) &structures.array[structures.used].array, &structures.array[structures.used].used, &structures.array[structures.used].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_macro_f_memory_structures_delete_ - -/** - * Destroy a generic memory structures. - * - * status: The status to return. - * structures: The structures to operate on. - * type_stucture: The structure type. - * type_stuctures: The structures type. - */ -#ifndef _di_macro_f_memory_structures_destroy_ - #define macro_f_memory_structures_destroy(status, structures, type_structure, type_structures) \ - structures.used = structures.size; \ - while (structures.used) { \ - --structures.used; \ - status = f_memory_structure_adjust(0, sizeof(type_structure), (void **) &structures.array[structures.used].array, &structures.array[structures.used].used, &structures.array[structures.used].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_macro_f_memory_structures_destroy_ - -/** - * Delete a generic memory structures. - * - * structures: The structures to operate on. - * type_stucture: The structure type. - * type_stuctures: The structures type. - */ -#ifndef _di_macro_f_memory_structures_delete_simple_ - #define macro_f_memory_structures_delete_simple(structures, type_structure, type_structures) \ - structures.used = structures.size; \ - while (structures.used) { \ - --structures.used; \ - f_memory_structure_resize(0, sizeof(type_structure), (void **) &structures.array[structures.used].array, &structures.array[structures.used].used, &structures.array[structures.used].size); \ - } \ - f_memory_structure_resize(0, sizeof(type_structures), (void **) & structures.array, &structures.used, &structures.size); -#endif // _di_macro_f_memory_structures_delete_simple_ - -/** - * Destroy a generic memory structures. - * - * structures: The structures to operate on. - * type_stucture: The structure type. - * type_stuctures: The structures type. - */ -#ifndef _di_macro_f_memory_structures_destroy_simple_ - #define macro_f_memory_structures_destroy_simple(structures, type_structure, type_structures) \ - structures.used = structures.size; \ - while (structures.used) { \ - --structures.used; \ - f_memory_structure_adjust(0, sizeof(type_structure), (void **) &structures.array[structures.used].array, &structures.array[structures.used].used, &structures.array[structures.used].size); \ - } \ - f_memory_structure_adjust(0, sizeof(type_structures), (void **) & structures.array, &structures.used, &structures.size); -#endif // _di_macro_f_memory_structures_destroy_simple_ - -/** - * Increase a generic memory structures by 1. - * - * This only increases if the structure.used + 1 is greater than structure.size. - * - * status: The status to return. - * structures: The structures to operate on. - * type_stuctures: The structures type. - * type_length: The data type of the length variable type. - */ -#ifndef _di_macro_f_memory_structures_increase_ - #define macro_f_memory_structures_increase(status, structures, type_structures, type_length) \ - status = f_memory_structure_increase(sizeof(type_structures), (void **) &structures.array, &structures.used, &structures.size); -#endif // _di_macro_f_memory_structures_increase_ - -/** - * Increase a generic memory structures by the given amount. - * - * This only increases if the structure.used + amount is greater than structure.size. - * - * status: The status to return. - * structures: The structures to operate on. - * type_stuctures: The structures type. - * type_length: The data type of the length variable type. - * amount: The amount to increase by. - */ -#ifndef _di_macro_f_memory_structures_increase_by_ - #define macro_f_memory_structures_increase_by(status, structures, type_structures, type_length, amount) \ - status = f_memory_structure_increase_by(amount, sizeof(type_structures), (void **) &structures.array, &structures.used, &structures.size); -#endif // _di_macro_f_memory_structures_increase_by_ - -/** - * Decrease a generic memory structures by the given amount. - * - * status: The status to return. - * structures: The structures to operate on. - * type_stucture: The structure type. - * type_stuctures: The structures type. - * type_length: The data type of the length variable type. - * amount: The amount to decrease by. - */ -#ifndef _di_macro_f_memory_structures_decrease_by_ - #define macro_f_memory_structures_decrease_by(status, structures, type_structure, type_structures, type_length, amount) \ - if (amount && structures.size) { \ - macro_f_memory_structures_resize(status, structures, type_structure, type_structures, (amount < structures.size ? structures.size - amount : 0), type_length); \ - } \ - status = f_memory_structure_decrease_by(amount, sizeof(type_structures), (void **) &structures.array, &structures.used, &structures.size); -#endif // _di_macro_f_memory_structures_decrease_by_ - -/** - * Decimate a generic memory structures by the given amount. - * - * status: The status to return. - * structures: The structures to operate on. - * type_stucture: The structure type. - * type_stuctures: The structures type. - * type_length: The data type of the length variable type. - * amount: The amount to decimate by. - */ -#ifndef _di_macro_f_memory_structures_decimate_by_ - #define macro_f_memory_structures_decimate_by(status, structures, type_structure, type_structures, type_length, amount) \ - if (amount && structures.size) { \ - macro_f_memory_structures_adjust(status, structures, type_structure, type_structures, (amount < structures.size ? structures.size - amount : 0), type_length); \ - } \ - status = f_memory_structure_decimate_by(amount, sizeof(type_structures), (void **) &structures.array, &structures.used, &structures.size); -#endif // _di_macro_f_memory_structures_decimate_by_ - -/** - * Provide a macro for calling other macros for incrementing a buffer. - * - * If the used + step is greater than size, then increase by step_default. - * If step_default exceeds F_number_t_size_unsigned_d, then attempt to increment by step. - * If step exceeds F_number_t_size_unsigned_d, set status to error_too_large. - * - * Be sure to check size for error after calling this. - * - * status: The status to return. - * structures: The structures to operate on. - * step: The step to increase by, must be less than or equal to step_default. - * step_default: The default step to increase by if memory allows. - * macro_resize: The resize structure macro to call that excepts the exact arguments: (status, structure, length). - * error_too_large: The error status to return when F_number_t_size_unsigned_d would be exceeded. - */ -#ifndef _di_macro_f_memory_structure_increment_ - #define macro_f_memory_structure_increment(status, structure, step, step_default, macro_resize, error_too_large) \ - if (structure.used + step > structure.size) { \ - if (structure.used + step_default > F_number_t_size_unsigned_d) { \ - if (structure.used + step > F_number_t_size_unsigned_d) { \ - status = F_status_set_error(error_too_large); \ - } \ - else { \ - macro_resize(status, structure, structure.used + step); \ - } \ - } \ - else { \ - macro_resize(status, structure, structure.size + step_default); \ - } \ - } -#endif // _di_macro_f_memory_structure_increment_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_0/f_memory/c/memory/structure.c b/level_0/f_memory/c/memory/structure.c deleted file mode 100644 index 9099b9a..0000000 --- a/level_0/f_memory/c/memory/structure.c +++ /dev/null @@ -1,117 +0,0 @@ -#include "../memory.h" -#include "../private-memory.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef _di_f_memory_structure_adjust_ - f_status_t f_memory_structure_adjust(const size_t length_new, const size_t type_size, void ** const structure, f_number_unsigned_t * const used, f_number_unsigned_t * const size) { - #ifndef _di_level_0_parameter_checking_ - if (!type_size) return F_status_set_error(F_parameter); - if (!structure) return F_status_set_error(F_parameter); - if (!used) return F_status_set_error(F_parameter); - if (!size) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - // Prevent double-frees and unnecessary frees. - if (!*structure && !length_new || *size == length_new) return F_data_not; - - return private_f_memory_structure_adjust(length_new, type_size, structure, used, size); - } -#endif // _di_f_memory_structure_adjust_ - -#ifndef _di_f_memory_structure_decimate_by_ - f_status_t f_memory_structure_decimate_by(const f_number_unsigned_t amount, const size_t type_size, void ** const structure, f_number_unsigned_t * const used, f_number_unsigned_t * const size) { - #ifndef _di_level_0_parameter_checking_ - if (!type_size) return F_status_set_error(F_parameter); - if (!structure) return F_status_set_error(F_parameter); - if (!used) return F_status_set_error(F_parameter); - if (!size) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (amount && *size) return private_f_memory_structure_adjust(amount <= *size ? *size - amount : 0, type_size, structure, used, size); - - return F_data_not; - } -#endif // _di_f_memory_structure_decimate_by_ - -#ifndef _di_f_memory_structure_decrease_by_ - f_status_t f_memory_structure_decrease_by(const f_number_unsigned_t amount, const size_t type_size, void ** const structure, f_number_unsigned_t * const used, f_number_unsigned_t * const size) { - #ifndef _di_level_0_parameter_checking_ - if (!type_size) return F_status_set_error(F_parameter); - if (!structure) return F_status_set_error(F_parameter); - if (!used) return F_status_set_error(F_parameter); - if (!size) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (amount && *size) return private_f_memory_structure_resize(amount <= *size ? *size - amount : 0, type_size, structure, used, size); - - return F_data_not; - } -#endif // _di_f_memory_structure_decrease_by_ - -#ifndef _di_f_memory_structure_increase_ - f_status_t f_memory_structure_increase(const f_number_unsigned_t step, const size_t type_size, void ** const structure, f_number_unsigned_t * const used, f_number_unsigned_t * const size) { - #ifndef _di_level_0_parameter_checking_ - if (!step) return F_status_set_error(F_parameter); - if (!type_size) return F_status_set_error(F_parameter); - if (!structure) return F_status_set_error(F_parameter); - if (!used) return F_status_set_error(F_parameter); - if (!size) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (*used + 1 > *size) { - f_number_unsigned_t length_new = *used + step; - - if (length_new > F_number_t_size_unsigned_d) { - if (*used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - - length_new = F_number_t_size_unsigned_d; - } - - return private_f_memory_structure_resize(length_new, type_size, structure, used, size); - } - - return F_data_not; - } -#endif // _di_f_memory_structure_increase_ - -#ifndef _di_f_memory_structure_increase_by_ - f_status_t f_memory_structure_increase_by(const f_number_unsigned_t amount, const size_t type_size, void ** const structure, f_number_unsigned_t * const used, f_number_unsigned_t * const size) { - #ifndef _di_level_0_parameter_checking_ - if (!type_size) return F_status_set_error(F_parameter); - if (!structure) return F_status_set_error(F_parameter); - if (!used) return F_status_set_error(F_parameter); - if (!size) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (amount && *used + amount > *size) { - if (*used + amount > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - - return private_f_memory_structure_resize(*used + amount, type_size, structure, used, size); - } - - return F_data_not; - } -#endif // _di_f_memory_structure_increase_by_ - -#ifndef _di_f_memory_structure_resize_ - f_status_t f_memory_structure_resize(const size_t length_new, const size_t type_size, void ** const structure, f_number_unsigned_t * const used, f_number_unsigned_t * const size) { - #ifndef _di_level_0_parameter_checking_ - if (!type_size) return F_status_set_error(F_parameter); - if (!structure) return F_status_set_error(F_parameter); - if (!used) return F_status_set_error(F_parameter); - if (!size) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - // Prevent double-frees and unnecessary frees. - if (!*structure && !length_new || *size == length_new) return F_data_not; - - return private_f_memory_structure_resize(length_new, type_size, structure, used, size); - } -#endif // _di_f_memory_structure_resize_ - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_memory/c/memory/structure.h b/level_0/f_memory/c/memory/structure.h deleted file mode 100644 index e4468ee..0000000 --- a/level_0/f_memory/c/memory/structure.h +++ /dev/null @@ -1,216 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Memory - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Defines memory structure data. - * - * This is auto-included by memory.h and should not need to be explicitly included. - */ -#ifndef _F_memory_structure_h -#define _F_memory_structure_h - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Resize the structure. - * - * Memory being deleted will be wiped. - * - * @param length_new - * The new size of the structure array. - * Setting a length of 0 will result in the deletion (freeing) of the structure. - * @param type_size - * The size of the structure type (such as: sizeof(structure_size)). - * Must be greater than 0. - * @param structure - * The structure to delete. - * @param used - * The amount of data used by the structure. - * @param size - * The amount of data allocated to the structure. - * - * @return - * F_none on success. - * - * F_memory_not (with error bit) on allocation error. - * - * @see calloc() - * @see free() - * @see memset() - */ -#ifndef _di_f_memory_structure_adjust_ - extern f_status_t f_memory_structure_adjust(const size_t length_new, const size_t type_size, void ** const structure, f_number_unsigned_t * const used, f_number_unsigned_t * const size); -#endif // _di_f_memory_structure_adjust_ - -/** - * Resize the structure to a smaller size, by the given amount. - * - * This will not shrink the size to less than 0. - * Memory being deleted will be wiped. - * - * @param amount - * A positive number representing how much to decimate the size by. - * @param type_size - * The size of the structure type (such as: sizeof(structure_size)). - * Must be greater than 0. - * @param structure - * The structure to delete. - * @param used - * The amount of data used by the structure. - * @param size - * The amount of data allocated to the structure. - * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to decimate size (amount = 0 or size = 0). - * - * F_memory_not (with error bit) on out of memory. - * - * @see calloc() - * @see free() - * @see memset() - */ -#ifndef _di_f_memory_structure_decimate_by_ - extern f_status_t f_memory_structure_decimate_by(const f_number_unsigned_t amount, const size_t type_size, void ** const structure, f_number_unsigned_t * const used, f_number_unsigned_t * const size); -#endif // _di_f_memory_structure_decimate_by_ - -/** - * Resize the structure to a smaller size, by the given amount. - * - * This will not shrink the size to less than 0. - * Memory being deleted will not be wiped. - * - * @param amount - * A positive number representing how much to decrease by. - * @param type_size - * The size of the structure type (such as: sizeof(structure_size)). - * Must be greater than 0. - * @param structure - * The structure to delete. - * @param used - * The amount of data used by the structure. - * @param size - * The amount of data allocated to the structure. - * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to decrease size (amount = 0 or size = 0). - * - * F_memory_not (with error bit) on allocation error. - * - * @see calloc() - * @see free() - * @see memset() - */ -#ifndef _di_f_memory_structure_decrease_by_ - extern f_status_t f_memory_structure_decrease_by(const f_number_unsigned_t amount, const size_t type_size, void ** const structure, f_number_unsigned_t * const used, f_number_unsigned_t * const size); -#endif // _di_f_memory_structure_decrease_by_ - -/** - * Increase the size of the structure, but only if necessary. - * - * If the given length is too large for the buffer, then attempt to set max buffer size (F_number_t_size_unsigned_d). - * If already set to the maximum buffer size, then the resize will fail. - * - * @param step - * The allocation step to use. - * Must be greater than 0. - * @param type_size - * The size of the structure type (such as: sizeof(structure_size)). - * Must be greater than 0. - * @param structure - * The structure to delete. - * @param used - * The amount of data used by the structure. - * @param size - * The amount of data allocated to the structure. - * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + 1 <= size). - * - * F_array_too_large (with error bit) if the new array length is too large. - * F_memory_not (with error bit) on allocation error. - * - * @see calloc() - * @see free() - * @see memset() - */ -#ifndef _di_f_memory_structure_increase_ - extern f_status_t f_memory_structure_increase(const f_number_unsigned_t step, const size_t type_size, void ** const structure, f_number_unsigned_t * const used, f_number_unsigned_t * const size); -#endif // _di_f_memory_structure_increase_ - -/** - * Resize the structure to a larger size. - * - * This will resize making the array larger based on the given length. - * If the given length is too large for the buffer, then attempt to set max buffer size (F_number_t_size_unsigned_d). - * If already set to the maximum buffer size, then the resize will fail. - * - * @param amount - * A positive number representing how much to increase the size by. - * @param type_size - * The size of the structure type (such as: sizeof(structure_size)). - * Must be greater than 0. - * @param structure - * The structure to delete. - * @param used - * The amount of data used by the structure. - * @param size - * The amount of data allocated to the structure. - * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (amount = 0 or used + 1 <= size). - * - * F_array_too_large (with error bit) if the new array length is too large. - * F_memory_not (with error bit) on allocation error. - * - * @see calloc() - * @see free() - * @see memset() - */ -#ifndef _di_f_memory_structure_increase_by_ - extern f_status_t f_memory_structure_increase_by(const f_number_unsigned_t amount, const size_t type_size, void ** const structure, f_number_unsigned_t * const used, f_number_unsigned_t * const size); -#endif // _di_f_memory_structure_increase_by_ - -/** - * Resize the structure. - * - * Memory being deleted will not be wiped. - * - * @param length_new - * The new size of the structure array. - * Setting a length of 0 will result in the deletion (freeing) of the structure. - * @param type_size - * The size of the structure type (such as: sizeof(structure_size)). - * @param structure - * The structure to delete. - * @param used - * The amount of data used by the structure. - * @param size - * The amount of data allocated to the structure. - * - * @return - * F_none on success. - * - * F_memory_not (with error bit) on allocation error. - * - * @see calloc() - * @see free() - * @see memset() - */ -#ifndef _di_f_memory_structure_resize_ - extern f_status_t f_memory_structure_resize(const size_t length_new, const size_t type_size, void ** const structure, f_number_unsigned_t * const used, f_number_unsigned_t * const size); -#endif // _di_f_memory_structure_resize_ - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _F_memory_structure_h diff --git a/level_0/f_memory/c/private-memory.c b/level_0/f_memory/c/private-memory.c index aed97c1..f48de2e 100644 --- a/level_0/f_memory/c/private-memory.c +++ b/level_0/f_memory/c/private-memory.c @@ -5,7 +5,7 @@ extern "C" { #endif -#if !defined(_di_f_memory_adjust_) || !defined(_di_f_memory_structure_adjust_) || !defined(_di_f_memory_structure_decimate_by_) +#if !defined(_di_f_memory_adjust_) || defined(_f_memory_FORCE_secure_memory_) f_status_t private_f_memory_adjust(const size_t length_old, const size_t length_new, const size_t type_size, void ** const pointer) { // When old length is 0 and the pointer is not NULL, then consider this pointer stale and reset it to NULL. @@ -58,9 +58,9 @@ extern "C" { return F_status_set_error(F_memory_not); } -#endif // !defined(_di_f_memory_adjust_) || !defined(_di_f_memory_structure_adjust_) || !defined(_di_f_memory_structure_decimate_by_) +#endif // !defined(_di_f_memory_adjust_) || defined(_f_memory_FORCE_secure_memory_) -#if !defined(_di_f_memory_resize_) || !defined(_di_memory_structure_decrease_by_) || !defined(_di_memory_structure_increase_) || !defined(_di_memory_structure_increase_by_) || !defined(_di_f_memory_structure_resize_) +#if !defined(_di_f_memory_resize_) || defined(_f_memory_FORCE_fast_memory_) f_status_t private_f_memory_resize(const size_t length_old, const size_t length_new, const size_t type_size, void ** const pointer) { // When old length is 0 and the pointer is not NULL, then consider this pointer stale and reset it to NULL. @@ -104,41 +104,7 @@ extern "C" { return F_status_set_error(F_memory_not); } -#endif // !defined(_di_f_memory_resize_) || !defined(_di_memory_structure_decrease_by_) || !defined(_di_memory_structure_increase_) || !defined(_di_memory_structure_increase_by_) || !defined(_di_f_memory_structure_resize_) - -#if !defined(_di_f_memory_structure_adjust_) || !defined(_di_f_memory_structure_decimate_by_) - f_status_t private_f_memory_structure_adjust(const size_t length_new, const size_t type_size, void ** const structure, f_number_unsigned_t * const used, f_number_unsigned_t * const size) { - - const f_status_t status = private_f_memory_adjust(*size, length_new, type_size, structure); - - if (F_status_is_error_not(status)) { - *size = length_new; - - if (*used > *size) { - *used = *size; - } - } - - return status; - } -#endif // !defined(_di_f_memory_structure_adjust_) || !defined(_di_f_memory_structure_decimate_by_) - -#if !defined(_di_memory_structure_decrease_by_) || !defined(_di_memory_structure_increase_) || !defined(_di_memory_structure_increase_by_) || !defined(_di_f_memory_structure_resize_) - f_status_t private_f_memory_structure_resize(const size_t length_new, const size_t type_size, void ** const structure, f_number_unsigned_t * const used, f_number_unsigned_t * const size) { - - const f_status_t status = private_f_memory_resize(*size, length_new, type_size, structure); - - if (F_status_is_error_not(status)) { - *size = length_new; - - if (*used > *size) { - *used = *size; - } - } - - return status; - } -#endif // !defined(_di_memory_structure_decrease_by_) || !defined(_di_memory_structure_increase_) || !defined(_di_memory_structure_increase_by_) || !defined(_di_f_memory_structure_resize_) +#endif // !!defined(_di_f_memory_resize_) || defined(_f_memory_FORCE_fast_memory_) #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_memory/c/private-memory.h b/level_0/f_memory/c/private-memory.h index e523810..1ffabaa 100644 --- a/level_0/f_memory/c/private-memory.h +++ b/level_0/f_memory/c/private-memory.h @@ -42,12 +42,11 @@ extern "C" { * @see memset() * * @see f_memory_adjust() - * @see f_memory_structure_adjust() - * @see f_memory_structure_decimate_by() + * @see f_memory_resize() */ -#if !defined(_di_f_memory_adjust_) || !defined(_di_f_memory_structure_adjust_) || !defined(_di_f_memory_structure_decimate_by_) +#if !defined(_di_f_memory_adjust_) || defined(_f_memory_FORCE_secure_memory_) extern f_status_t private_f_memory_adjust(const size_t length_old, const size_t length_new, const size_t type_size, void ** const pointer) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_memory_adjust_) || !defined(_di_f_memory_structure_adjust_) || !defined(_di_f_memory_structure_decimate_by_) +#endif // !defined(_di_f_memory_adjust_) || defined(_f_memory_FORCE_secure_memory_) /** * Private implementation for resizing. @@ -75,81 +74,12 @@ extern "C" { * @see free() * @see memset() * + * @see f_memory_adjust() * @see f_memory_resize() - * @see f_memory_structure_decrease_by() - * @see f_memory_structure_increase() - * @see f_memory_structure_increase_by() - * @see f_memory_structure_resize() - * - * @see private_f_memory_structure_resize() */ -#if !defined(_di_f_memory_resize_) || !defined(_di_memory_structure_decrease_by_) || !defined(_di_memory_structure_increase_) || !defined(_di_memory_structure_increase_by_) || !defined(_di_f_memory_structure_resize_) +#if !defined(_di_f_memory_resize_) || defined(_f_memory_FORCE_fast_memory_) extern f_status_t private_f_memory_resize(const size_t length_old, const size_t length_new, const size_t type_size, void ** const pointer) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_memory_resize_) || !defined(_di_memory_structure_decrease_by_) || !defined(_di_memory_structure_increase_) || !defined(_di_memory_structure_increase_by_) || !defined(_di_f_memory_structure_resize_) - -/** - * Private implementation for resizing a structure. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length_new - * The new size of the structure array. - * Setting a length of 0 will result in the deletion (freeing) of the structure. - * @param type_size - * The size of the structure type (such as: sizeof(structure_size)). - * @param structure - * The structure to delete. - * @param used - * The amount of data used by the structure. - * @param size - * The amount of data allocated to the structure. - * - * @return - * Return from: private_f_memory_adjust(). - * - * Errors (with error bit) from: private_f_memory_adjust(). - * - * @see f_memory_structure_adjust() - * @see f_memory_structure_decimate_by() - * - * @see private_f_memory_adjust() - */ -#if !defined(_di_f_memory_structure_adjust_) || !defined(_di_f_memory_structure_decimate_by_) - extern f_status_t private_f_memory_structure_adjust(const size_t length_new, const size_t type_size, void ** const structure, f_number_unsigned_t * const used, f_number_unsigned_t * const size) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_memory_structure_adjust_) || !defined(_di_f_memory_structure_decimate_by_) - -/** - * Private implementation for resizing a structure. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length_new - * The new size of the structure array. - * Setting a length of 0 will result in the deletion (freeing) of the structure. - * @param type_size - * The size of the structure type (such as: sizeof(structure_size)). - * @param structure - * The structure to delete. - * @param used - * The amount of data used by the structure. - * @param size - * The amount of data allocated to the structure. - * - * @return - * Return from: private_f_memory_resize(). - * - * Errors (with error bit) from: private_f_memory_structure_resize(). - * - * @see f_memory_structure_decrease_by() - * @see f_memory_structure_increase() - * @see f_memory_structure_increase_by() - * @see f_memory_structure_resize() - * - * @see private_f_memory_resize() - */ -#if !defined(_di_memory_structure_decrease_by_) || !defined(_di_memory_structure_increase_) || !defined(_di_memory_structure_increase_by_) || !defined(_di_f_memory_structure_resize_) - extern f_status_t private_f_memory_structure_resize(const size_t length_new, const size_t type_size, void ** const structure, f_number_unsigned_t * const used, f_number_unsigned_t * const size) F_attribute_visibility_internal_d; -#endif // !defined(_di_memory_structure_decrease_by_) || !defined(_di_memory_structure_increase_) || !defined(_di_memory_structure_increase_by_) || !defined(_di_f_memory_structure_resize_) +#endif // !defined(_di_f_memory_resize_) || defined(_f_memory_FORCE_fast_memory_) #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_memory/data/build/settings b/level_0/f_memory/data/build/settings index 55426ad..e073e53 100644 --- a/level_0/f_memory/data/build/settings +++ b/level_0/f_memory/data/build/settings @@ -31,10 +31,10 @@ build_language c build_libraries -lc -build_sources_library memory.c memory/array.c memory/structure.c +build_sources_library memory.c memory/array.c build_sources_library private-memory.c memory/private-array.c -build_sources_headers memory.h memory/array.h memory/common.h memory/structure.h +build_sources_headers memory.h memory/array.h memory/common.h build_script yes build_shared yes diff --git a/level_0/f_memory/tests/unit/c/test-memory-array_increase.c b/level_0/f_memory/tests/unit/c/test-memory-array_increase.c index 777124b..924016f 100644 --- a/level_0/f_memory/tests/unit/c/test-memory-array_increase.c +++ b/level_0/f_memory/tests/unit/c/test-memory-array_increase.c @@ -49,11 +49,13 @@ void test__f_memory_array_increase__returns_array_too_large(void **state) { const f_number_unsigned_t length = F_number_t_size_unsigned_d + 1; test_memory_array_t data = test_memory_array_t_initialize; + data.used = F_number_t_size_unsigned_d; + { const f_status_t status = f_memory_array_increase(length, sizeof(int), (void **) &data.array, &data.used, &data.size); assert_int_equal(status, F_status_set_error(F_array_too_large)); - assert_int_equal(data.used, 0); + assert_int_equal(data.used, F_number_t_size_unsigned_d); assert_int_equal(data.size, 0); } } diff --git a/level_0/f_string/c/string/dynamics.c b/level_0/f_string/c/string/dynamics.c index a06e2b4..c3a399d 100644 --- a/level_0/f_string/c/string/dynamics.c +++ b/level_0/f_string/c/string/dynamics.c @@ -105,12 +105,16 @@ extern "C" { if (!dynamics) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (dynamics->used + amount > dynamics->size) { - if (dynamics->used + amount > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + if (amount) { + if (dynamics->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + + const f_number_unsigned_t length = dynamics->used + amount; - return private_f_string_dynamics_resize(dynamics->used + amount, dynamics); + if (length > dynamics->size) { + if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + + return private_f_string_dynamics_resize(dynamics->used + amount, dynamics); + } } return F_data_not; diff --git a/level_0/f_string/c/string/dynamicss.c b/level_0/f_string/c/string/dynamicss.c index 4b881f6..3bd0565 100644 --- a/level_0/f_string/c/string/dynamicss.c +++ b/level_0/f_string/c/string/dynamicss.c @@ -139,14 +139,16 @@ extern "C" { if (!dynamicss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; + if (amount) { + if (dynamicss->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - if (dynamicss->used + amount > dynamicss->size) { - if (dynamicss->used + amount > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + const f_number_unsigned_t length = dynamicss->used + amount; - return private_f_string_dynamicss_resize(dynamicss->used + amount, dynamicss); + if (length > dynamicss->size) { + if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + + return private_f_string_dynamicss_resize(dynamicss->used + amount, dynamicss); + } } return F_data_not; diff --git a/level_0/f_string/c/string/map_multis.c b/level_0/f_string/c/string/map_multis.c index 2f3a4dd..4e54d41 100644 --- a/level_0/f_string/c/string/map_multis.c +++ b/level_0/f_string/c/string/map_multis.c @@ -124,14 +124,16 @@ extern "C" { if (!map_multis) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; + if (amount) { + if (map_multis->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - if (map_multis->used + amount > map_multis->size) { - if (map_multis->used + amount > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + const f_number_unsigned_t length = map_multis->used + amount; - return private_f_string_map_multis_resize(map_multis->used + amount, map_multis); + if (length > map_multis->size) { + if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + + return private_f_string_map_multis_resize(length, map_multis); + } } return F_data_not; diff --git a/level_0/f_string/c/string/map_multis.h b/level_0/f_string/c/string/map_multis.h index bd99ea8..4fde6a5 100644 --- a/level_0/f_string/c/string/map_multis.h +++ b/level_0/f_string/c/string/map_multis.h @@ -37,8 +37,6 @@ extern "C" { #define macro_f_string_map_multis_t_initialize_1(array, size, used) { array, size, used } #define macro_f_string_map_multis_t_initialize_2(array, length) { array, length, length } - #define macro_f_string_map_multis_t_clear(map_multis) macro_f_memory_structure_clear(map_multis) - #define macro_f_string_map_multis_t_resize(status, map_multis, length) status = f_string_map_multis_resize(length, &map_multis); #define macro_f_string_map_multis_t_adjust(status, map_multis, length) status = f_string_map_multis_adjust(length, &map_multis); diff --git a/level_0/f_string/c/string/map_multiss.c b/level_0/f_string/c/string/map_multiss.c index 2297175..e269af6 100644 --- a/level_0/f_string/c/string/map_multiss.c +++ b/level_0/f_string/c/string/map_multiss.c @@ -138,14 +138,16 @@ extern "C" { if (!map_multiss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; + if (amount) { + if (map_multiss->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - if (map_multiss->used + amount > map_multiss->size) { - if (map_multiss->used + amount > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + const f_number_unsigned_t length = map_multiss->used + amount; - return private_f_string_map_multiss_resize(map_multiss->used + amount, map_multiss); + if (length > map_multiss->size) { + if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + + return private_f_string_map_multiss_resize(length, map_multiss); + } } return F_data_not; diff --git a/level_0/f_string/c/string/map_multiss.h b/level_0/f_string/c/string/map_multiss.h index de2b733..9ebd77d 100644 --- a/level_0/f_string/c/string/map_multiss.h +++ b/level_0/f_string/c/string/map_multiss.h @@ -37,8 +37,6 @@ extern "C" { #define macro_f_string_map_multiss_t_initialize_1(array, size, used) { array, size, used } #define macro_f_string_map_multiss_t_initialize_2(array, length) { array, length, length } - #define macro_f_string_map_multiss_t_clear(map_multis) macro_f_memory_structure_clear(map_multis) - #define macro_f_string_map_multiss_t_resize(status, map_multis, length) status = f_string_map_multiss_resize(length, &map_multis); #define macro_f_string_map_multiss_t_adjust(status, map_multis, length) status = f_string_map_multiss_adjust(length, &map_multis); diff --git a/level_0/f_string/c/string/maps.c b/level_0/f_string/c/string/maps.c index dac763d..93324e8 100644 --- a/level_0/f_string/c/string/maps.c +++ b/level_0/f_string/c/string/maps.c @@ -122,14 +122,16 @@ extern "C" { if (!maps) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; + if (amount) { + if (maps->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - if (maps->used + amount > maps->size) { - if (maps->used + amount > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + const f_number_unsigned_t length = maps->used + amount; - return private_f_string_maps_resize(maps->used + amount, maps); + if (length > maps->size) { + if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + + return private_f_string_maps_resize(length, maps); + } } return F_data_not; diff --git a/level_0/f_string/c/string/maps.h b/level_0/f_string/c/string/maps.h index 36f7c13..c8dc1fd 100644 --- a/level_0/f_string/c/string/maps.h +++ b/level_0/f_string/c/string/maps.h @@ -37,8 +37,6 @@ extern "C" { #define macro_f_string_maps_t_initialize_1(array, size, used) { array, size, used } #define macro_f_string_maps_t_initialize_2(array, length) { array, length, length } - #define macro_f_string_maps_t_clear(maps) macro_f_memory_structure_clear(maps) - #define macro_f_string_maps_t_resize(status, maps, length) status = f_string_maps_resize(length, &maps); #define macro_f_string_maps_t_adjust(status, maps, length) status = f_string_maps_adjust(length, &maps); diff --git a/level_0/f_string/c/string/mapss.c b/level_0/f_string/c/string/mapss.c index ae3d40f..ddd3824 100644 --- a/level_0/f_string/c/string/mapss.c +++ b/level_0/f_string/c/string/mapss.c @@ -136,14 +136,16 @@ extern "C" { if (!mapss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; + if (amount) { + if (mapss->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - if (mapss->used + amount > mapss->size) { - if (mapss->used + amount > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + const f_number_unsigned_t length = mapss->used + amount; - return private_f_string_mapss_resize(mapss->used + amount, mapss); + if (length > mapss->size) { + if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + + return private_f_string_mapss_resize(length, mapss); + } } return F_data_not; diff --git a/level_0/f_string/c/string/mapss.h b/level_0/f_string/c/string/mapss.h index 45378e1..563bf47 100644 --- a/level_0/f_string/c/string/mapss.h +++ b/level_0/f_string/c/string/mapss.h @@ -37,8 +37,6 @@ extern "C" { #define macro_f_string_mapss_t_initialize_1(array, size, used) { array, size, used } #define macro_f_string_mapss_t_initialize_2(array, length) { array, length, length } - #define macro_f_string_mapss_t_clear(maps) macro_f_memory_structure_clear(maps) - #define macro_f_string_mapss_t_resize(status, maps, length) status = f_string_mapss_resize(length, &maps); #define macro_f_string_mapss_t_adjust(status, maps, length) status = f_string_mapss_adjust(length, &maps); diff --git a/level_0/f_string/c/string/private-dynamic.c b/level_0/f_string/c/string/private-dynamic.c index f2542fd..7bb7cbf 100644 --- a/level_0/f_string/c/string/private-dynamic.c +++ b/level_0/f_string/c/string/private-dynamic.c @@ -25,12 +25,12 @@ extern "C" { #if !defined(_di_f_string_append_) || !defined(_di_f_string_append_assure_) || !defined(_di_f_string_append_mash_) || !defined(_di_f_string_append_nulless_) || !defined(_di_f_string_dynamic_append_) || !defined(_di_f_string_dynamic_append_assure_) || !defined(_di_f_string_dynamic_append_nulless_) || !defined(_di_f_string_dynamic_increase_by_) || !defined(_di_f_string_dynamic_mash_) || !defined(_di_f_string_dynamic_mash_nulless_) || !defined(_di_f_string_dynamic_partial_append_) || !defined(_di_f_string_dynamic_partial_append_assure_) || !defined(_di_f_string_dynamic_partial_mash_) || !defined(_di_f_string_dynamic_prepend_) || !defined(_di_f_string_dynamic_prepend_nulless_) || !defined(_di_f_string_dynamics_append_) || !defined(_di_f_string_map_multis_append_) || !defined(_di_f_string_mash_) || !defined(_di_f_string_mash_nulless_) || !defined(_di_f_string_maps_append_) || !defined(_di_f_string_prepend_) || !defined(_di_f_string_prepend_nulless_) || !defined(_di_f_string_triples_append_) f_status_t private_f_string_dynamic_increase_by(const f_number_unsigned_t amount, f_string_dynamic_t * const dynamic) { - if (dynamic->used + amount > dynamic->size) { - if (dynamic->used + amount > F_string_t_size_d) { - return F_status_set_error(F_string_too_large); - } + const f_number_unsigned_t length = dynamic->used + amount; - return private_f_string_dynamic_resize(dynamic->used + amount, dynamic); + if (length > dynamic->size) { + if (length > F_string_t_size_d) return F_status_set_error(F_string_too_large); + + return private_f_string_dynamic_resize(length, dynamic); } return F_data_not; diff --git a/level_0/f_string/c/string/private-dynamics.c b/level_0/f_string/c/string/private-dynamics.c index 26552fc..f0c0659 100644 --- a/level_0/f_string/c/string/private-dynamics.c +++ b/level_0/f_string/c/string/private-dynamics.c @@ -10,7 +10,7 @@ extern "C" { #if !defined(_di_f_string_dynamics_adjust_) || !defined(_di_f_string_dynamics_append_) || !defined(_di_f_string_dynamics_decimate_by_) || !defined(_di_f_string_map_multis_adjust_) || !defined(_di_f_string_map_multis_append_) f_status_t private_f_string_dynamics_adjust(const f_number_unsigned_t length, f_string_dynamics_t * const dynamics) { - if (dynamics->used + length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); f_status_t status = F_none; @@ -83,7 +83,7 @@ extern "C" { #if !defined(_di_f_string_dynamics_decrease_by_) || !defined(_di_f_string_dynamics_increase_) || !defined(_di_f_string_dynamics_increase_by_) || !defined(f_string_dynamics_resize) || !defined(_di_f_string_map_multis_append_) || !defined(_di_f_string_map_multis_append_all_) || !defined(_di_f_string_map_multis_decrease_by_) || !defined(_di_f_string_map_multis_increase_) || !defined(_di_f_string_map_multis_increase_by_) || !defined(_di_f_string_map_multis_resize_) || !defined(_di_f_string_map_multiss_append_) || !defined(_di_f_string_map_multiss_append_all_) || !defined(_di_f_string_map_multiss_decrease_by_) || !defined(_di_f_string_map_multiss_increase_) || !defined(_di_f_string_map_multiss_increase_by_) f_status_t private_f_string_dynamics_resize(const f_number_unsigned_t length, f_string_dynamics_t * const dynamics) { - if (dynamics->used + length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); f_status_t status = F_none; diff --git a/level_0/f_string/c/string/private-dynamicss.c b/level_0/f_string/c/string/private-dynamicss.c index e36b7bb..76374c9 100644 --- a/level_0/f_string/c/string/private-dynamicss.c +++ b/level_0/f_string/c/string/private-dynamicss.c @@ -11,7 +11,7 @@ extern "C" { #if !defined(_di_f_string_dynamicss_adjust_) || !defined(_di_f_string_dynamicss_append_) || !defined(_di_f_string_dynamicss_decimate_by_) || !defined(_di_f_string_map_multis_adjust_) || !defined(_di_f_string_map_multis_append_) f_status_t private_f_string_dynamicss_adjust(const f_number_unsigned_t length, f_string_dynamicss_t * const dynamicss) { - if (dynamicss->used + length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); f_status_t status = F_none; @@ -37,7 +37,7 @@ extern "C" { #if !defined(_di_f_string_dynamicss_decrease_by_) || !defined(_di_f_string_dynamicss_increase_) || !defined(_di_f_string_dynamicss_increase_by_) || !defined(_di_f_string_dynamicss_append_all_) || !defined(_di_f_string_map_multis_append_all_) f_status_t private_f_string_dynamicss_resize(const f_number_unsigned_t length, f_string_dynamicss_t * const dynamicss) { - if (dynamicss->used + length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); f_status_t status = F_none; diff --git a/level_0/f_string/c/string/quantitys.c b/level_0/f_string/c/string/quantitys.c index a802050..0c9289e 100644 --- a/level_0/f_string/c/string/quantitys.c +++ b/level_0/f_string/c/string/quantitys.c @@ -108,14 +108,16 @@ extern "C" { if (!quantitys) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; + if (amount) { + if (quantitys->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - if (quantitys->used + amount > quantitys->size) { - if (quantitys->used + amount > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + const f_number_unsigned_t length = quantitys->used + amount; - return private_f_string_quantitys_resize(quantitys->used + amount, quantitys); + if (length > quantitys->size) { + if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + + return private_f_string_quantitys_resize(length, quantitys); + } } return F_data_not; diff --git a/level_0/f_string/c/string/quantitys.h b/level_0/f_string/c/string/quantitys.h index b7fe955..d717b72 100644 --- a/level_0/f_string/c/string/quantitys.h +++ b/level_0/f_string/c/string/quantitys.h @@ -37,8 +37,6 @@ extern "C" { #define macro_f_string_quantitys_t_initialize_1(array, size, used) { array, size, used } #define macro_f_string_quantitys_t_initialize_2(array, length) { array, length, length } - #define macro_f_string_quantitys_t_clear(quantitys) macro_f_memory_structure_clear(quantitys) - #define macro_f_string_quantitys_t_resize(status, quantitys, length) status = f_string_quantitys_resize(length, &quantitys); #define macro_f_string_quantitys_t_adjust(status, quantitys, length) status = f_string_quantitys_adjust(length, &quantitys); diff --git a/level_0/f_string/c/string/quantityss.c b/level_0/f_string/c/string/quantityss.c index 31137d5..261acb2 100644 --- a/level_0/f_string/c/string/quantityss.c +++ b/level_0/f_string/c/string/quantityss.c @@ -136,14 +136,16 @@ extern "C" { if (!quantityss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; + if (amount) { + if (quantityss->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - if (quantityss->used + amount > quantityss->size) { - if (quantityss->used + amount > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + const f_number_unsigned_t length = quantityss->used + amount; - return private_f_string_quantityss_resize(quantityss->used + amount, quantityss); + if (length > quantityss->size) { + if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + + return private_f_string_quantityss_resize(length, quantityss); + } } return F_data_not; diff --git a/level_0/f_string/c/string/ranges.c b/level_0/f_string/c/string/ranges.c index 37be263..19678ca 100644 --- a/level_0/f_string/c/string/ranges.c +++ b/level_0/f_string/c/string/ranges.c @@ -119,14 +119,16 @@ extern "C" { if (!ranges) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; + if (amount) { + if (ranges->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - if (ranges->used + amount > ranges->size) { - if (ranges->used + amount > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + const f_number_unsigned_t length = ranges->used + amount; - return private_f_string_ranges_resize(ranges->used + amount, ranges); + if (length > ranges->size) { + if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + + return private_f_string_ranges_resize(length, ranges); + } } return F_data_not; diff --git a/level_0/f_string/c/string/ranges.h b/level_0/f_string/c/string/ranges.h index de3c0e9..47640ad 100644 --- a/level_0/f_string/c/string/ranges.h +++ b/level_0/f_string/c/string/ranges.h @@ -37,8 +37,6 @@ extern "C" { #define macro_f_string_ranges_t_initialize_1(array, size, used) { array, size, used } #define macro_f_string_ranges_t_initialize_2(array, length) { array, length, length } - #define macro_f_string_ranges_t_clear(ranges) macro_f_memory_structure_clear(ranges) - #define macro_f_string_ranges_t_resize(status, ranges, length) status = f_string_ranges_resize(length, &ranges); #define macro_f_string_ranges_t_adjust(status, ranges, length) status = f_string_ranges_adjust(length, &ranges); diff --git a/level_0/f_string/c/string/rangess.c b/level_0/f_string/c/string/rangess.c index 22c7762..026da0b 100644 --- a/level_0/f_string/c/string/rangess.c +++ b/level_0/f_string/c/string/rangess.c @@ -136,14 +136,16 @@ extern "C" { if (!rangess) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; + if (amount) { + if (rangess->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - if (rangess->used + amount > rangess->size) { - if (rangess->used + amount > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + const f_number_unsigned_t length = rangess->used + amount; - return private_f_string_rangess_resize(rangess->used + amount, rangess); + if (length > rangess->size) { + if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + + return private_f_string_rangess_resize(length, rangess); + } } return F_data_not; diff --git a/level_0/f_string/c/string/triples.c b/level_0/f_string/c/string/triples.c index a63a20b..c65e00b 100644 --- a/level_0/f_string/c/string/triples.c +++ b/level_0/f_string/c/string/triples.c @@ -155,14 +155,16 @@ extern "C" { if (!triples) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; + if (amount) { + if (triples->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - if (triples->used + amount > triples->size) { - if (triples->used + amount > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + const f_number_unsigned_t length = triples->used + amount; - return private_f_string_triples_resize(triples->used + amount, triples); + if (length > triples->size) { + if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + + return private_f_string_triples_resize(length, triples); + } } return F_data_not; diff --git a/level_0/f_string/c/string/triples.h b/level_0/f_string/c/string/triples.h index 9cfb7af..c5a3a0c 100644 --- a/level_0/f_string/c/string/triples.h +++ b/level_0/f_string/c/string/triples.h @@ -37,8 +37,6 @@ extern "C" { #define macro_f_string_triples_t_initialize_1(array, size, used) { array, size, used } #define macro_f_string_triples_t_initialize_2(array, length) { array, length, length } - #define macro_f_string_triples_t_clear(triples) macro_f_memory_structure_clear(triples) - #define macro_f_string_triples_t_resize(status, triples, length) status = f_string_triples_resize(length, &triples); #define macro_f_string_triples_t_adjust(status, triples, length) status = f_string_triples_adjust(length, &triples); diff --git a/level_0/f_string/c/string/tripless.c b/level_0/f_string/c/string/tripless.c index 542361a..d1cee99 100644 --- a/level_0/f_string/c/string/tripless.c +++ b/level_0/f_string/c/string/tripless.c @@ -136,14 +136,16 @@ extern "C" { if (!tripless) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; + if (amount) { + if (tripless->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - if (tripless->used + amount > tripless->size) { - if (tripless->used + amount > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + const f_number_unsigned_t length = tripless->used + amount; - return private_f_string_tripless_resize(tripless->used + amount, tripless); + if (length > tripless->size) { + if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + + return private_f_string_tripless_resize(length, tripless); + } } return F_data_not; diff --git a/level_0/f_string/c/string/tripless.h b/level_0/f_string/c/string/tripless.h index 4f5ca5d..c2f6a9d 100644 --- a/level_0/f_string/c/string/tripless.h +++ b/level_0/f_string/c/string/tripless.h @@ -37,8 +37,6 @@ extern "C" { #define macro_f_string_tripless_t_initialize_1(array, size, used) { array, size, used } #define macro_f_string_tripless_t_initialize_2(array, length) { array, length, length } - #define macro_f_string_tripless_t_clear(tripless) macro_f_memory_structure_clear(tripless) - #define macro_f_string_tripless_t_resize(status, tripless, length) status = f_string_tripless_resize(length, &tripless); #define macro_f_string_tripless_t_adjust(status, tripless, length) status = f_string_tripless_adjust(length, &tripless); diff --git a/level_0/f_thread/c/thread/attribute.c b/level_0/f_thread/c/thread/attribute.c index df1dadc..c31f367 100644 --- a/level_0/f_thread/c/thread/attribute.c +++ b/level_0/f_thread/c/thread/attribute.c @@ -78,14 +78,16 @@ extern "C" { if (!attributes) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; + if (amount) { + if (attributes->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - if (attributes->used + amount > attributes->size) { - if (attributes->used + amount > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + const f_number_unsigned_t length = attributes->used + amount; - return private_f_thread_attributes_resize(attributes->used + amount, attributes); + if (length > attributes->size) { + if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + + return private_f_thread_attributes_resize(length, attributes); + } } return F_data_not; diff --git a/level_0/f_thread/c/thread/attribute.h b/level_0/f_thread/c/thread/attribute.h index f1b3586..64f47d7 100644 --- a/level_0/f_thread/c/thread/attribute.h +++ b/level_0/f_thread/c/thread/attribute.h @@ -53,8 +53,6 @@ extern "C" { #define macro_f_thread_attributes_t_initialize_1(array, size, used) { array, size, used } #define macro_f_thread_attributes_t_initialize_2(array, length) { array, length, length } - #define macro_f_thread_attributes_t_clear(attributes) macro_f_memory_structure_clear(attributes) - #define macro_f_thread_attributes_t_resize(status, attributes, length) status = f_thread_attributes_resize(length, &attributes); #define macro_f_thread_attributes_t_adjust(status, attributes, length) status = f_thread_attributes_adjust(length, &attributes); diff --git a/level_0/f_thread/c/thread/barrier.c b/level_0/f_thread/c/thread/barrier.c index c2aa4b8..cbae0f3 100644 --- a/level_0/f_thread/c/thread/barrier.c +++ b/level_0/f_thread/c/thread/barrier.c @@ -78,14 +78,16 @@ extern "C" { if (!barriers) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; + if (amount) { + if (barriers->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - if (barriers->used + amount > barriers->size) { - if (barriers->used + amount > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + const f_number_unsigned_t length = barriers->used + amount; - return private_f_thread_barriers_resize(barriers->used + amount, barriers); + if (length > barriers->size) { + if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + + return private_f_thread_barriers_resize(barriers->used + amount, barriers); + } } return F_data_not; diff --git a/level_0/f_thread/c/thread/barrier.h b/level_0/f_thread/c/thread/barrier.h index af2e66c..cdf9fd3 100644 --- a/level_0/f_thread/c/thread/barrier.h +++ b/level_0/f_thread/c/thread/barrier.h @@ -52,8 +52,6 @@ extern "C" { #define macro_f_thread_barriers_t_initialize_1(array, size, used) { array, size, used } #define macro_f_thread_barriers_t_initialize_2(array, length) { array, length, length } - #define macro_f_thread_barriers_t_clear(barriers) macro_f_memory_structure_clear(barriers) - #define macro_f_thread_barriers_t_resize(status, barriers, length) status = f_thread_barriers_resize(length, &barriers); #define macro_f_thread_barriers_t_adjust(status, barriers, length) status = f_thread_barriers_adjust(length, &barriers); diff --git a/level_0/f_thread/c/thread/barrier_attribute.c b/level_0/f_thread/c/thread/barrier_attribute.c index 2f9a151..467a8b9 100644 --- a/level_0/f_thread/c/thread/barrier_attribute.c +++ b/level_0/f_thread/c/thread/barrier_attribute.c @@ -78,14 +78,16 @@ extern "C" { if (!attributes) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; + if (amount) { + if (attributes->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - if (attributes->used + amount > attributes->size) { - if (attributes->used + amount > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + const f_number_unsigned_t length = attributes->used + amount; - return private_f_thread_barrier_attributes_resize(attributes->used + amount, attributes); + if (length > attributes->size) { + if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + + return private_f_thread_barrier_attributes_resize(attributes->used + amount, attributes); + } } return F_data_not; diff --git a/level_0/f_thread/c/thread/barrier_attribute.h b/level_0/f_thread/c/thread/barrier_attribute.h index faecf6f..8a53e8e 100644 --- a/level_0/f_thread/c/thread/barrier_attribute.h +++ b/level_0/f_thread/c/thread/barrier_attribute.h @@ -53,8 +53,6 @@ extern "C" { #define macro_f_thread_barrier_attributes_t_initialize_1(array, size, used) { array, size, used } #define macro_f_thread_barrier_attributes_t_initialize_2(array, length) { array, length, length } - #define macro_f_thread_barrier_attributes_t_clear(barrier_attributes) macro_f_memory_structure_clear(barrier_attributes) - #define macro_f_thread_barrier_attributes_t_resize(status, barrier_attributes, length) status = f_thread_barrier_attributes_resize(length, &barrier_attributes); #define macro_f_thread_barrier_attributes_t_adjust(status, barrier_attributes, length) status = f_thread_barrier_attributes_adjust(length, &barrier_attributes); diff --git a/level_0/f_thread/c/thread/condition.c b/level_0/f_thread/c/thread/condition.c index 5600e65..3087bed 100644 --- a/level_0/f_thread/c/thread/condition.c +++ b/level_0/f_thread/c/thread/condition.c @@ -78,14 +78,16 @@ extern "C" { if (!conditions) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; + if (amount) { + if (conditions->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - if (conditions->used + amount > conditions->size) { - if (conditions->used + amount > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + const f_number_unsigned_t length = conditions->used + amount; - return private_f_thread_conditions_resize(conditions->used + amount, conditions); + if (length > conditions->size) { + if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + + return private_f_thread_conditions_resize(conditions->used + amount, conditions); + } } return F_data_not; diff --git a/level_0/f_thread/c/thread/condition.h b/level_0/f_thread/c/thread/condition.h index 457f9e6..b7bee62 100644 --- a/level_0/f_thread/c/thread/condition.h +++ b/level_0/f_thread/c/thread/condition.h @@ -53,8 +53,6 @@ extern "C" { #define macro_f_thread_conditions_t_initialize_1(array, size, used) { array, size, used } #define macro_f_thread_conditions_t_initialize_2(array, length) { array, length, length } - #define macro_f_thread_conditions_t_clear(conditions) macro_f_memory_structure_clear(conditions) - #define macro_f_thread_conditions_t_resize(status, conditions, length) status = f_thread_conditions_resize(length, &conditions); #define macro_f_thread_conditions_t_adjust(status, conditions, length) status = f_thread_conditions_adjust(length, &conditions); diff --git a/level_0/f_thread/c/thread/condition_attribute.c b/level_0/f_thread/c/thread/condition_attribute.c index e6277d9..2e01272 100644 --- a/level_0/f_thread/c/thread/condition_attribute.c +++ b/level_0/f_thread/c/thread/condition_attribute.c @@ -78,14 +78,16 @@ extern "C" { if (!attributes) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; + if (amount) { + if (attributes->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - if (attributes->used + amount > attributes->size) { - if (attributes->used + amount > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + const f_number_unsigned_t length = attributes->used + amount; - return private_f_thread_condition_attributes_resize(attributes->used + amount, attributes); + if (length > attributes->size) { + if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + + return private_f_thread_condition_attributes_resize(attributes->used + amount, attributes); + } } return F_data_not; diff --git a/level_0/f_thread/c/thread/condition_attribute.h b/level_0/f_thread/c/thread/condition_attribute.h index 79e7b04..f25bef8 100644 --- a/level_0/f_thread/c/thread/condition_attribute.h +++ b/level_0/f_thread/c/thread/condition_attribute.h @@ -53,8 +53,6 @@ extern "C" { #define macro_f_thread_condition_attributes_t_initialize_1(array, size, used) { array, size, used } #define macro_f_thread_condition_attributes_t_initialize_2(array, length) { array, length, length } - #define macro_f_thread_condition_attributes_t_clear(attributes) macro_f_memory_structure_clear(attributes) - #define macro_f_thread_condition_attributes_t_resize(status, attributes, length) status = f_thread_condition_attributes_resize(length, &attributes); #define macro_f_thread_condition_attributes_t_adjust(status, attributes, length) status = f_thread_condition_attributes_adjust(length, &attributes); diff --git a/level_0/f_thread/c/thread/id.c b/level_0/f_thread/c/thread/id.c index 0fcb7cd..f998aab 100644 --- a/level_0/f_thread/c/thread/id.c +++ b/level_0/f_thread/c/thread/id.c @@ -78,14 +78,16 @@ extern "C" { if (!ids) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; + if (amount) { + if (ids->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - if (ids->used + amount > ids->size) { - if (ids->used + amount > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + const f_number_unsigned_t length = ids->used + amount; - return private_f_thread_ids_resize(ids->used + amount, ids); + if (length > ids->size) { + if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + + return private_f_thread_ids_resize(length, ids); + } } return F_data_not; diff --git a/level_0/f_thread/c/thread/id.h b/level_0/f_thread/c/thread/id.h index 14dfc51..a252cd7 100644 --- a/level_0/f_thread/c/thread/id.h +++ b/level_0/f_thread/c/thread/id.h @@ -48,8 +48,6 @@ extern "C" { #define macro_f_thread_ids_t_initialize_1(array, size, used) { array, size, used } #define macro_f_thread_ids_t_initialize_2(array, length) { array, length, length } - #define macro_f_thread_ids_t_clear(attributes) macro_f_memory_structure_clear(attributes) - #define macro_f_thread_ids_t_resize(status, attributes, length) status = f_thread_ids_resize(length, &attributes); #define macro_f_thread_ids_t_adjust(status, attributes, length) status = f_thread_ids_adjust(length, &attributes); diff --git a/level_0/f_thread/c/thread/key.c b/level_0/f_thread/c/thread/key.c index d5844b0..841c8f2 100644 --- a/level_0/f_thread/c/thread/key.c +++ b/level_0/f_thread/c/thread/key.c @@ -78,14 +78,16 @@ extern "C" { if (!keys) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; + if (amount) { + if (keys->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - if (keys->used + amount > keys->size) { - if (keys->used + amount > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + const f_number_unsigned_t length = keys->used + amount; - return private_f_thread_keys_resize(keys->used + amount, keys); + if (length > keys->size) { + if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + + return private_f_thread_keys_resize(length, keys); + } } return F_data_not; diff --git a/level_0/f_thread/c/thread/key.h b/level_0/f_thread/c/thread/key.h index 8619869..334b5c1 100644 --- a/level_0/f_thread/c/thread/key.h +++ b/level_0/f_thread/c/thread/key.h @@ -52,8 +52,6 @@ extern "C" { #define macro_f_thread_keys_t_initialize_1(array, size, used) { array, size, used } #define macro_f_thread_keys_t_initialize_2(array, length) { array, length, length } - #define macro_f_thread_keys_t_clear(keys) macro_f_memory_structure_clear(keys) - #define macro_f_thread_keys_t_resize(status, keys, length) status = f_thread_keys_resize(length, &keys); #define macro_f_thread_keys_t_adjust(status, keys, length) status = f_thread_keys_adjust(length, &keys); diff --git a/level_0/f_thread/c/thread/lock.c b/level_0/f_thread/c/thread/lock.c index db7dc8c..d09388a 100644 --- a/level_0/f_thread/c/thread/lock.c +++ b/level_0/f_thread/c/thread/lock.c @@ -78,14 +78,16 @@ extern "C" { if (!locks) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; + if (amount) { + if (locks->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - if (locks->used + amount > locks->size) { - if (locks->used + amount > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + const f_number_unsigned_t length = locks->used + amount; - return private_f_thread_locks_resize(locks->used + amount, locks); + if (length > locks->size) { + if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + + return private_f_thread_locks_resize(length, locks); + } } return F_data_not; diff --git a/level_0/f_thread/c/thread/lock.h b/level_0/f_thread/c/thread/lock.h index da4d5ce..f27ff87 100644 --- a/level_0/f_thread/c/thread/lock.h +++ b/level_0/f_thread/c/thread/lock.h @@ -53,16 +53,16 @@ extern "C" { #define macro_f_thread_locks_t_initialize_1(array, size, used) { array, size, used } #define macro_f_thread_locks_t_initialize_2(array, length) { array, length, length } - #define macro_f_thread_locks_t_resize(status, locks, length) macro_f_memory_structure_resize(status, locks, f_thread_lock_t, length) - #define macro_f_thread_locks_t_adjust(status, locks, length) macro_f_memory_structure_adjust(status, locks, f_thread_lock_t, length) + #define macro_f_thread_locks_t_adjust(status, locks, length) status = f_memory_array_adjust(length, sizeof(f_thread_lock_t), (void **) & locks.array, locks.used, locks.size) + #define macro_f_thread_locks_t_resize(status, locks, length) status = f_memory_array_resize(length, sizeof(f_thread_lock_t), (void **) & locks.array, locks.used, locks.size) - #define macro_f_thread_locks_t_delete_simple(locks) macro_f_memory_structure_delete_simple(locks, f_thread_lock_t) - #define macro_f_thread_locks_t_destroy_simple(locks) macro_f_memory_structure_destroy_simple(locks, f_thread_lock_t) + #define macro_f_thread_locks_t_delete_simple(locks) f_memory_array_resize(0, sizeof(f_thread_lock_t), (void **) & locks.array, locks.used, locks.size) + #define macro_f_thread_locks_t_destroy_simple(locks) f_memory_array_adjust(0, sizeof(f_thread_lock_t), (void **) & locks.array, locks.used, locks.size) - #define macro_f_thread_locks_t_increase(status, step, locks) macro_f_memory_structure_increase(status, step, locks, f_thread_lock_t) - #define macro_f_thread_locks_t_increase_by(status, locks, amount) macro_f_memory_structure_increase_by(status, locks, f_thread_lock_t, amount) - #define macro_f_thread_locks_t_decrease_by(status, locks, amount) macro_f_memory_structure_decrease_by(status, locks, f_thread_lock_t, amount) - #define macro_f_thread_locks_t_decimate_by(status, locks, amount) macro_f_memory_structure_decimate_by(status, locks, f_thread_lock_t, amount) + #define macro_f_thread_locks_t_increase(status, step, locks) status = f_memory_array_increase(step, sizeof(f_thread_lock_t), (void **) & locks.array, locks.used, locks.size) + #define macro_f_thread_locks_t_increase_by(status, locks, amount) status = f_memory_array_increase_by(amount, sizeof(f_thread_lock_t), (void **) & locks.array, locks.used, locks.size) + #define macro_f_thread_locks_t_decrease_by(status, locks, amount) status = f_memory_array_decrease_by(amount, sizeof(f_thread_lock_t), (void **) & locks.array, locks.used, locks.size) + #define macro_f_thread_locks_t_decimate_by(status, locks, amount) status = f_memory_array_decimate_by(amount, sizeof(f_thread_lock_t), (void **) & locks.array, locks.used, locks.size) #endif // _di_f_thread_locks_t_ /** diff --git a/level_0/f_thread/c/thread/lock_attribute.c b/level_0/f_thread/c/thread/lock_attribute.c index b1a3520..12e7aef 100644 --- a/level_0/f_thread/c/thread/lock_attribute.c +++ b/level_0/f_thread/c/thread/lock_attribute.c @@ -78,14 +78,16 @@ extern "C" { if (!attributes) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; + if (amount) { + if (attributes->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - if (attributes->used + amount > attributes->size) { - if (attributes->used + amount > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + const f_number_unsigned_t length = attributes->used + amount; - return private_f_thread_lock_attributes_resize(attributes->used + amount, attributes); + if (length > attributes->size) { + if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + + return private_f_thread_lock_attributes_resize(length, attributes); + } } return F_data_not; diff --git a/level_0/f_thread/c/thread/lock_attribute.h b/level_0/f_thread/c/thread/lock_attribute.h index 87c5796..b6f7773 100644 --- a/level_0/f_thread/c/thread/lock_attribute.h +++ b/level_0/f_thread/c/thread/lock_attribute.h @@ -53,8 +53,6 @@ extern "C" { #define macro_f_thread_lock_attributes_t_initialize_1(array, size, used) { array, size, used } #define macro_f_thread_lock_attributes_t_initialize_2(array, length) { array, length, length } - #define macro_f_thread_lock_attributes_t_clear(attributes) macro_f_memory_structure_clear(attributes) - #define macro_f_thread_lock_attributes_t_resize(status, attributes, length) status = f_thread_lock_attributes_resize(length, &attributes); #define macro_f_thread_lock_attributes_t_adjust(status, attributes, length) status = f_thread_lock_attributes_adjust(length, &attributes); diff --git a/level_0/f_thread/c/thread/mutex.c b/level_0/f_thread/c/thread/mutex.c index d6df593..200310b 100644 --- a/level_0/f_thread/c/thread/mutex.c +++ b/level_0/f_thread/c/thread/mutex.c @@ -78,14 +78,16 @@ extern "C" { if (!mutexs) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; + if (amount) { + if (mutexs->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - if (mutexs->used + amount > mutexs->size) { - if (mutexs->used + amount > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + const f_number_unsigned_t length = mutexs->used + amount; - return private_f_thread_mutexs_resize(mutexs->used + amount, mutexs); + if (length > mutexs->size) { + if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + + return private_f_thread_mutexs_resize(length, mutexs); + } } return F_data_not; diff --git a/level_0/f_thread/c/thread/mutex.h b/level_0/f_thread/c/thread/mutex.h index 3dfd807..d159e8e 100644 --- a/level_0/f_thread/c/thread/mutex.h +++ b/level_0/f_thread/c/thread/mutex.h @@ -55,8 +55,6 @@ extern "C" { #define macro_f_thread_mutexs_t_initialize_1(array, size, used) { array, size, used } #define macro_f_thread_mutexs_t_initialize_2(array, length) { array, length, length } - #define macro_f_thread_mutexs_t_clear(mutexs) macro_f_memory_structure_clear(mutexs) - #define macro_f_thread_mutexs_t_resize(status, mutexs, length) status = f_thread_mutexs_resize(length, &mutexs); #define macro_f_thread_mutexs_t_adjust(status, mutexs, length) status = f_thread_mutexs_adjust(length, &mutexs); diff --git a/level_0/f_thread/c/thread/mutex_attribute.c b/level_0/f_thread/c/thread/mutex_attribute.c index 749404b..0c5e358 100644 --- a/level_0/f_thread/c/thread/mutex_attribute.c +++ b/level_0/f_thread/c/thread/mutex_attribute.c @@ -78,14 +78,16 @@ extern "C" { if (!attributes) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; + if (amount) { + if (attributes->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - if (attributes->used + amount > attributes->size) { - if (attributes->used + amount > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + const f_number_unsigned_t length = attributes->used + amount; - return private_f_thread_mutex_attributes_resize(attributes->used + amount, attributes); + if (length > attributes->size) { + if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + + return private_f_thread_mutex_attributes_resize(length, attributes); + } } return F_data_not; diff --git a/level_0/f_thread/c/thread/mutex_attribute.h b/level_0/f_thread/c/thread/mutex_attribute.h index 8f97d75..0cfd9a8 100644 --- a/level_0/f_thread/c/thread/mutex_attribute.h +++ b/level_0/f_thread/c/thread/mutex_attribute.h @@ -53,8 +53,6 @@ extern "C" { #define macro_f_thread_mutex_attributes_t_initialize_1(array, size, used) { array, size, used } #define macro_f_thread_mutex_attributes_t_initialize_2(array, length) { array, length, length } - #define macro_f_thread_mutex_attributes_t_clear(attributes) macro_f_memory_structure_clear(attributes) - #define macro_f_thread_mutex_attributes_t_resize(status, attributes, length) status = f_thread_mutex_attributes_resize(length, &attributes); #define macro_f_thread_mutex_attributes_t_adjust(status, attributes, length) status = f_thread_mutex_attributes_adjust(length, &attributes); diff --git a/level_0/f_thread/c/thread/once.c b/level_0/f_thread/c/thread/once.c index cfe8f82..6373936 100644 --- a/level_0/f_thread/c/thread/once.c +++ b/level_0/f_thread/c/thread/once.c @@ -78,14 +78,16 @@ extern "C" { if (!onces) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; + if (amount) { + if (onces->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - if (onces->used + amount > onces->size) { - if (onces->used + amount > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + const f_number_unsigned_t length = onces->used + amount; - return private_f_thread_onces_resize(onces->used + amount, onces); + if (length > onces->size) { + if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + + return private_f_thread_onces_resize(length, onces); + } } return F_data_not; diff --git a/level_0/f_thread/c/thread/once.h b/level_0/f_thread/c/thread/once.h index 0747313..d62c39f 100644 --- a/level_0/f_thread/c/thread/once.h +++ b/level_0/f_thread/c/thread/once.h @@ -53,8 +53,6 @@ extern "C" { #define macro_f_thread_onces_t_initialize_1(array, size, used) { array, size, used } #define macro_f_thread_onces_t_initialize_2(array, length) { array, length, length } - #define macro_f_thread_onces_t_clear(onces) macro_f_memory_structure_clear(onces) - #define macro_f_thread_onces_t_resize(status, onces, length) status = f_thread_onces_resize(length, &onces); #define macro_f_thread_onces_t_adjust(status, onces, length) status = f_thread_onces_adjust(length, &onces); diff --git a/level_0/f_thread/c/thread/semaphore.c b/level_0/f_thread/c/thread/semaphore.c index 0acfd18..85ea697 100644 --- a/level_0/f_thread/c/thread/semaphore.c +++ b/level_0/f_thread/c/thread/semaphore.c @@ -78,14 +78,16 @@ extern "C" { if (!semaphores) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; + if (amount) { + if (semaphores->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - if (semaphores->used + amount > semaphores->size) { - if (semaphores->used + amount > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + const f_number_unsigned_t length = semaphores->used + amount; - return private_f_thread_semaphores_resize(semaphores->used + amount, semaphores); + if (length > semaphores->size) { + if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + + return private_f_thread_semaphores_resize(length, semaphores); + } } return F_data_not; diff --git a/level_0/f_thread/c/thread/semaphore.h b/level_0/f_thread/c/thread/semaphore.h index 9722acf..56ac067 100644 --- a/level_0/f_thread/c/thread/semaphore.h +++ b/level_0/f_thread/c/thread/semaphore.h @@ -54,8 +54,6 @@ extern "C" { #define macro_f_thread_semaphores_t_initialize_1(array, size, used) { array, size, used } #define macro_f_thread_semaphores_t_initialize_2(array, length) { array, length, length } - #define macro_f_thread_semaphores_t_clear(semaphores) macro_f_memory_structure_clear(semaphores) - #define macro_f_thread_semaphores_t_resize(status, semaphores, length) status = f_thread_semaphores_resize(length, &semaphores); #define macro_f_thread_semaphores_t_adjust(status, semaphores, length) status = f_thread_semaphores_adjust(length, &semaphores); diff --git a/level_0/f_thread/c/thread/set.c b/level_0/f_thread/c/thread/set.c index afa1dd0..a0e55a9 100644 --- a/level_0/f_thread/c/thread/set.c +++ b/level_0/f_thread/c/thread/set.c @@ -78,14 +78,16 @@ extern "C" { if (!sets) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; + if (amount) { + if (sets->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - if (sets->used + amount > sets->size) { - if (sets->used + amount > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + const f_number_unsigned_t length = sets->used + amount; - return private_f_thread_sets_resize(sets->used + amount, sets); + if (length > sets->size) { + if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + + return private_f_thread_sets_resize(length, sets); + } } return F_data_not; diff --git a/level_0/f_thread/c/thread/set.h b/level_0/f_thread/c/thread/set.h index 5406faa..c092154 100644 --- a/level_0/f_thread/c/thread/set.h +++ b/level_0/f_thread/c/thread/set.h @@ -64,8 +64,6 @@ extern "C" { #define macro_f_thread_sets_t_initialize_1(array, size, used) { array, size, used } #define macro_f_thread_sets_t_initialize_2(array, length) { array, length, length } - #define macro_f_thread_sets_t_clear(sets) macro_f_memory_structure_clear(sets) - #define macro_f_thread_sets_t_resize(status, sets, length) status = f_thread_sets_resize(length, &sets); #define macro_f_thread_sets_t_adjust(status, sets, length) status = f_thread_sets_adjust(length, &sets); diff --git a/level_0/f_thread/c/thread/spin.c b/level_0/f_thread/c/thread/spin.c index e12db09..81258cf 100644 --- a/level_0/f_thread/c/thread/spin.c +++ b/level_0/f_thread/c/thread/spin.c @@ -78,14 +78,16 @@ extern "C" { if (!spins) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; + if (amount) { + if (spins->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - if (spins->used + amount > spins->size) { - if (spins->used + amount > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + const f_number_unsigned_t length = spins->used + amount; - return private_f_thread_spins_resize(spins->used + amount, spins); + if (length > spins->size) { + if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + + return private_f_thread_spins_resize(length, spins); + } } return F_data_not; diff --git a/level_0/f_thread/c/thread/spin.h b/level_0/f_thread/c/thread/spin.h index 61f0c82..d6f7f92 100644 --- a/level_0/f_thread/c/thread/spin.h +++ b/level_0/f_thread/c/thread/spin.h @@ -52,8 +52,6 @@ extern "C" { #define macro_f_thread_spins_t_initialize_1(array, size, used) { array, size, used } #define macro_f_thread_spins_t_initialize_2(array, length) { array, length, length } - #define macro_f_thread_spins_t_clear(spins) macro_f_memory_structure_clear(spins) - #define macro_f_thread_spins_t_resize(status, spins, length) status = f_thread_spins_resize(length, &spins); #define macro_f_thread_spins_t_adjust(status, spins, length) status = f_thread_spins_adjust(length, &spins); diff --git a/level_0/f_type_array/c/type_array/poll.c b/level_0/f_type_array/c/type_array/poll.c index c370a99..023534d 100644 --- a/level_0/f_type_array/c/type_array/poll.c +++ b/level_0/f_type_array/c/type_array/poll.c @@ -72,6 +72,8 @@ extern "C" { #endif // _di_level_0_parameter_checking_ if (step && polls->used + 1 > polls->size) { + if (polls->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + f_number_unsigned_t size = polls->used + step; if (size > F_number_t_size_unsigned_d) { @@ -93,12 +95,16 @@ extern "C" { if (!polls) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; + if (amount) { + if (polls->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - if (polls->used + amount > polls->size) { - if (polls->used + amount > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + const f_number_unsigned_t length = polls->used + amount; - return private_f_polls_resize(polls->used + amount, polls); + if (length > polls->size) { + if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + + return private_f_polls_resize(length, polls); + } } return F_data_not; @@ -211,6 +217,8 @@ extern "C" { #endif // _di_level_0_parameter_checking_ if (step && pollss->used + 1 > pollss->size) { + if (pollss->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + f_number_unsigned_t size = pollss->used + step; if (size > F_number_t_size_unsigned_d) { @@ -232,12 +240,16 @@ extern "C" { if (!pollss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; + if (amount) { + if (pollss->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - if (pollss->used + amount > pollss->size) { - if (pollss->used + amount > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + const f_number_unsigned_t length = pollss->used + amount; - return private_f_pollss_resize(pollss->used + amount, pollss); + if (length > pollss->size) { + if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + + return private_f_pollss_resize(length, pollss); + } } return F_data_not; diff --git a/level_0/f_utf/c/utf/dynamics.c b/level_0/f_utf/c/utf/dynamics.c index e0f28b8..8de484c 100644 --- a/level_0/f_utf/c/utf/dynamics.c +++ b/level_0/f_utf/c/utf/dynamics.c @@ -107,12 +107,16 @@ extern "C" { if (!dynamics) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (dynamics->used + amount > dynamics->size) { - if (dynamics->used + amount > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + if (amount) { + if (dynamics->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + + const f_number_unsigned_t length = dynamics->used + amount; - return private_f_utf_string_dynamics_resize(dynamics->used + amount, dynamics); + if (length > dynamics->size) { + if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + + return private_f_utf_string_dynamics_resize(length, dynamics); + } } return F_data_not; diff --git a/level_0/f_utf/c/utf/dynamicss.c b/level_0/f_utf/c/utf/dynamicss.c index db2a878..d086606 100644 --- a/level_0/f_utf/c/utf/dynamicss.c +++ b/level_0/f_utf/c/utf/dynamicss.c @@ -141,14 +141,16 @@ extern "C" { if (!dynamicss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; + if (amount) { + if (dynamicss->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - if (dynamicss->used + amount > dynamicss->size) { - if (dynamicss->used + amount > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + const f_number_unsigned_t length = dynamicss->used + amount; - return private_f_utf_string_dynamicss_resize(dynamicss->used + amount, dynamicss); + if (length > dynamicss->size) { + if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + + return private_f_utf_string_dynamicss_resize(length, dynamicss); + } } return F_data_not; diff --git a/level_0/f_utf/c/utf/map_multis.c b/level_0/f_utf/c/utf/map_multis.c index b77a899..1db192b 100644 --- a/level_0/f_utf/c/utf/map_multis.c +++ b/level_0/f_utf/c/utf/map_multis.c @@ -125,14 +125,16 @@ extern "C" { if (!map_multis) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; + if (amount) { + if (map_multis->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - if (map_multis->used + amount > map_multis->size) { - if (map_multis->used + amount > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + const f_number_unsigned_t length = map_multis->used + amount; - return private_f_utf_string_map_multis_resize(map_multis->used + amount, map_multis); + if (length > map_multis->size) { + if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + + return private_f_utf_string_map_multis_resize(length, map_multis); + } } return F_data_not; diff --git a/level_0/f_utf/c/utf/map_multis.h b/level_0/f_utf/c/utf/map_multis.h index 3c01df3..743b007 100644 --- a/level_0/f_utf/c/utf/map_multis.h +++ b/level_0/f_utf/c/utf/map_multis.h @@ -37,8 +37,6 @@ extern "C" { #define macro_f_utf_string_map_multis_t_initialize_1(array, size, used) { array, size, used } #define macro_f_utf_string_map_multis_t_initialize_2(array, length) { array, length, length } - #define macro_f_utf_string_map_multis_t_clear(map_multis) macro_f_memory_structure_clear(map_multis) - #define macro_f_utf_string_map_multis_t_resize(status, map_multis, length) status = f_utf_string_map_multis_resize(length, &map_multis); #define macro_f_utf_string_map_multis_t_adjust(status, map_multis, length) status = f_utf_string_map_multis_adjust(length, &map_multis); diff --git a/level_0/f_utf/c/utf/map_multiss.c b/level_0/f_utf/c/utf/map_multiss.c index 76598b2..c757197 100644 --- a/level_0/f_utf/c/utf/map_multiss.c +++ b/level_0/f_utf/c/utf/map_multiss.c @@ -140,14 +140,16 @@ extern "C" { if (!map_multiss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; + if (amount) { + if (map_multiss->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - if (map_multiss->used + amount > map_multiss->size) { - if (map_multiss->used + amount > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + const f_number_unsigned_t length = map_multiss->used + amount; - return private_f_utf_string_map_multiss_resize(map_multiss->used + amount, map_multiss); + if (length > map_multiss->size) { + if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + + return private_f_utf_string_map_multiss_resize(length, map_multiss); + } } return F_data_not; diff --git a/level_0/f_utf/c/utf/map_multiss.h b/level_0/f_utf/c/utf/map_multiss.h index 13bb564..4427dd3 100644 --- a/level_0/f_utf/c/utf/map_multiss.h +++ b/level_0/f_utf/c/utf/map_multiss.h @@ -37,8 +37,6 @@ extern "C" { #define macro_f_utf_string_map_multiss_t_initialize_1(array, size, used) { array, size, used } #define macro_f_utf_string_map_multiss_t_initialize_2(array, length) { array, length, length } - #define macro_f_utf_string_map_multiss_t_clear(map_multis) macro_f_memory_structure_clear(map_multis) - #define macro_f_utf_string_map_multiss_t_resize(status, map_multis, length) status = f_utf_string_map_multiss_resize(length, &map_multis); #define macro_f_utf_string_map_multiss_t_adjust(status, map_multis, length) status = f_utf_string_map_multiss_adjust(length, &map_multis); diff --git a/level_0/f_utf/c/utf/maps.c b/level_0/f_utf/c/utf/maps.c index 5829d62..dda7f5a 100644 --- a/level_0/f_utf/c/utf/maps.c +++ b/level_0/f_utf/c/utf/maps.c @@ -123,14 +123,16 @@ extern "C" { if (!maps) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; + if (amount) { + if (maps->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - if (maps->used + amount > maps->size) { - if (maps->used + amount > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + const f_number_unsigned_t length = maps->used + amount; - return private_f_utf_string_maps_resize(maps->used + amount, maps); + if (length > maps->size) { + if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + + return private_f_utf_string_maps_resize(length, maps); + } } return F_data_not; diff --git a/level_0/f_utf/c/utf/maps.h b/level_0/f_utf/c/utf/maps.h index 16edf57..ad92b14 100644 --- a/level_0/f_utf/c/utf/maps.h +++ b/level_0/f_utf/c/utf/maps.h @@ -37,8 +37,6 @@ extern "C" { #define macro_f_utf_string_maps_t_initialize_1(array, size, used) { array, size, used } #define macro_f_utf_string_maps_t_initialize_2(array, length) { array, length, length } - #define macro_f_utf_string_maps_t_clear(maps) macro_f_memory_structure_clear(maps) - #define macro_f_utf_string_maps_t_resize(status, maps, length) status = f_utf_string_maps_resize(length, &maps); #define macro_f_utf_string_maps_t_adjust(status, maps, length) status = f_utf_string_maps_adjust(length, &maps); diff --git a/level_0/f_utf/c/utf/mapss.c b/level_0/f_utf/c/utf/mapss.c index 10c52bb..a281a0d 100644 --- a/level_0/f_utf/c/utf/mapss.c +++ b/level_0/f_utf/c/utf/mapss.c @@ -137,14 +137,16 @@ extern "C" { if (!mapss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; + if (amount) { + if (mapss->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - if (mapss->used + amount > mapss->size) { - if (mapss->used + amount > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + const f_number_unsigned_t length = mapss->used + amount; - return private_f_utf_string_mapss_resize(mapss->used + amount, mapss); + if (length > mapss->size) { + if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + + return private_f_utf_string_mapss_resize(length, mapss); + } } return F_data_not; diff --git a/level_0/f_utf/c/utf/mapss.h b/level_0/f_utf/c/utf/mapss.h index 38f7511..b7d83c1 100644 --- a/level_0/f_utf/c/utf/mapss.h +++ b/level_0/f_utf/c/utf/mapss.h @@ -37,8 +37,6 @@ extern "C" { #define macro_f_utf_string_mapss_t_initialize_1(array, size, used) { array, size, used } #define macro_f_utf_string_mapss_t_initialize_2(array, length) { array, length, length } - #define macro_f_utf_string_mapss_t_clear(maps) macro_f_memory_structure_clear(maps) - #define macro_f_utf_string_mapss_t_resize(status, maps, length) status = f_utf_string_mapss_resize(length, &maps); #define macro_f_utf_string_mapss_t_adjust(status, maps, length) status = f_utf_string_mapss_adjust(length, &maps); diff --git a/level_0/f_utf/c/utf/private-dynamic.c b/level_0/f_utf/c/utf/private-dynamic.c index 556bd1e..dc4cb48 100644 --- a/level_0/f_utf/c/utf/private-dynamic.c +++ b/level_0/f_utf/c/utf/private-dynamic.c @@ -26,12 +26,12 @@ extern "C" { #if !defined(_di_f_utf_string_append_) || !defined(_di_f_utf_string_append_assure_) || !defined(_di_f_utf_string_append_assure_nulless_) || !defined(_di_f_utf_string_append_nulless_) || !defined(_di_f_utf_string_dynamic_append_) || !defined(_di_f_utf_string_dynamic_append_assure_) || !defined(_di_f_utf_string_dynamic_append_assure_nulless_) || !defined(_di_f_utf_string_dynamic_append_nulless_) || !defined(_di_f_utf_string_dynamic_increase_by_) || !defined(_di_f_utf_string_dynamic_mash_) || !defined(_di_f_utf_string_dynamic_mash_nulless_) || !defined(_di_f_utf_string_dynamic_mish_) || !defined(_di_f_utf_string_dynamic_mish_nulless_) || !defined(_di_f_utf_string_dynamic_partial_append_) || !defined(_di_f_utf_string_dynamic_partial_append_assure_) || !defined(_di_f_utf_string_dynamic_partial_append_assure_nulless_) || !defined(_di_f_utf_string_dynamic_partial_append_nulless_) || !defined(_di_f_utf_string_dynamic_partial_mash_) || !defined(_di_f_utf_string_dynamic_partial_mash_nulless_) || !defined(_di_f_utf_string_dynamic_partial_mish_) || !defined(_di_f_utf_string_dynamic_partial_mish_nulless_) || !defined(_di_f_utf_string_dynamic_partial_prepend_) || !defined(_di_f_utf_string_dynamic_partial_prepend_assure_) || !defined(_di_f_utf_string_dynamic_partial_prepend_assure_nulless_) || !defined(_di_f_utf_string_dynamic_partial_prepend_nulless_) || !defined(_di_f_utf_string_dynamic_prepend_) || !defined(_di_f_utf_string_dynamic_prepend_assure_) || !defined(_di_f_utf_string_dynamic_prepend_assure_nulless_) || !defined(_di_f_utf_string_dynamic_prepend_nulless_) || !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_dynamics_append_all_) || !defined(_di_f_utf_string_map_multis_append_) || !defined(_di_f_utf_string_map_multis_append_all_) || !defined(_di_f_utf_string_map_multiss_append_) || !defined(_di_f_utf_string_map_multiss_append_all_) || !defined(_di_f_utf_string_maps_append_) || !defined(_di_f_utf_string_maps_append_all_) || !defined(_di_f_utf_string_mapss_append_) || !defined(_di_f_utf_string_mapss_append_all_) || !defined(_di_f_utf_string_mash_) || !defined(_di_f_utf_string_mash_nulless_) || !defined(_di_f_utf_string_mish_) || !defined(_di_f_utf_string_mish_nulless_) || !defined(_di_f_utf_string_prepend_) || !defined(_di_f_utf_string_prepend_assure_) || !defined(_di_f_utf_string_prepend_assure_nulless_) || !defined(_di_f_utf_string_prepend_nulless_) || !defined(_di_f_utf_string_triples_append_) || !defined(_di_f_utf_string_triples_append_all_) || !defined(_di_f_utf_string_tripless_append_) || !defined(_di_f_utf_string_tripless_append_all_) f_status_t private_f_utf_string_dynamic_increase_by(const f_number_unsigned_t amount, f_utf_string_dynamic_t * const dynamic) { - if (dynamic->used + amount > dynamic->size) { - if (dynamic->used + amount > F_string_t_size_d) { - return F_status_set_error(F_string_too_large); - } + const f_number_unsigned_t length = dynamic->used + amount; - return private_f_utf_string_dynamic_resize(dynamic->used + amount, dynamic); + if (length > dynamic->size) { + if (length > F_string_t_size_d) return F_status_set_error(F_string_too_large); + + return private_f_utf_string_dynamic_resize(length, dynamic); } return F_data_not; diff --git a/level_0/f_utf/c/utf/triples.c b/level_0/f_utf/c/utf/triples.c index ed1797d..5b7e190 100644 --- a/level_0/f_utf/c/utf/triples.c +++ b/level_0/f_utf/c/utf/triples.c @@ -156,14 +156,16 @@ extern "C" { if (!triples) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; + if (amount) { + if (triples->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - if (triples->used + amount > triples->size) { - if (triples->used + amount > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + const f_number_unsigned_t length = triples->used + amount; - return private_f_utf_string_triples_resize(triples->used + amount, triples); + if (length > triples->size) { + if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + + return private_f_utf_string_triples_resize(length, triples); + } } return F_data_not; diff --git a/level_0/f_utf/c/utf/triples.h b/level_0/f_utf/c/utf/triples.h index b3b7a22..e68b778 100644 --- a/level_0/f_utf/c/utf/triples.h +++ b/level_0/f_utf/c/utf/triples.h @@ -37,8 +37,6 @@ extern "C" { #define macro_f_utf_string_triples_t_initialize_1(array, size, used) { array, size, used } #define macro_f_utf_string_triples_t_initialize_2(array, length) { array, length, length } - #define macro_f_utf_string_triples_t_clear(triples) macro_f_memory_structure_clear(triples) - #define macro_f_utf_string_triples_t_resize(status, triples, length) status = f_utf_string_triples_resize(length, &triples); #define macro_f_utf_string_triples_t_adjust(status, triples, length) status = f_utf_string_triples_adjust(length, &triples); diff --git a/level_0/f_utf/c/utf/tripless.c b/level_0/f_utf/c/utf/tripless.c index 1eb04ae..b4f37fc 100644 --- a/level_0/f_utf/c/utf/tripless.c +++ b/level_0/f_utf/c/utf/tripless.c @@ -137,14 +137,16 @@ extern "C" { if (!tripless) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; + if (amount) { + if (tripless->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - if (tripless->used + amount > tripless->size) { - if (tripless->used + amount > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + const f_number_unsigned_t length = tripless->used + amount; - return private_f_utf_string_tripless_resize(tripless->used + amount, tripless); + if (length > tripless->size) { + if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + + return private_f_utf_string_tripless_resize(length, tripless); + } } return F_data_not; diff --git a/level_0/f_utf/c/utf/tripless.h b/level_0/f_utf/c/utf/tripless.h index 339ea38..c7655ff 100644 --- a/level_0/f_utf/c/utf/tripless.h +++ b/level_0/f_utf/c/utf/tripless.h @@ -37,8 +37,6 @@ extern "C" { #define macro_f_utf_string_tripless_t_initialize_1(array, size, used) { array, size, used } #define macro_f_utf_string_tripless_t_initialize_2(array, length) { array, length, length } - #define macro_f_utf_string_tripless_t_clear(tripless) macro_f_memory_structure_clear(tripless) - #define macro_f_utf_string_tripless_t_resize(status, tripless, length) status = f_utf_string_tripless_resize(length, &tripless); #define macro_f_utf_string_tripless_t_adjust(status, tripless, length) status = f_utf_string_tripless_adjust(length, &tripless); diff --git a/level_3/controller/c/common/private-entry.c b/level_3/controller/c/common/private-entry.c index 8be713a..f59aba7 100644 --- a/level_3/controller/c/common/private-entry.c +++ b/level_3/controller/c/common/private-entry.c @@ -29,18 +29,20 @@ extern "C" { #ifndef _di_controller_entry_actions_increase_by_ f_status_t controller_entry_actions_increase_by(const f_number_unsigned_t amount, controller_entry_actions_t * const actions) { - if (actions->used + amount > actions->size) { - if (actions->used + amount > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + if (amount) { + if (actions->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - const f_status_t status = f_memory_resize(actions->size, actions->used + amount, sizeof(controller_entry_action_t), (void **) & actions->array); + const f_number_unsigned_t length = actions->used + amount; - if (F_status_is_error_not(status)) { - actions->size = actions->used + amount; - } + if (length > actions->size) { + const f_status_t status = f_memory_resize(actions->size, length, sizeof(controller_entry_action_t), (void **) & actions->array); - return status; + if (F_status_is_error_not(status)) { + actions->size = actions->used + amount; + } + + return status; + } } return F_data_not; @@ -73,18 +75,20 @@ extern "C" { #ifndef _di_controller_entry_items_increase_by_ f_status_t controller_entry_items_increase_by(const f_number_unsigned_t amount, controller_entry_items_t * const items) { - if (items->used + amount > items->size) { - if (items->used + amount > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + if (amount) { + if (items->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - const f_status_t status = f_memory_resize(items->size, items->used + amount, sizeof(controller_entry_item_t), (void **) & items->array); + const f_number_unsigned_t length = items->used + amount; - if (F_status_is_error_not(status)) { - items->size = items->used + amount; - } + if (length > items->size) { + const f_status_t status = f_memory_resize(items->size, length, sizeof(controller_entry_item_t), (void **) & items->array); - return status; + if (F_status_is_error_not(status)) { + items->size = items->used + amount; + } + + return status; + } } return F_data_not; diff --git a/level_3/controller/c/common/private-rule.c b/level_3/controller/c/common/private-rule.c index 85c560e..1bc9296 100644 --- a/level_3/controller/c/common/private-rule.c +++ b/level_3/controller/c/common/private-rule.c @@ -35,18 +35,20 @@ extern "C" { #ifndef _di_controller_rule_actions_increase_by_ f_status_t controller_rule_actions_increase_by(const f_number_unsigned_t amount, controller_rule_actions_t * const actions) { - if (actions->used + amount > actions->size) { - if (actions->used + amount > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + if (amount) { + if (actions->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - const f_status_t status = f_memory_resize(actions->size, actions->used + amount, sizeof(controller_rule_action_t), (void **) & actions->array); + const f_number_unsigned_t length = actions->used + amount; - if (F_status_is_error_not(status)) { - actions->size = actions->used + amount; - } + if (length > actions->size) { + const f_status_t status = f_memory_resize(actions->size, length, sizeof(controller_rule_action_t), (void **) & actions->array); - return status; + if (F_status_is_error_not(status)) { + actions->size = actions->used + amount; + } + + return status; + } } return F_data_not; diff --git a/level_3/controller/c/rule/private-rule.c b/level_3/controller/c/rule/private-rule.c index 66a5019..52c1248 100644 --- a/level_3/controller/c/rule/private-rule.c +++ b/level_3/controller/c/rule/private-rule.c @@ -2528,18 +2528,20 @@ extern "C" { #ifndef _di_controller_rule_items_increase_by_ f_status_t controller_rule_items_increase_by(const f_number_unsigned_t amount, controller_rule_items_t * const items) { - if (items->used + amount > items->size) { - if (items->used + amount > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + if (amount) { + if (items->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - const f_status_t status = f_memory_resize(items->size, items->used + amount, sizeof(controller_rule_item_t), (void **) & items->array); + const f_number_unsigned_t length = items->used + amount; - if (F_status_is_error_not(status)) { - items->size = items->used + amount; - } + if (length > items->size) { + const f_status_t status = f_memory_resize(items->size, length, sizeof(controller_rule_item_t), (void **) & items->array); - return status; + if (F_status_is_error_not(status)) { + items->size = items->used + amount; + } + + return status; + } } return F_data_not; diff --git a/level_3/fss_read/c/main/common/type.c b/level_3/fss_read/c/main/common/type.c index 0a49a71..45f0880 100644 --- a/level_3/fss_read/c/main/common/type.c +++ b/level_3/fss_read/c/main/common/type.c @@ -17,6 +17,7 @@ extern "C" { f_status_t fss_read_depths_resize(const f_number_unsigned_t length, fss_read_depths_t * const depths) { if (!depths) return F_status_set_error(F_parameter); + if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); if (depths->used + length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); for (f_number_unsigned_t i = length; i < depths->size; ++i) { @@ -40,6 +41,7 @@ extern "C" { f_status_t fss_read_files_resize(const f_number_unsigned_t length, fss_read_files_t * const files) { if (!files) return F_status_set_error(F_parameter); + if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); if (files->used + length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); const f_status_t status = f_memory_adjust(files->size, length, sizeof(fss_read_file_t), (void **) & files->array); diff --git a/level_3/fss_read/c/main/common/type.h b/level_3/fss_read/c/main/common/type.h index 6548de7..0a322a8 100644 --- a/level_3/fss_read/c/main/common/type.h +++ b/level_3/fss_read/c/main/common/type.h @@ -71,8 +71,6 @@ extern "C" { } fss_read_depths_t; #define fss_read_depths_t_initialize { 0, 0, 0 } - - #define macro_fss_read_depths_t_clear(depths) macro_f_memory_structure_clear(depths) #endif // _di_fss_read_depths_t_ /**