From: Kevin Day Date: Sat, 22 Jul 2023 03:46:36 +0000 (-0500) Subject: Progress: Continue memory array related changes. X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=da3912cd2833c43b44726b1f20ac1f544842f058;p=fll Progress: Continue memory array related changes. --- diff --git a/level_0/f_fss/c/fss/named.c b/level_0/f_fss/c/fss/named.c index c41d115..2f58715 100644 --- a/level_0/f_fss/c/fss/named.c +++ b/level_0/f_fss/c/fss/named.c @@ -48,15 +48,15 @@ extern "C" { 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; + f_number_unsigned_t length = named->objects.used + step; - if (size > F_number_t_size_unsigned_d) { + if (length > F_number_t_size_unsigned_d) { if (named->objects.used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - size = F_number_t_size_unsigned_d; + length = F_number_t_size_unsigned_d; } - return private_f_fss_named_resize(size, named); + return private_f_fss_named_resize(length, named); } return F_data_not; diff --git a/level_0/f_fss/c/fss/nest.c b/level_0/f_fss/c/fss/nest.c index 0741aca..a6decb2 100644 --- a/level_0/f_fss/c/fss/nest.c +++ b/level_0/f_fss/c/fss/nest.c @@ -49,15 +49,15 @@ extern "C" { 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; + f_number_unsigned_t length = nest->used + step; - if (size > F_number_t_size_unsigned_d) { + if (length > F_number_t_size_unsigned_d) { if (nest->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - size = F_number_t_size_unsigned_d; + length = F_number_t_size_unsigned_d; } - return private_f_fss_nest_resize(size, nest); + return private_f_fss_nest_resize(length, nest); } return F_data_not; @@ -139,15 +139,15 @@ extern "C" { 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; + f_number_unsigned_t length = nests->used + step; - if (size > F_number_t_size_unsigned_d) { + if (length > F_number_t_size_unsigned_d) { if (nests->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - size = F_number_t_size_unsigned_d; + length = F_number_t_size_unsigned_d; } - return private_f_fss_nests_resize(size, nests); + return private_f_fss_nests_resize(length, nests); } return F_data_not; diff --git a/level_0/f_fss/c/fss/set.c b/level_0/f_fss/c/fss/set.c index dad2b5a..18c4aaf 100644 --- a/level_0/f_fss/c/fss/set.c +++ b/level_0/f_fss/c/fss/set.c @@ -48,15 +48,15 @@ extern "C" { 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; + f_number_unsigned_t length = set->objects.used + step; - if (size > F_number_t_size_unsigned_d) { + if (length > F_number_t_size_unsigned_d) { if (set->objects.used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - size = F_number_t_size_unsigned_d; + length = F_number_t_size_unsigned_d; } - return private_f_fss_set_resize(size, set); + return private_f_fss_set_resize(length, set); } return F_data_not; diff --git a/level_0/f_fss/c/fss/set_quote.c b/level_0/f_fss/c/fss/set_quote.c index 39bf227..655a69d 100644 --- a/level_0/f_fss/c/fss/set_quote.c +++ b/level_0/f_fss/c/fss/set_quote.c @@ -48,15 +48,15 @@ extern "C" { 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; + f_number_unsigned_t length = set_quote->objects.used + step; - if (size > F_number_t_size_unsigned_d) { + if (length > F_number_t_size_unsigned_d) { if (set_quote->objects.used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - size = F_number_t_size_unsigned_d; + length = F_number_t_size_unsigned_d; } - return private_f_fss_set_quote_resize(size, set_quote); + return private_f_fss_set_quote_resize(length, set_quote); } return F_data_not; diff --git a/level_0/f_iki/c/iki/data.c b/level_0/f_iki/c/iki/data.c index 9f8ca36..4a4e822 100644 --- a/level_0/f_iki/c/iki/data.c +++ b/level_0/f_iki/c/iki/data.c @@ -117,15 +117,15 @@ extern "C" { 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; + f_number_unsigned_t length = datas->used + step; - if (size > F_number_t_size_unsigned_d) { + if (length > 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); - size = F_number_t_size_unsigned_d; + length = F_number_t_size_unsigned_d; } - return private_f_iki_datas_resize(size, datas); + return private_f_iki_datas_resize(length, datas); } return F_data_not; @@ -262,15 +262,15 @@ extern "C" { 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; + f_number_unsigned_t length = datass->used + step; - if (size > F_number_t_size_unsigned_d) { + if (length > 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); - size = F_number_t_size_unsigned_d; + length = F_number_t_size_unsigned_d; } - return private_f_iki_datass_resize(size, datass); + return private_f_iki_datass_resize(length, datass); } return F_data_not; diff --git a/level_0/f_memory/c/memory/private-array.c b/level_0/f_memory/c/memory/private-array.c index f5850f6..5b96940 100644 --- a/level_0/f_memory/c/memory/private-array.c +++ b/level_0/f_memory/c/memory/private-array.c @@ -1,4 +1,5 @@ #include "../memory.h" +#include "../private-memory.h" #include "private-array.h" #ifdef __cplusplus @@ -8,7 +9,7 @@ extern "C" { #if !defined(_di_f_memory_array_adjust_) || !defined(_di_f_memory_array_decimate_by_) f_status_t private_f_memory_array_adjust(const f_number_unsigned_t length, const size_t width, void ** array, f_number_unsigned_t * const used, f_number_unsigned_t * const size) { - const f_status_t status = f_memory_adjust(*size, length, width, array); + const f_status_t status = private_f_memory_adjust(*size, length, width, array); if (F_status_is_error(status)) return status; *size = length; @@ -24,7 +25,7 @@ extern "C" { #if !defined(_di_f_memory_array_decrease_by_) || !defined(_di_f_memory_array_increase_) || !defined(_di_f_memory_array_increase_by_) || !defined(_di_f_memory_array_resize_) f_status_t private_f_memory_array_resize(const f_number_unsigned_t length, const size_t width, void ** array, f_number_unsigned_t * const used, f_number_unsigned_t * const size) { - const f_status_t status = f_memory_resize(*size, length, width, array); + const f_status_t status = private_f_memory_resize(*size, length, width, array); if (F_status_is_error(status)) return status; *size = length; diff --git a/level_0/f_string/c/string/dynamics.c b/level_0/f_string/c/string/dynamics.c index 8869ec3..6067ddc 100644 --- a/level_0/f_string/c/string/dynamics.c +++ b/level_0/f_string/c/string/dynamics.c @@ -74,15 +74,15 @@ extern "C" { if (!step) return F_data_not; if (dynamics->used + 1 > dynamics->size) { - f_number_unsigned_t size = dynamics->used + step; + f_number_unsigned_t length = dynamics->used + step; - if (size > F_number_t_size_unsigned_d) { + if (length > F_number_t_size_unsigned_d) { if (dynamics->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - size = F_number_t_size_unsigned_d; + length = F_number_t_size_unsigned_d; } - return private_f_string_dynamics_resize(size, dynamics); + return private_f_string_dynamics_resize(length, 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 74aee6c..dae3a3b 100644 --- a/level_0/f_string/c/string/dynamicss.c +++ b/level_0/f_string/c/string/dynamicss.c @@ -108,15 +108,15 @@ extern "C" { if (!step) return F_data_not; if (dynamicss->used + 1 > dynamicss->size) { - f_number_unsigned_t size = dynamicss->used + step; + f_number_unsigned_t length = dynamicss->used + step; - if (size > F_number_t_size_unsigned_d) { + if (length > F_number_t_size_unsigned_d) { if (dynamicss->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - size = F_number_t_size_unsigned_d; + length = F_number_t_size_unsigned_d; } - return private_f_string_dynamicss_resize(size, dynamicss); + return private_f_string_dynamicss_resize(length, 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 758e3e1..5f8cb36 100644 --- a/level_0/f_string/c/string/map_multis.c +++ b/level_0/f_string/c/string/map_multis.c @@ -93,15 +93,15 @@ extern "C" { #endif // _di_level_0_parameter_checking_ if (step && map_multis->used + 1 > map_multis->size) { - f_number_unsigned_t size = map_multis->used + step; + f_number_unsigned_t length = map_multis->used + step; - if (size > F_number_t_size_unsigned_d) { + if (length > F_number_t_size_unsigned_d) { if (map_multis->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - size = F_number_t_size_unsigned_d; + length = F_number_t_size_unsigned_d; } - return private_f_string_map_multis_resize(size, map_multis); + return private_f_string_map_multis_resize(length, map_multis); } return F_data_not; diff --git a/level_0/f_string/c/string/map_multiss.c b/level_0/f_string/c/string/map_multiss.c index 29b0464..2dd2c4a 100644 --- a/level_0/f_string/c/string/map_multiss.c +++ b/level_0/f_string/c/string/map_multiss.c @@ -107,15 +107,15 @@ extern "C" { #endif // _di_level_0_parameter_checking_ if (step && map_multiss->used + 1 > map_multiss->size) { - f_number_unsigned_t size = map_multiss->used + step; + f_number_unsigned_t length = map_multiss->used + step; - if (size > F_number_t_size_unsigned_d) { + if (length > F_number_t_size_unsigned_d) { if (map_multiss->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - size = F_number_t_size_unsigned_d; + length = F_number_t_size_unsigned_d; } - return private_f_string_map_multiss_resize(size, map_multiss); + return private_f_string_map_multiss_resize(length, map_multiss); } return F_data_not; diff --git a/level_0/f_string/c/string/maps.c b/level_0/f_string/c/string/maps.c index bc12a2b..fa95676 100644 --- a/level_0/f_string/c/string/maps.c +++ b/level_0/f_string/c/string/maps.c @@ -91,15 +91,15 @@ extern "C" { #endif // _di_level_0_parameter_checking_ if (step && maps->used + 1 > maps->size) { - f_number_unsigned_t size = maps->used + step; + f_number_unsigned_t length = maps->used + step; - if (size > F_number_t_size_unsigned_d) { + if (length > F_number_t_size_unsigned_d) { if (maps->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - size = F_number_t_size_unsigned_d; + length = F_number_t_size_unsigned_d; } - return private_f_string_maps_resize(size, maps); + return private_f_string_maps_resize(length, maps); } return F_data_not; diff --git a/level_0/f_string/c/string/mapss.c b/level_0/f_string/c/string/mapss.c index a68f0b7..6e86e6f 100644 --- a/level_0/f_string/c/string/mapss.c +++ b/level_0/f_string/c/string/mapss.c @@ -105,15 +105,15 @@ extern "C" { #endif // _di_level_0_parameter_checking_ if (step && mapss->used + 1 > mapss->size) { - f_number_unsigned_t size = mapss->used + step; + f_number_unsigned_t length = mapss->used + step; - if (size > F_number_t_size_unsigned_d) { + if (length > F_number_t_size_unsigned_d) { if (mapss->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - size = F_number_t_size_unsigned_d; + length = F_number_t_size_unsigned_d; } - return private_f_string_mapss_resize(size, mapss); + return private_f_string_mapss_resize(length, mapss); } return F_data_not; diff --git a/level_0/f_string/c/string/quantityss.c b/level_0/f_string/c/string/quantityss.c index 07c6950..733efe7 100644 --- a/level_0/f_string/c/string/quantityss.c +++ b/level_0/f_string/c/string/quantityss.c @@ -105,15 +105,15 @@ extern "C" { #endif // _di_level_0_parameter_checking_ if (step && quantityss->used + 1 > quantityss->size) { - f_number_unsigned_t size = quantityss->used + step; + f_number_unsigned_t length = quantityss->used + step; - if (size > F_number_t_size_unsigned_d) { + if (length > F_number_t_size_unsigned_d) { if (quantityss->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - size = F_number_t_size_unsigned_d; + length = F_number_t_size_unsigned_d; } - return private_f_string_quantityss_resize(size, quantityss); + return private_f_string_quantityss_resize(length, quantityss); } return F_data_not; diff --git a/level_0/f_string/c/string/rangess.c b/level_0/f_string/c/string/rangess.c index 324739c..7a58c46 100644 --- a/level_0/f_string/c/string/rangess.c +++ b/level_0/f_string/c/string/rangess.c @@ -105,15 +105,15 @@ extern "C" { #endif // _di_level_0_parameter_checking_ if (step && rangess->used + 1 > rangess->size) { - f_number_unsigned_t size = rangess->used + step; + f_number_unsigned_t length = rangess->used + step; - if (size > F_number_t_size_unsigned_d) { + if (length > F_number_t_size_unsigned_d) { if (rangess->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - size = F_number_t_size_unsigned_d; + length = F_number_t_size_unsigned_d; } - return private_f_string_rangess_resize(size, rangess); + 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 39ea8de..f715588 100644 --- a/level_0/f_string/c/string/triples.c +++ b/level_0/f_string/c/string/triples.c @@ -126,15 +126,15 @@ extern "C" { #endif // _di_level_0_parameter_checking_ if (step && triples->used + 1 > triples->size) { - f_number_unsigned_t size = triples->used + F_memory_default_allocation_small_d; + f_number_unsigned_t length = triples->used + F_memory_default_allocation_small_d; - if (size > F_number_t_size_unsigned_d) { + if (length > F_number_t_size_unsigned_d) { if (triples->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - size = F_number_t_size_unsigned_d; + length = F_number_t_size_unsigned_d; } - return private_f_string_triples_resize(size, triples); + return private_f_string_triples_resize(length, triples); } return F_data_not; diff --git a/level_0/f_string/c/string/tripless.c b/level_0/f_string/c/string/tripless.c index 196f172..e61ebcc 100644 --- a/level_0/f_string/c/string/tripless.c +++ b/level_0/f_string/c/string/tripless.c @@ -105,15 +105,15 @@ extern "C" { #endif // _di_level_0_parameter_checking_ if (step && tripless->used + 1 > tripless->size) { - f_number_unsigned_t size = tripless->used + step; + f_number_unsigned_t length = tripless->used + step; - if (size > F_number_t_size_unsigned_d) { + if (length > F_number_t_size_unsigned_d) { if (tripless->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - size = F_number_t_size_unsigned_d; + length = F_number_t_size_unsigned_d; } - return private_f_string_tripless_resize(size, tripless); + return private_f_string_tripless_resize(length, tripless); } return F_data_not; diff --git a/level_0/f_thread/c/thread/attribute.c b/level_0/f_thread/c/thread/attribute.c index 19866d2..b62418c 100644 --- a/level_0/f_thread/c/thread/attribute.c +++ b/level_0/f_thread/c/thread/attribute.c @@ -7,57 +7,55 @@ extern "C" { #endif #ifndef _di_f_thread_attributes_adjust_ - f_status_t f_thread_attributes_adjust(const f_number_unsigned_t length, f_thread_attributes_t * const attributes) { + f_status_t f_thread_attributes_adjust(const f_number_unsigned_t length, f_thread_attributes_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!attributes) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_thread_attributes_adjust(length, attributes); + return private_f_thread_attributes_adjust(length, structure); } #endif // _di_f_thread_attributes_adjust_ #ifndef _di_f_thread_attributes_decimate_by_ - f_status_t f_thread_attributes_decimate_by(const f_number_unsigned_t amount, f_thread_attributes_t * const attributes) { + f_status_t f_thread_attributes_decimate_by(const f_number_unsigned_t amount, f_thread_attributes_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!attributes) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - return private_f_thread_attributes_adjust((attributes->size > amount) ? attributes->size - amount : 0, attributes); + return private_f_thread_attributes_adjust((structure->size > amount) ? structure->size - amount : 0, structure); } #endif // _di_f_thread_attributes_decimate_by_ #ifndef _di_f_thread_attributes_decrease_by_ - f_status_t f_thread_attributes_decrease_by(const f_number_unsigned_t amount, f_thread_attributes_t * const attributes) { + f_status_t f_thread_attributes_decrease_by(const f_number_unsigned_t amount, f_thread_attributes_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!attributes) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - return private_f_thread_attributes_resize((attributes->size > amount) ? attributes->size - amount : 0, attributes); + return private_f_thread_attributes_resize((structure->size > amount) ? structure->size - amount : 0, structure); } #endif // _di_f_thread_attributes_decrease_by_ #ifndef _di_f_thread_attributes_increase_ - f_status_t f_thread_attributes_increase(const f_number_unsigned_t step, f_thread_attributes_t * const attributes) { + f_status_t f_thread_attributes_increase(const f_number_unsigned_t step, f_thread_attributes_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!attributes) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (step && attributes->used + 1 > attributes->size) { - f_number_unsigned_t size = attributes->used + step; + if (step && structure->used + 1 > structure->size) { + f_number_unsigned_t length = structure->used + step; - if (size > F_number_t_size_unsigned_d) { - if (attributes->used + 1 > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + if (length > F_number_t_size_unsigned_d) { + if (structure->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - size = F_number_t_size_unsigned_d; + length = F_number_t_size_unsigned_d; } - return private_f_thread_attributes_resize(size, attributes); + return private_f_thread_attributes_resize(length, structure); } return F_data_not; @@ -65,20 +63,20 @@ extern "C" { #endif // _di_f_thread_attributes_increase_ #ifndef _di_f_thread_attributes_increase_by_ - f_status_t f_thread_attributes_increase_by(const f_number_unsigned_t amount, f_thread_attributes_t * const attributes) { + f_status_t f_thread_attributes_increase_by(const f_number_unsigned_t amount, f_thread_attributes_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!attributes) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (amount) { - if (attributes->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + if (structure->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - const f_number_unsigned_t length = attributes->used + amount; + const f_number_unsigned_t length = structure->used + amount; - if (length > attributes->size) { + if (length > structure->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 private_f_thread_attributes_resize(length, structure); } } @@ -87,12 +85,12 @@ extern "C" { #endif // _di_f_thread_attributes_increase_by_ #ifndef _di_f_thread_attributes_resize_ - f_status_t f_thread_attributes_resize(const f_number_unsigned_t length, f_thread_attributes_t * const attributes) { + f_status_t f_thread_attributes_resize(const f_number_unsigned_t length, f_thread_attributes_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!attributes) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_thread_attributes_resize(length, attributes); + return private_f_thread_attributes_resize(length, structure); } #endif // _di_f_thread_attributes_resize_ diff --git a/level_0/f_thread/c/thread/attribute.h b/level_0/f_thread/c/thread/attribute.h index 64f47d7..8453a18 100644 --- a/level_0/f_thread/c/thread/attribute.h +++ b/level_0/f_thread/c/thread/attribute.h @@ -70,8 +70,8 @@ extern "C" { * * @param length * The new size to use. - * @param attributes - * The string attributes array to resize. + * @param structure + * The thread attributes array to resize. * * @return * F_none on success. @@ -80,7 +80,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_attributes_adjust_ - extern f_status_t f_thread_attributes_adjust(const f_number_unsigned_t length, f_thread_attributes_t * const attributes); + extern f_status_t f_thread_attributes_adjust(const f_number_unsigned_t length, f_thread_attributes_t * const structure); #endif // _di_f_thread_attributes_adjust_ /** @@ -92,8 +92,8 @@ extern "C" { * * @param amount * A positive number representing how much to decimate the size by. - * @param attributes - * The string attributes array to resize. + * @param structure + * The thread attributes array to resize. * * @return * F_none on success. @@ -103,7 +103,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_attributes_decimate_by_ - extern f_status_t f_thread_attributes_decimate_by(const f_number_unsigned_t amount, f_thread_attributes_t * const attributes); + extern f_status_t f_thread_attributes_decimate_by(const f_number_unsigned_t amount, f_thread_attributes_t * const structure); #endif // _di_f_thread_attributes_decimate_by_ /** @@ -115,8 +115,8 @@ extern "C" { * * @param amount * A positive number representing how much to decrease the size by. - * @param attributes - * The string attributes array to resize. + * @param structure + * The thread attributes array to resize. * * @return * F_none on success. @@ -126,7 +126,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_attributes_decrease_by_ - extern f_status_t f_thread_attributes_decrease_by(const f_number_unsigned_t amount, f_thread_attributes_t * const attributes); + extern f_status_t f_thread_attributes_decrease_by(const f_number_unsigned_t amount, f_thread_attributes_t * const structure); #endif // _di_f_thread_attributes_decrease_by_ /** @@ -138,8 +138,8 @@ extern "C" { * @param step * The allocation step to use. * Must be greater than 0. - * @param attributes - * The string attributes array to resize. + * @param structure + * The thread attributes array to resize. * * @return * F_none on success. @@ -150,7 +150,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_attributes_increase_ - extern f_status_t f_thread_attributes_increase(const f_number_unsigned_t step, f_thread_attributes_t * const attributes); + extern f_status_t f_thread_attributes_increase(const f_number_unsigned_t step, f_thread_attributes_t * const structure); #endif // _di_f_thread_attributes_increase_ /** @@ -162,8 +162,8 @@ extern "C" { * * @param amount * A positive number representing how much to increase the size by. - * @param attributes - * The string attributes array to resize. + * @param structure + * The thread attributes array to resize. * * @return * F_none on success. @@ -174,7 +174,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_attributes_increase_by_ - extern f_status_t f_thread_attributes_increase_by(const f_number_unsigned_t amount, f_thread_attributes_t * const attributes); + extern f_status_t f_thread_attributes_increase_by(const f_number_unsigned_t amount, f_thread_attributes_t * const structure); #endif // _di_f_thread_attributes_increase_by_ /** @@ -182,8 +182,8 @@ extern "C" { * * @param length * The new size to use. - * @param attributes - * The string attributes array to adjust. + * @param structure + * The thread attributes array to adjust. * * @return * F_none on success. @@ -192,7 +192,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_attributes_resize_ - extern f_status_t f_thread_attributes_resize(const f_number_unsigned_t length, f_thread_attributes_t * const attributes); + extern f_status_t f_thread_attributes_resize(const f_number_unsigned_t length, f_thread_attributes_t * const structure); #endif // _di_f_thread_attributes_resize_ #ifdef __cplusplus diff --git a/level_0/f_thread/c/thread/barrier.c b/level_0/f_thread/c/thread/barrier.c index e7a0a80..65bb682 100644 --- a/level_0/f_thread/c/thread/barrier.c +++ b/level_0/f_thread/c/thread/barrier.c @@ -7,65 +7,55 @@ extern "C" { #endif #ifndef _di_f_thread_barriers_adjust_ - f_status_t f_thread_barriers_adjust(const f_number_unsigned_t length, f_thread_barriers_t * const barriers) { + f_status_t f_thread_barriers_adjust(const f_number_unsigned_t length, f_thread_barriers_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!barriers) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_thread_barriers_adjust(length, barriers); + return private_f_thread_barriers_adjust(length, structure); } #endif // _di_f_thread_barriers_adjust_ #ifndef _di_f_thread_barriers_decimate_by_ - f_status_t f_thread_barriers_decimate_by(const f_number_unsigned_t amount, f_thread_barriers_t * const barriers) { + f_status_t f_thread_barriers_decimate_by(const f_number_unsigned_t amount, f_thread_barriers_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!barriers) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - if (barriers->size > amount) { - return private_f_thread_barriers_adjust(barriers->size - amount, barriers); - } - - return private_f_thread_barriers_adjust(0, barriers); + return private_f_thread_barriers_adjust((structure->size > amount) ? structure->size - amount : 0, structure); } #endif // _di_f_thread_barriers_decimate_by_ #ifndef _di_f_thread_barriers_decrease_by_ - f_status_t f_thread_barriers_decrease_by(const f_number_unsigned_t amount, f_thread_barriers_t * const barriers) { + f_status_t f_thread_barriers_decrease_by(const f_number_unsigned_t amount, f_thread_barriers_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!barriers) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - if (barriers->size > amount) { - return private_f_thread_barriers_resize(barriers->size - amount, barriers); - } - - return private_f_thread_barriers_resize(0, barriers); + return private_f_thread_barriers_resize((structure->size > amount) ? structure->size - amount : 0, structure); } #endif // _di_f_thread_barriers_decrease_by_ #ifndef _di_f_thread_barriers_increase_ - f_status_t f_thread_barriers_increase(const f_number_unsigned_t step, f_thread_barriers_t * const barriers) { + f_status_t f_thread_barriers_increase(const f_number_unsigned_t step, f_thread_barriers_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!barriers) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (step && barriers->used + 1 > barriers->size) { - f_number_unsigned_t size = barriers->used + step; + if (step && structure->used + 1 > structure->size) { + f_number_unsigned_t length = structure->used + step; - if (size > F_number_t_size_unsigned_d) { - if (barriers->used + 1 > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + if (length > F_number_t_size_unsigned_d) { + if (structure->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - size = F_number_t_size_unsigned_d; + length = F_number_t_size_unsigned_d; } - return private_f_thread_barriers_resize(size, barriers); + return private_f_thread_barriers_resize(length, structure); } return F_data_not; @@ -73,20 +63,20 @@ extern "C" { #endif // _di_f_thread_barriers_increase_ #ifndef _di_f_thread_barriers_increase_by_ - f_status_t f_thread_barriers_increase_by(const f_number_unsigned_t amount, f_thread_barriers_t * const barriers) { + f_status_t f_thread_barriers_increase_by(const f_number_unsigned_t amount, f_thread_barriers_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!barriers) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (amount) { - if (barriers->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + if (structure->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - const f_number_unsigned_t length = barriers->used + amount; + const f_number_unsigned_t length = structure->used + amount; - if (length > barriers->size) { + if (length > structure->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 private_f_thread_barriers_resize(length, structure); } } @@ -95,12 +85,12 @@ extern "C" { #endif // _di_f_thread_barriers_increase_by_ #ifndef _di_f_thread_barriers_resize_ - f_status_t f_thread_barriers_resize(const f_number_unsigned_t length, f_thread_barriers_t * const barriers) { + f_status_t f_thread_barriers_resize(const f_number_unsigned_t length, f_thread_barriers_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!barriers) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_thread_barriers_resize(length, barriers); + return private_f_thread_barriers_resize(length, structure); } #endif // _di_f_thread_barriers_resize_ diff --git a/level_0/f_thread/c/thread/barrier.h b/level_0/f_thread/c/thread/barrier.h index cdf9fd3..2bb8a56 100644 --- a/level_0/f_thread/c/thread/barrier.h +++ b/level_0/f_thread/c/thread/barrier.h @@ -69,7 +69,7 @@ extern "C" { * * @param length * The new size to use. - * @param barriers + * @param structure * The thread barriers array to resize. * * @return @@ -79,7 +79,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_barriers_adjust_ - extern f_status_t f_thread_barriers_adjust(const f_number_unsigned_t length, f_thread_barriers_t * const barriers); + extern f_status_t f_thread_barriers_adjust(const f_number_unsigned_t length, f_thread_barriers_t * const structure); #endif // _di_f_thread_barriers_adjust_ /** @@ -91,7 +91,7 @@ extern "C" { * * @param amount * A positive number representing how much to decimate the size by. - * @param barriers + * @param structure * The thread barriers array to resize. * * @return @@ -102,7 +102,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_barriers_decimate_by_ - extern f_status_t f_thread_barriers_decimate_by(const f_number_unsigned_t amount, f_thread_barriers_t * const barriers); + extern f_status_t f_thread_barriers_decimate_by(const f_number_unsigned_t amount, f_thread_barriers_t * const structure); #endif // _di_f_thread_barriers_decimate_by_ /** @@ -114,7 +114,7 @@ extern "C" { * * @param amount * A positive number representing how much to decrease the size by. - * @param barriers + * @param structure * The thread barriers array to resize. * * @return @@ -125,7 +125,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_barriers_decrease_by_ - extern f_status_t f_thread_barriers_decrease_by(const f_number_unsigned_t amount, f_thread_barriers_t * const barriers); + extern f_status_t f_thread_barriers_decrease_by(const f_number_unsigned_t amount, f_thread_barriers_t * const structure); #endif // _di_f_thread_barriers_decrease_by_ /** @@ -137,7 +137,7 @@ extern "C" { * @param step * The allocation step to use. * Must be greater than 0. - * @param barriers + * @param structure * The thread barriers array to resize. * * @return @@ -149,7 +149,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_barriers_increase_ - extern f_status_t f_thread_barriers_increase(const f_number_unsigned_t step, f_thread_barriers_t * const barriers); + extern f_status_t f_thread_barriers_increase(const f_number_unsigned_t step, f_thread_barriers_t * const structure); #endif // _di_f_thread_barriers_increase_ /** @@ -161,7 +161,7 @@ extern "C" { * * @param amount * A positive number representing how much to increase the size by. - * @param barriers + * @param structure * The thread barriers array to resize. * * @return @@ -173,7 +173,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_barriers_increase_by_ - extern f_status_t f_thread_barriers_increase_by(const f_number_unsigned_t amount, f_thread_barriers_t * const barriers); + extern f_status_t f_thread_barriers_increase_by(const f_number_unsigned_t amount, f_thread_barriers_t * const structure); #endif // _di_f_thread_barriers_increase_by_ /** @@ -181,7 +181,7 @@ extern "C" { * * @param length * The new size to use. - * @param barriers + * @param structure * The thread barriers array to adjust. * * @return @@ -191,7 +191,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_barriers_resize_ - extern f_status_t f_thread_barriers_resize(const f_number_unsigned_t length, f_thread_barriers_t * const barriers); + extern f_status_t f_thread_barriers_resize(const f_number_unsigned_t length, f_thread_barriers_t * const structure); #endif // _di_f_thread_barriers_resize_ #ifdef __cplusplus diff --git a/level_0/f_thread/c/thread/barrier_attribute.c b/level_0/f_thread/c/thread/barrier_attribute.c index 2e23288..98f40b5 100644 --- a/level_0/f_thread/c/thread/barrier_attribute.c +++ b/level_0/f_thread/c/thread/barrier_attribute.c @@ -7,65 +7,55 @@ extern "C" { #endif #ifndef _di_f_thread_barrier_attributes_adjust_ - f_status_t f_thread_barrier_attributes_adjust(const f_number_unsigned_t length, f_thread_barrier_attributes_t * const attributes) { + f_status_t f_thread_barrier_attributes_adjust(const f_number_unsigned_t length, f_thread_barrier_attributes_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!attributes) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_thread_barrier_attributes_adjust(length, attributes); + return private_f_thread_barrier_attributes_adjust(length, structure); } #endif // _di_f_thread_barrier_attributes_adjust_ #ifndef _di_f_thread_barrier_attributes_decimate_by_ - f_status_t f_thread_barrier_attributes_decimate_by(const f_number_unsigned_t amount, f_thread_barrier_attributes_t * const attributes) { + f_status_t f_thread_barrier_attributes_decimate_by(const f_number_unsigned_t amount, f_thread_barrier_attributes_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!attributes) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - if (attributes->size > amount) { - return private_f_thread_barrier_attributes_adjust(attributes->size - amount, attributes); - } - - return private_f_thread_barrier_attributes_adjust(0, attributes); + return private_f_thread_barrier_attributes_adjust((structure->size > amount) ? structure->size - amount : 0, structure); } #endif // _di_f_thread_barrier_attributes_decimate_by_ #ifndef _di_f_thread_barrier_attributes_decrease_by_ - f_status_t f_thread_barrier_attributes_decrease_by(const f_number_unsigned_t amount, f_thread_barrier_attributes_t * const attributes) { + f_status_t f_thread_barrier_attributes_decrease_by(const f_number_unsigned_t amount, f_thread_barrier_attributes_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!attributes) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - if (attributes->size > amount) { - return private_f_thread_barrier_attributes_resize(attributes->size - amount, attributes); - } - - return private_f_thread_barrier_attributes_resize(0, attributes); + return private_f_thread_barrier_attributes_resize((structure->size > amount) ? structure->size - amount : 0, structure); } #endif // _di_f_thread_barrier_attributes_decrease_by_ #ifndef _di_f_thread_barrier_attributes_increase_ - f_status_t f_thread_barrier_attributes_increase(const f_number_unsigned_t step, f_thread_barrier_attributes_t * const attributes) { + f_status_t f_thread_barrier_attributes_increase(const f_number_unsigned_t step, f_thread_barrier_attributes_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!attributes) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (step && attributes->used + 1 > attributes->size) { - f_number_unsigned_t size = attributes->used + step; + if (step && structure->used + 1 > structure->size) { + f_number_unsigned_t length = structure->used + step; - if (size > F_number_t_size_unsigned_d) { - if (attributes->used + 1 > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + if (length > F_number_t_size_unsigned_d) { + if (structure->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - size = F_number_t_size_unsigned_d; + length = F_number_t_size_unsigned_d; } - return private_f_thread_barrier_attributes_resize(size, attributes); + return private_f_thread_barrier_attributes_resize(length, structure); } return F_data_not; @@ -73,20 +63,20 @@ extern "C" { #endif // _di_f_thread_barrier_attributes_increase_ #ifndef _di_f_thread_barrier_attributes_increase_by_ - f_status_t f_thread_barrier_attributes_increase_by(const f_number_unsigned_t amount, f_thread_barrier_attributes_t * const attributes) { + f_status_t f_thread_barrier_attributes_increase_by(const f_number_unsigned_t amount, f_thread_barrier_attributes_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!attributes) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (amount) { - if (attributes->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + if (structure->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - const f_number_unsigned_t length = attributes->used + amount; + const f_number_unsigned_t length = structure->used + amount; - if (length > attributes->size) { + if (length > structure->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 private_f_thread_barrier_attributes_resize(length, structure); } } @@ -95,12 +85,12 @@ extern "C" { #endif // _di_f_thread_barrier_attributes_increase_by_ #ifndef _di_f_thread_barrier_attributes_resize_ - f_status_t f_thread_barrier_attributes_resize(const f_number_unsigned_t length, f_thread_barrier_attributes_t * const attributes) { + f_status_t f_thread_barrier_attributes_resize(const f_number_unsigned_t length, f_thread_barrier_attributes_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!attributes) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_thread_barrier_attributes_resize(length, attributes); + return private_f_thread_barrier_attributes_resize(length, structure); } #endif // _di_f_thread_barrier_attributes_resize_ diff --git a/level_0/f_thread/c/thread/barrier_attribute.h b/level_0/f_thread/c/thread/barrier_attribute.h index 8a53e8e..0d7b577 100644 --- a/level_0/f_thread/c/thread/barrier_attribute.h +++ b/level_0/f_thread/c/thread/barrier_attribute.h @@ -66,12 +66,12 @@ extern "C" { #endif // _di_f_thread_barrier_attributes_t_ /** - * Resize the thread barrier attributes array. + * Resize the thread barrier_attributes array. * * @param length * The new size to use. - * @param attributes - * The thread attributes array to resize. + * @param structure + * The thread barrier_attributes array to resize. * * @return * F_none on success. @@ -80,11 +80,11 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_barrier_attributes_adjust_ - extern f_status_t f_thread_barrier_attributes_adjust(const f_number_unsigned_t length, f_thread_barrier_attributes_t * const attributes); + extern f_status_t f_thread_barrier_attributes_adjust(const f_number_unsigned_t length, f_thread_barrier_attributes_t * const structure); #endif // _di_f_thread_barrier_attributes_adjust_ /** - * Resize the thread barrier attributes array to a smaller size. + * Resize the thread barrier_attributes array to a smaller size. * * This will resize making the array smaller based on (size - given length). * If the given length is too small, then the resize will fail. @@ -92,8 +92,8 @@ extern "C" { * * @param amount * A positive number representing how much to decimate the size by. - * @param attributes - * The thread attributes array to resize. + * @param structure + * The thread barrier_attributes array to resize. * * @return * F_none on success. @@ -103,11 +103,11 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_barrier_attributes_decimate_by_ - extern f_status_t f_thread_barrier_attributes_decimate_by(const f_number_unsigned_t amount, f_thread_barrier_attributes_t * const attributes); + extern f_status_t f_thread_barrier_attributes_decimate_by(const f_number_unsigned_t amount, f_thread_barrier_attributes_t * const structure); #endif // _di_f_thread_barrier_attributes_decimate_by_ /** - * Resize the thread barrier attributes array to a smaller size. + * Resize the thread barrier_attributes array to a smaller size. * * This will resize making the array smaller based on (size - given length). * If the given length is too small, then the resize will fail. @@ -115,8 +115,8 @@ extern "C" { * * @param amount * A positive number representing how much to decrease the size by. - * @param attributes - * The thread attributes array to resize. + * @param structure + * The thread barrier_attributes array to resize. * * @return * F_none on success. @@ -126,11 +126,11 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_barrier_attributes_decrease_by_ - extern f_status_t f_thread_barrier_attributes_decrease_by(const f_number_unsigned_t amount, f_thread_barrier_attributes_t * const attributes); + extern f_status_t f_thread_barrier_attributes_decrease_by(const f_number_unsigned_t amount, f_thread_barrier_attributes_t * const structure); #endif // _di_f_thread_barrier_attributes_decrease_by_ /** - * Increase the size of the thread barrier attributes array, but only if necessary. + * Increase the size of the thread barrier_attributes array, 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. @@ -138,8 +138,8 @@ extern "C" { * @param step * The allocation step to use. * Must be greater than 0. - * @param attributes - * The thread attributes array to resize. + * @param structure + * The thread barrier_attributes array to resize. * * @return * F_none on success. @@ -150,11 +150,11 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_barrier_attributes_increase_ - extern f_status_t f_thread_barrier_attributes_increase(const f_number_unsigned_t step, f_thread_barrier_attributes_t * const attributes); + extern f_status_t f_thread_barrier_attributes_increase(const f_number_unsigned_t step, f_thread_barrier_attributes_t * const structure); #endif // _di_f_thread_barrier_attributes_increase_ /** - * Resize the thread barrier attributes array to a larger size. + * Resize the thread barrier_attributes array 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). @@ -162,8 +162,8 @@ extern "C" { * * @param amount * A positive number representing how much to increase the size by. - * @param attributes - * The thread attributes array to resize. + * @param structure + * The thread barrier_attributes array to resize. * * @return * F_none on success. @@ -174,16 +174,16 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_barrier_attributes_increase_by_ - extern f_status_t f_thread_barrier_attributes_increase_by(const f_number_unsigned_t amount, f_thread_barrier_attributes_t * const attributes); + extern f_status_t f_thread_barrier_attributes_increase_by(const f_number_unsigned_t amount, f_thread_barrier_attributes_t * const structure); #endif // _di_f_thread_barrier_attributes_increase_by_ /** - * Resize the thread barrier attributes array. + * Resize the thread barrier_attributes array. * * @param length * The new size to use. - * @param attributes - * The thread attributes array to adjust. + * @param structure + * The thread barrier_attributes array to adjust. * * @return * F_none on success. @@ -192,7 +192,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_barrier_attributes_resize_ - extern f_status_t f_thread_barrier_attributes_resize(const f_number_unsigned_t length, f_thread_barrier_attributes_t * const attributes); + extern f_status_t f_thread_barrier_attributes_resize(const f_number_unsigned_t length, f_thread_barrier_attributes_t * const structure); #endif // _di_f_thread_barrier_attributes_resize_ #ifdef __cplusplus diff --git a/level_0/f_thread/c/thread/condition.c b/level_0/f_thread/c/thread/condition.c index 523b63f..618df12 100644 --- a/level_0/f_thread/c/thread/condition.c +++ b/level_0/f_thread/c/thread/condition.c @@ -7,65 +7,55 @@ extern "C" { #endif #ifndef _di_f_thread_conditions_adjust_ - f_status_t f_thread_conditions_adjust(const f_number_unsigned_t length, f_thread_conditions_t * const conditions) { + f_status_t f_thread_conditions_adjust(const f_number_unsigned_t length, f_thread_conditions_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!conditions) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_thread_conditions_adjust(length, conditions); + return private_f_thread_conditions_adjust(length, structure); } #endif // _di_f_thread_conditions_adjust_ #ifndef _di_f_thread_conditions_decimate_by_ - f_status_t f_thread_conditions_decimate_by(const f_number_unsigned_t amount, f_thread_conditions_t * const conditions) { + f_status_t f_thread_conditions_decimate_by(const f_number_unsigned_t amount, f_thread_conditions_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!conditions) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - if (conditions->size > amount) { - return private_f_thread_conditions_adjust(conditions->size - amount, conditions); - } - - return private_f_thread_conditions_adjust(0, conditions); + return private_f_thread_conditions_adjust((structure->size > amount) ? structure->size - amount : 0, structure); } #endif // _di_f_thread_conditions_decimate_by_ #ifndef _di_f_thread_conditions_decrease_by_ - f_status_t f_thread_conditions_decrease_by(const f_number_unsigned_t amount, f_thread_conditions_t * const conditions) { + f_status_t f_thread_conditions_decrease_by(const f_number_unsigned_t amount, f_thread_conditions_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!conditions) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - if (conditions->size > amount) { - return private_f_thread_conditions_resize(conditions->size - amount, conditions); - } - - return private_f_thread_conditions_resize(0, conditions); + return private_f_thread_conditions_resize((structure->size > amount) ? structure->size - amount : 0, structure); } #endif // _di_f_thread_conditions_decrease_by_ #ifndef _di_f_thread_conditions_increase_ - f_status_t f_thread_conditions_increase(const f_number_unsigned_t step, f_thread_conditions_t * const conditions) { + f_status_t f_thread_conditions_increase(const f_number_unsigned_t step, f_thread_conditions_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!conditions) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (step && conditions->used + 1 > conditions->size) { - f_number_unsigned_t size = conditions->used + step; + if (step && structure->used + 1 > structure->size) { + f_number_unsigned_t length = structure->used + step; - if (size > F_number_t_size_unsigned_d) { - if (conditions->used + 1 > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + if (length > F_number_t_size_unsigned_d) { + if (structure->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - size = F_number_t_size_unsigned_d; + length = F_number_t_size_unsigned_d; } - return private_f_thread_conditions_resize(size, conditions); + return private_f_thread_conditions_resize(length, structure); } return F_data_not; @@ -73,20 +63,20 @@ extern "C" { #endif // _di_f_thread_conditions_increase_ #ifndef _di_f_thread_conditions_increase_by_ - f_status_t f_thread_conditions_increase_by(const f_number_unsigned_t amount, f_thread_conditions_t * const conditions) { + f_status_t f_thread_conditions_increase_by(const f_number_unsigned_t amount, f_thread_conditions_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!conditions) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (amount) { - if (conditions->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + if (structure->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - const f_number_unsigned_t length = conditions->used + amount; + const f_number_unsigned_t length = structure->used + amount; - if (length > conditions->size) { + if (length > structure->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 private_f_thread_conditions_resize(length, structure); } } @@ -95,12 +85,12 @@ extern "C" { #endif // _di_f_thread_conditions_increase_by_ #ifndef _di_f_thread_conditions_resize_ - f_status_t f_thread_conditions_resize(const f_number_unsigned_t length, f_thread_conditions_t * const conditions) { + f_status_t f_thread_conditions_resize(const f_number_unsigned_t length, f_thread_conditions_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!conditions) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_thread_conditions_resize(length, conditions); + return private_f_thread_conditions_resize(length, structure); } #endif // _di_f_thread_conditions_resize_ diff --git a/level_0/f_thread/c/thread/condition.h b/level_0/f_thread/c/thread/condition.h index b7bee62..fc87fae 100644 --- a/level_0/f_thread/c/thread/condition.h +++ b/level_0/f_thread/c/thread/condition.h @@ -70,8 +70,8 @@ extern "C" { * * @param length * The new size to use. - * @param conditions - * The string conditions array to resize. + * @param structure + * The thread conditions array to resize. * * @return * F_none on success. @@ -80,7 +80,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_conditions_adjust_ - extern f_status_t f_thread_conditions_adjust(const f_number_unsigned_t length, f_thread_conditions_t * const conditions); + extern f_status_t f_thread_conditions_adjust(const f_number_unsigned_t length, f_thread_conditions_t * const structure); #endif // _di_f_thread_conditions_adjust_ /** @@ -92,8 +92,8 @@ extern "C" { * * @param amount * A positive number representing how much to decimate the size by. - * @param conditions - * The string conditions array to resize. + * @param structure + * The thread conditions array to resize. * * @return * F_none on success. @@ -103,7 +103,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_conditions_decimate_by_ - extern f_status_t f_thread_conditions_decimate_by(const f_number_unsigned_t amount, f_thread_conditions_t * const conditions); + extern f_status_t f_thread_conditions_decimate_by(const f_number_unsigned_t amount, f_thread_conditions_t * const structure); #endif // _di_f_thread_conditions_decimate_by_ /** @@ -115,8 +115,8 @@ extern "C" { * * @param amount * A positive number representing how much to decrease the size by. - * @param conditions - * The string conditions array to resize. + * @param structure + * The thread conditions array to resize. * * @return * F_none on success. @@ -126,7 +126,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_conditions_decrease_by_ - extern f_status_t f_thread_conditions_decrease_by(const f_number_unsigned_t amount, f_thread_conditions_t * const conditions); + extern f_status_t f_thread_conditions_decrease_by(const f_number_unsigned_t amount, f_thread_conditions_t * const structure); #endif // _di_f_thread_conditions_decrease_by_ /** @@ -138,8 +138,8 @@ extern "C" { * @param step * The allocation step to use. * Must be greater than 0. - * @param conditions - * The string conditions array to resize. + * @param structure + * The thread conditions array to resize. * * @return * F_none on success. @@ -150,7 +150,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_conditions_increase_ - extern f_status_t f_thread_conditions_increase(const f_number_unsigned_t step, f_thread_conditions_t * const conditions); + extern f_status_t f_thread_conditions_increase(const f_number_unsigned_t step, f_thread_conditions_t * const structure); #endif // _di_f_thread_conditions_increase_ /** @@ -162,8 +162,8 @@ extern "C" { * * @param amount * A positive number representing how much to increase the size by. - * @param conditions - * The string conditions array to resize. + * @param structure + * The thread conditions array to resize. * * @return * F_none on success. @@ -174,7 +174,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_conditions_increase_by_ - extern f_status_t f_thread_conditions_increase_by(const f_number_unsigned_t amount, f_thread_conditions_t * const conditions); + extern f_status_t f_thread_conditions_increase_by(const f_number_unsigned_t amount, f_thread_conditions_t * const structure); #endif // _di_f_thread_conditions_increase_by_ /** @@ -182,8 +182,8 @@ extern "C" { * * @param length * The new size to use. - * @param conditions - * The string conditions array to adjust. + * @param structure + * The thread conditions array to adjust. * * @return * F_none on success. @@ -192,7 +192,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_conditions_resize_ - extern f_status_t f_thread_conditions_resize(const f_number_unsigned_t length, f_thread_conditions_t * const conditions); + extern f_status_t f_thread_conditions_resize(const f_number_unsigned_t length, f_thread_conditions_t * const structure); #endif // _di_f_thread_conditions_resize_ #ifdef __cplusplus diff --git a/level_0/f_thread/c/thread/condition_attribute.c b/level_0/f_thread/c/thread/condition_attribute.c index 740c503..5d2200a 100644 --- a/level_0/f_thread/c/thread/condition_attribute.c +++ b/level_0/f_thread/c/thread/condition_attribute.c @@ -7,65 +7,55 @@ extern "C" { #endif #ifndef _di_f_thread_condition_attributes_adjust_ - f_status_t f_thread_condition_attributes_adjust(const f_number_unsigned_t length, f_thread_condition_attributes_t * const attributes) { + f_status_t f_thread_condition_attributes_adjust(const f_number_unsigned_t length, f_thread_condition_attributes_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!attributes) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_thread_condition_attributes_adjust(length, attributes); + return private_f_thread_condition_attributes_adjust(length, structure); } #endif // _di_f_thread_condition_attributes_adjust_ #ifndef _di_f_thread_condition_attributes_decimate_by_ - f_status_t f_thread_condition_attributes_decimate_by(const f_number_unsigned_t amount, f_thread_condition_attributes_t * const attributes) { + f_status_t f_thread_condition_attributes_decimate_by(const f_number_unsigned_t amount, f_thread_condition_attributes_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!attributes) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - if (attributes->size > amount) { - return private_f_thread_condition_attributes_adjust(attributes->size - amount, attributes); - } - - return private_f_thread_condition_attributes_adjust(0, attributes); + return private_f_thread_condition_attributes_adjust((structure->size > amount) ? structure->size - amount : 0, structure); } #endif // _di_f_thread_condition_attributes_decimate_by_ #ifndef _di_f_thread_condition_attributes_decrease_by_ - f_status_t f_thread_condition_attributes_decrease_by(const f_number_unsigned_t amount, f_thread_condition_attributes_t * const attributes) { + f_status_t f_thread_condition_attributes_decrease_by(const f_number_unsigned_t amount, f_thread_condition_attributes_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!attributes) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - if (attributes->size > amount) { - return private_f_thread_condition_attributes_resize(attributes->size - amount, attributes); - } - - return private_f_thread_condition_attributes_resize(0, attributes); + return private_f_thread_condition_attributes_resize((structure->size > amount) ? structure->size - amount : 0, structure); } #endif // _di_f_thread_condition_attributes_decrease_by_ #ifndef _di_f_thread_condition_attributes_increase_ - f_status_t f_thread_condition_attributes_increase(const f_number_unsigned_t step, f_thread_condition_attributes_t * const attributes) { + f_status_t f_thread_condition_attributes_increase(const f_number_unsigned_t step, f_thread_condition_attributes_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!attributes) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (step && attributes->used + 1 > attributes->size) { - f_number_unsigned_t size = attributes->used + step; + if (step && structure->used + 1 > structure->size) { + f_number_unsigned_t length = structure->used + step; - if (size > F_number_t_size_unsigned_d) { - if (attributes->used + 1 > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + if (length > F_number_t_size_unsigned_d) { + if (structure->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - size = F_number_t_size_unsigned_d; + length = F_number_t_size_unsigned_d; } - return private_f_thread_condition_attributes_resize(size, attributes); + return private_f_thread_condition_attributes_resize(length, structure); } return F_data_not; @@ -73,20 +63,20 @@ extern "C" { #endif // _di_f_thread_condition_attributes_increase_ #ifndef _di_f_thread_condition_attributes_increase_by_ - f_status_t f_thread_condition_attributes_increase_by(const f_number_unsigned_t amount, f_thread_condition_attributes_t * const attributes) { + f_status_t f_thread_condition_attributes_increase_by(const f_number_unsigned_t amount, f_thread_condition_attributes_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!attributes) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (amount) { - if (attributes->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + if (structure->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - const f_number_unsigned_t length = attributes->used + amount; + const f_number_unsigned_t length = structure->used + amount; - if (length > attributes->size) { + if (length > structure->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 private_f_thread_condition_attributes_resize(length, structure); } } @@ -95,12 +85,12 @@ extern "C" { #endif // _di_f_thread_condition_attributes_increase_by_ #ifndef _di_f_thread_condition_attributes_resize_ - f_status_t f_thread_condition_attributes_resize(const f_number_unsigned_t length, f_thread_condition_attributes_t * const attributes) { + f_status_t f_thread_condition_attributes_resize(const f_number_unsigned_t length, f_thread_condition_attributes_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!attributes) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_thread_condition_attributes_resize(length, attributes); + return private_f_thread_condition_attributes_resize(length, structure); } #endif // _di_f_thread_condition_attributes_resize_ diff --git a/level_0/f_thread/c/thread/condition_attribute.h b/level_0/f_thread/c/thread/condition_attribute.h index f25bef8..cf2659d 100644 --- a/level_0/f_thread/c/thread/condition_attribute.h +++ b/level_0/f_thread/c/thread/condition_attribute.h @@ -66,12 +66,12 @@ extern "C" { #endif // _di_f_thread_condition_attributes_t_ /** - * Resize the thread attributes array. + * Resize the thread condition_attributes array. * * @param length * The new size to use. - * @param attributes - * The string attributes array to resize. + * @param structure + * The thread condition_attributes array to resize. * * @return * F_none on success. @@ -80,11 +80,11 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_condition_attributes_adjust_ - extern f_status_t f_thread_condition_attributes_adjust(const f_number_unsigned_t length, f_thread_condition_attributes_t * const attributes); + extern f_status_t f_thread_condition_attributes_adjust(const f_number_unsigned_t length, f_thread_condition_attributes_t * const structure); #endif // _di_f_thread_condition_attributes_adjust_ /** - * Resize the thread attributes array to a smaller size. + * Resize the thread condition_attributes array to a smaller size. * * This will resize making the array smaller based on (size - given length). * If the given length is too small, then the resize will fail. @@ -92,8 +92,8 @@ extern "C" { * * @param amount * A positive number representing how much to decimate the size by. - * @param attributes - * The string attributes array to resize. + * @param structure + * The thread condition_attributes array to resize. * * @return * F_none on success. @@ -103,11 +103,11 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_condition_attributes_decimate_by_ - extern f_status_t f_thread_condition_attributes_decimate_by(const f_number_unsigned_t amount, f_thread_condition_attributes_t * const attributes); + extern f_status_t f_thread_condition_attributes_decimate_by(const f_number_unsigned_t amount, f_thread_condition_attributes_t * const structure); #endif // _di_f_thread_condition_attributes_decimate_by_ /** - * Resize the thread attributes array to a smaller size. + * Resize the thread condition_attributes array to a smaller size. * * This will resize making the array smaller based on (size - given length). * If the given length is too small, then the resize will fail. @@ -115,8 +115,8 @@ extern "C" { * * @param amount * A positive number representing how much to decrease the size by. - * @param attributes - * The string attributes array to resize. + * @param structure + * The thread condition_attributes array to resize. * * @return * F_none on success. @@ -126,11 +126,11 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_condition_attributes_decrease_by_ - extern f_status_t f_thread_condition_attributes_decrease_by(const f_number_unsigned_t amount, f_thread_condition_attributes_t * const attributes); + extern f_status_t f_thread_condition_attributes_decrease_by(const f_number_unsigned_t amount, f_thread_condition_attributes_t * const structure); #endif // _di_f_thread_condition_attributes_decrease_by_ /** - * Increase the size of the thread attributes array, but only if necessary. + * Increase the size of the thread condition_attributes array, 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. @@ -138,8 +138,8 @@ extern "C" { * @param step * The allocation step to use. * Must be greater than 0. - * @param attributes - * The string attributes array to resize. + * @param structure + * The thread condition_attributes array to resize. * * @return * F_none on success. @@ -150,11 +150,11 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_condition_attributes_increase_ - extern f_status_t f_thread_condition_attributes_increase(const f_number_unsigned_t step, f_thread_condition_attributes_t * const attributes); + extern f_status_t f_thread_condition_attributes_increase(const f_number_unsigned_t step, f_thread_condition_attributes_t * const structure); #endif // _di_f_thread_condition_attributes_increase_ /** - * Resize the thread attributes array to a larger size. + * Resize the thread condition_attributes array 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). @@ -162,8 +162,8 @@ extern "C" { * * @param amount * A positive number representing how much to increase the size by. - * @param attributes - * The string attributes array to resize. + * @param structure + * The thread condition_attributes array to resize. * * @return * F_none on success. @@ -174,16 +174,16 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_condition_attributes_increase_by_ - extern f_status_t f_thread_condition_attributes_increase_by(const f_number_unsigned_t amount, f_thread_condition_attributes_t * const attributes); + extern f_status_t f_thread_condition_attributes_increase_by(const f_number_unsigned_t amount, f_thread_condition_attributes_t * const structure); #endif // _di_f_thread_condition_attributes_increase_by_ /** - * Resize the thread attributes array. + * Resize the thread condition_attributes array. * * @param length * The new size to use. - * @param attributes - * The string attributes array to adjust. + * @param structure + * The thread condition_attributes array to adjust. * * @return * F_none on success. @@ -192,7 +192,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_condition_attributes_resize_ - extern f_status_t f_thread_condition_attributes_resize(const f_number_unsigned_t length, f_thread_condition_attributes_t * const attributes); + extern f_status_t f_thread_condition_attributes_resize(const f_number_unsigned_t length, f_thread_condition_attributes_t * const structure); #endif // _di_f_thread_condition_attributes_resize_ #ifdef __cplusplus diff --git a/level_0/f_thread/c/thread/id.c b/level_0/f_thread/c/thread/id.c index 2bc8abd..d37b005 100644 --- a/level_0/f_thread/c/thread/id.c +++ b/level_0/f_thread/c/thread/id.c @@ -7,100 +7,62 @@ extern "C" { #endif #ifndef _di_f_thread_ids_adjust_ - f_status_t f_thread_ids_adjust(const f_number_unsigned_t length, f_thread_ids_t * const ids) { + f_status_t f_thread_ids_adjust(const f_number_unsigned_t length, f_thread_ids_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!ids) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_thread_ids_adjust(length, ids); + return f_memory_array_adjust(length, sizeof(f_thread_id_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_thread_ids_adjust_ #ifndef _di_f_thread_ids_decimate_by_ - f_status_t f_thread_ids_decimate_by(const f_number_unsigned_t amount, f_thread_ids_t * const ids) { + f_status_t f_thread_ids_decimate_by(const f_number_unsigned_t amount, f_thread_ids_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!ids) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; - - if (ids->size > amount) { - return private_f_thread_ids_adjust(ids->size - amount, ids); - } - - return private_f_thread_ids_adjust(0, ids); + return f_memory_array_decrease_by(amount, sizeof(f_thread_id_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_thread_ids_decimate_by_ #ifndef _di_f_thread_ids_decrease_by_ - f_status_t f_thread_ids_decrease_by(const f_number_unsigned_t amount, f_thread_ids_t * const ids) { + f_status_t f_thread_ids_decrease_by(const f_number_unsigned_t amount, f_thread_ids_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!ids) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; - - if (ids->size > amount) { - return private_f_thread_ids_resize(ids->size - amount, ids); - } - - return private_f_thread_ids_resize(0, ids); + return f_memory_array_decrease_by(amount, sizeof(f_thread_id_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_thread_ids_decrease_by_ #ifndef _di_f_thread_ids_increase_ - f_status_t f_thread_ids_increase(const f_number_unsigned_t step, f_thread_ids_t * const ids) { + f_status_t f_thread_ids_increase(const f_number_unsigned_t step, f_thread_ids_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!ids) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (step && ids->used + 1 > ids->size) { - f_number_unsigned_t size = ids->used + step; - - if (size > F_number_t_size_unsigned_d) { - if (ids->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_thread_ids_resize(size, ids); - } - - return F_data_not; + return f_memory_array_increase(step, sizeof(f_thread_id_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_thread_ids_increase_ #ifndef _di_f_thread_ids_increase_by_ - f_status_t f_thread_ids_increase_by(const f_number_unsigned_t amount, f_thread_ids_t * const ids) { + f_status_t f_thread_ids_increase_by(const f_number_unsigned_t amount, f_thread_ids_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!ids) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (amount) { - if (ids->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - - const f_number_unsigned_t length = ids->used + amount; - - 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; + return f_memory_array_increase_by(amount, sizeof(f_thread_id_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_thread_ids_increase_by_ #ifndef _di_f_thread_ids_resize_ - f_status_t f_thread_ids_resize(const f_number_unsigned_t length, f_thread_ids_t * const ids) { + f_status_t f_thread_ids_resize(const f_number_unsigned_t length, f_thread_ids_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!ids) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_thread_ids_resize(length, ids); + return f_memory_array_resize(length, sizeof(f_thread_id_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_thread_ids_resize_ diff --git a/level_0/f_thread/c/thread/id.h b/level_0/f_thread/c/thread/id.h index a252cd7..ad92ae0 100644 --- a/level_0/f_thread/c/thread/id.h +++ b/level_0/f_thread/c/thread/id.h @@ -65,7 +65,7 @@ extern "C" { * * @param length * The new size to use. - * @param ids + * @param structure * The thread ids array to resize. * * @return @@ -75,7 +75,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_ids_adjust_ - extern f_status_t f_thread_ids_adjust(const f_number_unsigned_t length, f_thread_ids_t * const ids); + extern f_status_t f_thread_ids_adjust(const f_number_unsigned_t length, f_thread_ids_t * const structure); #endif // _di_f_thread_ids_adjust_ /** @@ -87,7 +87,7 @@ extern "C" { * * @param amount * A positive number representing how much to decimate the size by. - * @param ids + * @param structure * The thread ids array to resize. * * @return @@ -98,7 +98,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_ids_decimate_by_ - extern f_status_t f_thread_ids_decimate_by(const f_number_unsigned_t amount, f_thread_ids_t * const ids); + extern f_status_t f_thread_ids_decimate_by(const f_number_unsigned_t amount, f_thread_ids_t * const structure); #endif // _di_f_thread_ids_decimate_by_ /** @@ -110,7 +110,7 @@ extern "C" { * * @param amount * A positive number representing how much to decrease the size by. - * @param ids + * @param structure * The thread ids array to resize. * * @return @@ -121,7 +121,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_ids_decrease_by_ - extern f_status_t f_thread_ids_decrease_by(const f_number_unsigned_t amount, f_thread_ids_t * const ids); + extern f_status_t f_thread_ids_decrease_by(const f_number_unsigned_t amount, f_thread_ids_t * const structure); #endif // _di_f_thread_ids_decrease_by_ /** @@ -133,7 +133,7 @@ extern "C" { * @param step * The allocation step to use. * Must be greater than 0. - * @param ids + * @param structure * The thread ids array to resize. * * @return @@ -145,7 +145,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_ids_increase_ - extern f_status_t f_thread_ids_increase(const f_number_unsigned_t step, f_thread_ids_t * const ids); + extern f_status_t f_thread_ids_increase(const f_number_unsigned_t step, f_thread_ids_t * const structure); #endif // _di_f_thread_ids_increase_ /** @@ -157,7 +157,7 @@ extern "C" { * * @param amount * A positive number representing how much to increase the size by. - * @param ids + * @param structure * The thread ids array to resize. * * @return @@ -169,7 +169,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_ids_increase_by_ - extern f_status_t f_thread_ids_increase_by(const f_number_unsigned_t amount, f_thread_ids_t * const ids); + extern f_status_t f_thread_ids_increase_by(const f_number_unsigned_t amount, f_thread_ids_t * const structure); #endif // _di_f_thread_ids_increase_by_ /** @@ -177,7 +177,7 @@ extern "C" { * * @param length * The new size to use. - * @param ids + * @param structure * The thread ids array to adjust. * * @return @@ -187,7 +187,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_ids_resize_ - extern f_status_t f_thread_ids_resize(const f_number_unsigned_t length, f_thread_ids_t * const ids); + extern f_status_t f_thread_ids_resize(const f_number_unsigned_t length, f_thread_ids_t * const structure); #endif // _di_f_thread_ids_resize_ #ifdef __cplusplus diff --git a/level_0/f_thread/c/thread/key.c b/level_0/f_thread/c/thread/key.c index f053118..177b419 100644 --- a/level_0/f_thread/c/thread/key.c +++ b/level_0/f_thread/c/thread/key.c @@ -7,65 +7,55 @@ extern "C" { #endif #ifndef _di_f_thread_keys_adjust_ - f_status_t f_thread_keys_adjust(const f_number_unsigned_t length, f_thread_keys_t * const keys) { + f_status_t f_thread_keys_adjust(const f_number_unsigned_t length, f_thread_keys_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!keys) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_thread_keys_adjust(length, keys); + return private_f_thread_keys_adjust(length, structure); } #endif // _di_f_thread_keys_adjust_ #ifndef _di_f_thread_keys_decimate_by_ - f_status_t f_thread_keys_decimate_by(const f_number_unsigned_t amount, f_thread_keys_t * const keys) { + f_status_t f_thread_keys_decimate_by(const f_number_unsigned_t amount, f_thread_keys_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!keys) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - if (keys->size > amount) { - return private_f_thread_keys_adjust(keys->size - amount, keys); - } - - return private_f_thread_keys_adjust(0, keys); + return private_f_thread_keys_adjust((structure->size > amount) ? structure->size - amount : 0, structure); } #endif // _di_f_thread_keys_decimate_by_ #ifndef _di_f_thread_keys_decrease_by_ - f_status_t f_thread_keys_decrease_by(const f_number_unsigned_t amount, f_thread_keys_t * const keys) { + f_status_t f_thread_keys_decrease_by(const f_number_unsigned_t amount, f_thread_keys_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!keys) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - if (keys->size > amount) { - return private_f_thread_keys_resize(keys->size - amount, keys); - } - - return private_f_thread_keys_resize(0, keys); + return private_f_thread_keys_resize((structure->size > amount) ? structure->size - amount : 0, structure); } #endif // _di_f_thread_keys_decrease_by_ #ifndef _di_f_thread_keys_increase_ - f_status_t f_thread_keys_increase(const f_number_unsigned_t step, f_thread_keys_t * const keys) { + f_status_t f_thread_keys_increase(const f_number_unsigned_t step, f_thread_keys_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!keys) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (step && keys->used + 1 > keys->size) { - f_number_unsigned_t size = keys->used + step; + if (step && structure->used + 1 > structure->size) { + f_number_unsigned_t length = structure->used + step; - if (size > F_number_t_size_unsigned_d) { - if (keys->used + 1 > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + if (length > F_number_t_size_unsigned_d) { + if (structure->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - size = F_number_t_size_unsigned_d; + length = F_number_t_size_unsigned_d; } - return private_f_thread_keys_resize(size, keys); + return private_f_thread_keys_resize(length, structure); } return F_data_not; @@ -73,20 +63,20 @@ extern "C" { #endif // _di_f_thread_keys_increase_ #ifndef _di_f_thread_keys_increase_by_ - f_status_t f_thread_keys_increase_by(const f_number_unsigned_t amount, f_thread_keys_t * const keys) { + f_status_t f_thread_keys_increase_by(const f_number_unsigned_t amount, f_thread_keys_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!keys) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (amount) { - if (keys->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + if (structure->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - const f_number_unsigned_t length = keys->used + amount; + const f_number_unsigned_t length = structure->used + amount; - if (length > keys->size) { + if (length > structure->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 private_f_thread_keys_resize(length, structure); } } @@ -95,12 +85,12 @@ extern "C" { #endif // _di_f_thread_keys_increase_by_ #ifndef _di_f_thread_keys_resize_ - f_status_t f_thread_keys_resize(const f_number_unsigned_t length, f_thread_keys_t * const keys) { + f_status_t f_thread_keys_resize(const f_number_unsigned_t length, f_thread_keys_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!keys) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_thread_keys_resize(length, keys); + return private_f_thread_keys_resize(length, structure); } #endif // _di_f_thread_keys_resize_ diff --git a/level_0/f_thread/c/thread/key.h b/level_0/f_thread/c/thread/key.h index 334b5c1..48211ce 100644 --- a/level_0/f_thread/c/thread/key.h +++ b/level_0/f_thread/c/thread/key.h @@ -69,8 +69,8 @@ extern "C" { * * @param length * The new size to use. - * @param keys - * The string keys array to resize. + * @param structure + * The thread keys array to resize. * * @return * F_none on success. @@ -79,7 +79,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_keys_adjust_ - extern f_status_t f_thread_keys_adjust(const f_number_unsigned_t length, f_thread_keys_t * const keys); + extern f_status_t f_thread_keys_adjust(const f_number_unsigned_t length, f_thread_keys_t * const structure); #endif // _di_f_thread_keys_adjust_ /** @@ -91,8 +91,8 @@ extern "C" { * * @param amount * A positive number representing how much to decimate the size by. - * @param keys - * The string keys array to resize. + * @param structure + * The thread keys array to resize. * * @return * F_none on success. @@ -102,7 +102,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_keys_decimate_by_ - extern f_status_t f_thread_keys_decimate_by(const f_number_unsigned_t amount, f_thread_keys_t * const keys); + extern f_status_t f_thread_keys_decimate_by(const f_number_unsigned_t amount, f_thread_keys_t * const structure); #endif // _di_f_thread_keys_decimate_by_ /** @@ -114,8 +114,8 @@ extern "C" { * * @param amount * A positive number representing how much to decrease the size by. - * @param keys - * The string keys array to resize. + * @param structure + * The thread keys array to resize. * * @return * F_none on success. @@ -125,7 +125,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_keys_decrease_by_ - extern f_status_t f_thread_keys_decrease_by(const f_number_unsigned_t amount, f_thread_keys_t * const keys); + extern f_status_t f_thread_keys_decrease_by(const f_number_unsigned_t amount, f_thread_keys_t * const structure); #endif // _di_f_thread_keys_decrease_by_ /** @@ -137,8 +137,8 @@ extern "C" { * @param step * The allocation step to use. * Must be greater than 0. - * @param keys - * The string keys array to resize. + * @param structure + * The thread keys array to resize. * * @return * F_none on success. @@ -149,7 +149,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_keys_increase_ - extern f_status_t f_thread_keys_increase(const f_number_unsigned_t step, f_thread_keys_t * const keys); + extern f_status_t f_thread_keys_increase(const f_number_unsigned_t step, f_thread_keys_t * const structure); #endif // _di_f_thread_keys_increase_ /** @@ -161,8 +161,8 @@ extern "C" { * * @param amount * A positive number representing how much to increase the size by. - * @param keys - * The string keys array to resize. + * @param structure + * The thread keys array to resize. * * @return * F_none on success. @@ -173,7 +173,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_keys_increase_by_ - extern f_status_t f_thread_keys_increase_by(const f_number_unsigned_t amount, f_thread_keys_t * const keys); + extern f_status_t f_thread_keys_increase_by(const f_number_unsigned_t amount, f_thread_keys_t * const structure); #endif // _di_f_thread_keys_increase_by_ /** @@ -181,8 +181,8 @@ extern "C" { * * @param length * The new size to use. - * @param keys - * The string keys array to adjust. + * @param structure + * The thread keys array to adjust. * * @return * F_none on success. @@ -191,7 +191,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_keys_resize_ - extern f_status_t f_thread_keys_resize(const f_number_unsigned_t length, f_thread_keys_t * const keys); + extern f_status_t f_thread_keys_resize(const f_number_unsigned_t length, f_thread_keys_t * const structure); #endif // _di_f_thread_keys_resize_ #ifdef __cplusplus diff --git a/level_0/f_thread/c/thread/lock.c b/level_0/f_thread/c/thread/lock.c index fef1541..0bfd995 100644 --- a/level_0/f_thread/c/thread/lock.c +++ b/level_0/f_thread/c/thread/lock.c @@ -7,65 +7,55 @@ extern "C" { #endif #ifndef _di_f_thread_locks_adjust_ - f_status_t f_thread_locks_adjust(const f_number_unsigned_t length, f_thread_locks_t * const locks) { + f_status_t f_thread_locks_adjust(const f_number_unsigned_t length, f_thread_locks_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!locks) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_thread_locks_adjust(length, locks); + return private_f_thread_locks_adjust(length, structure); } #endif // _di_f_thread_locks_adjust_ #ifndef _di_f_thread_locks_decimate_by_ - f_status_t f_thread_locks_decimate_by(const f_number_unsigned_t amount, f_thread_locks_t * const locks) { + f_status_t f_thread_locks_decimate_by(const f_number_unsigned_t amount, f_thread_locks_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!locks) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - if (locks->size > amount) { - return private_f_thread_locks_adjust(locks->size - amount, locks); - } - - return private_f_thread_locks_adjust(0, locks); + return private_f_thread_locks_adjust((structure->size > amount) ? structure->size - amount : 0, structure); } #endif // _di_f_thread_locks_decimate_by_ #ifndef _di_f_thread_locks_decrease_by_ - f_status_t f_thread_locks_decrease_by(const f_number_unsigned_t amount, f_thread_locks_t * const locks) { + f_status_t f_thread_locks_decrease_by(const f_number_unsigned_t amount, f_thread_locks_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!locks) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - if (locks->size > amount) { - return private_f_thread_locks_resize(locks->size - amount, locks); - } - - return private_f_thread_locks_resize(0, locks); + return private_f_thread_locks_resize((structure->size > amount) ? structure->size - amount : 0, structure); } #endif // _di_f_thread_locks_decrease_by_ #ifndef _di_f_thread_locks_increase_ - f_status_t f_thread_locks_increase(const f_number_unsigned_t step, f_thread_locks_t * const locks) { + f_status_t f_thread_locks_increase(const f_number_unsigned_t step, f_thread_locks_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!locks) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (step && locks->used + 1 > locks->size) { - f_number_unsigned_t size = locks->used + step; + if (step && structure->used + 1 > structure->size) { + f_number_unsigned_t length = structure->used + step; - if (size > F_number_t_size_unsigned_d) { - if (locks->used + 1 > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + if (length > F_number_t_size_unsigned_d) { + if (structure->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - size = F_number_t_size_unsigned_d; + length = F_number_t_size_unsigned_d; } - return private_f_thread_locks_resize(size, locks); + return private_f_thread_locks_resize(length, structure); } return F_data_not; @@ -73,20 +63,20 @@ extern "C" { #endif // _di_f_thread_locks_increase_ #ifndef _di_f_thread_locks_increase_by_ - f_status_t f_thread_locks_increase_by(const f_number_unsigned_t amount, f_thread_locks_t * const locks) { + f_status_t f_thread_locks_increase_by(const f_number_unsigned_t amount, f_thread_locks_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!locks) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (amount) { - if (locks->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + if (structure->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - const f_number_unsigned_t length = locks->used + amount; + const f_number_unsigned_t length = structure->used + amount; - if (length > locks->size) { + if (length > structure->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 private_f_thread_locks_resize(length, structure); } } @@ -95,12 +85,12 @@ extern "C" { #endif // _di_f_thread_locks_increase_by_ #ifndef _di_f_thread_locks_resize_ - f_status_t f_thread_locks_resize(const f_number_unsigned_t length, f_thread_locks_t * const locks) { + f_status_t f_thread_locks_resize(const f_number_unsigned_t length, f_thread_locks_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!locks) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_thread_locks_resize(length, locks); + return private_f_thread_locks_resize(length, structure); } #endif // _di_f_thread_locks_resize_ diff --git a/level_0/f_thread/c/thread/lock.h b/level_0/f_thread/c/thread/lock.h index f27ff87..2cae518 100644 --- a/level_0/f_thread/c/thread/lock.h +++ b/level_0/f_thread/c/thread/lock.h @@ -66,12 +66,12 @@ extern "C" { #endif // _di_f_thread_locks_t_ /** - * Resize the read/write locks array. + * Resize the thread locks array. * * @param length * The new size to use. - * @param locks - * The string locks array to resize. + * @param structure + * The thread locks array to resize. * * @return * F_none on success. @@ -80,11 +80,11 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_locks_adjust_ - extern f_status_t f_thread_locks_adjust(const f_number_unsigned_t length, f_thread_locks_t * const locks); + extern f_status_t f_thread_locks_adjust(const f_number_unsigned_t length, f_thread_locks_t * const structure); #endif // _di_f_thread_locks_adjust_ /** - * Resize the read/write locks array to a smaller size. + * Resize the thread locks array to a smaller size. * * This will resize making the array smaller based on (size - given length). * If the given length is too small, then the resize will fail. @@ -92,8 +92,8 @@ extern "C" { * * @param amount * A positive number representing how much to decimate the size by. - * @param locks - * The string locks array to resize. + * @param structure + * The thread locks array to resize. * * @return * F_none on success. @@ -103,11 +103,11 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_locks_decimate_by_ - extern f_status_t f_thread_locks_decimate_by(const f_number_unsigned_t amount, f_thread_locks_t * const locks); + extern f_status_t f_thread_locks_decimate_by(const f_number_unsigned_t amount, f_thread_locks_t * const structure); #endif // _di_f_thread_locks_decimate_by_ /** - * Resize the read/write locks array to a smaller size. + * Resize the thread locks array to a smaller size. * * This will resize making the array smaller based on (size - given length). * If the given length is too small, then the resize will fail. @@ -115,8 +115,8 @@ extern "C" { * * @param amount * A positive number representing how much to decrease the size by. - * @param locks - * The string locks array to resize. + * @param structure + * The thread locks array to resize. * * @return * F_none on success. @@ -126,11 +126,11 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_locks_decrease_by_ - extern f_status_t f_thread_locks_decrease_by(const f_number_unsigned_t amount, f_thread_locks_t * const locks); + extern f_status_t f_thread_locks_decrease_by(const f_number_unsigned_t amount, f_thread_locks_t * const structure); #endif // _di_f_thread_locks_decrease_by_ /** - * Increase the size of the read/write array, but only if necessary. + * Increase the size of the thread locks array, 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. @@ -138,8 +138,8 @@ extern "C" { * @param step * The allocation step to use. * Must be greater than 0. - * @param locks - * The string locks array to resize. + * @param structure + * The thread locks array to resize. * * @return * F_none on success. @@ -150,11 +150,11 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_locks_increase_ - extern f_status_t f_thread_locks_increase(const f_number_unsigned_t step, f_thread_locks_t * const locks); + extern f_status_t f_thread_locks_increase(const f_number_unsigned_t step, f_thread_locks_t * const structure); #endif // _di_f_thread_locks_increase_ /** - * Resize the read/write locks array to a larger size. + * Resize the thread locks array 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). @@ -162,8 +162,8 @@ extern "C" { * * @param amount * A positive number representing how much to increase the size by. - * @param locks - * The string locks array to resize. + * @param structure + * The thread locks array to resize. * * @return * F_none on success. @@ -174,16 +174,16 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_locks_increase_by_ - extern f_status_t f_thread_locks_increase_by(const f_number_unsigned_t amount, f_thread_locks_t * const locks); + extern f_status_t f_thread_locks_increase_by(const f_number_unsigned_t amount, f_thread_locks_t * const structure); #endif // _di_f_thread_locks_increase_by_ /** - * Resize the read/write locks array. + * Resize the thread locks array. * * @param length * The new size to use. - * @param locks - * The string locks array to adjust. + * @param structure + * The thread locks array to adjust. * * @return * F_none on success. @@ -192,7 +192,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_locks_resize_ - extern f_status_t f_thread_locks_resize(const f_number_unsigned_t length, f_thread_locks_t * const locks); + extern f_status_t f_thread_locks_resize(const f_number_unsigned_t length, f_thread_locks_t * const structure); #endif // _di_f_thread_locks_resize_ #ifdef __cplusplus diff --git a/level_0/f_thread/c/thread/lock_attribute.c b/level_0/f_thread/c/thread/lock_attribute.c index 60ac6cd..68d8b8b 100644 --- a/level_0/f_thread/c/thread/lock_attribute.c +++ b/level_0/f_thread/c/thread/lock_attribute.c @@ -7,65 +7,55 @@ extern "C" { #endif #ifndef _di_f_thread_lock_attributes_adjust_ - f_status_t f_thread_lock_attributes_adjust(const f_number_unsigned_t length, f_thread_lock_attributes_t * const attributes) { + f_status_t f_thread_lock_attributes_adjust(const f_number_unsigned_t length, f_thread_lock_attributes_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!attributes) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_thread_lock_attributes_adjust(length, attributes); + return private_f_thread_lock_attributes_adjust(length, structure); } #endif // _di_f_thread_lock_attributes_adjust_ #ifndef _di_f_thread_lock_attributes_decimate_by_ - f_status_t f_thread_lock_attributes_decimate_by(const f_number_unsigned_t amount, f_thread_lock_attributes_t * const attributes) { + f_status_t f_thread_lock_attributes_decimate_by(const f_number_unsigned_t amount, f_thread_lock_attributes_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!attributes) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - if (attributes->size > amount) { - return private_f_thread_lock_attributes_adjust(attributes->size - amount, attributes); - } - - return private_f_thread_lock_attributes_adjust(0, attributes); + return private_f_thread_lock_attributes_adjust((structure->size > amount) ? structure->size - amount : 0, structure); } #endif // _di_f_thread_lock_attributes_decimate_by_ #ifndef _di_f_thread_lock_attributes_decrease_by_ - f_status_t f_thread_lock_attributes_decrease_by(const f_number_unsigned_t amount, f_thread_lock_attributes_t * const attributes) { + f_status_t f_thread_lock_attributes_decrease_by(const f_number_unsigned_t amount, f_thread_lock_attributes_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!attributes) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - if (attributes->size > amount) { - return private_f_thread_lock_attributes_resize(attributes->size - amount, attributes); - } - - return private_f_thread_lock_attributes_resize(0, attributes); + return private_f_thread_lock_attributes_resize((structure->size > amount) ? structure->size - amount : 0, structure); } #endif // _di_f_thread_lock_attributes_decrease_by_ #ifndef _di_f_thread_lock_attributes_increase_ - f_status_t f_thread_lock_attributes_increase(const f_number_unsigned_t step, f_thread_lock_attributes_t * const attributes) { + f_status_t f_thread_lock_attributes_increase(const f_number_unsigned_t step, f_thread_lock_attributes_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!attributes) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (step && attributes->used + 1 > attributes->size) { - f_number_unsigned_t size = attributes->used + step; + if (step && structure->used + 1 > structure->size) { + f_number_unsigned_t length = structure->used + step; - if (size > F_number_t_size_unsigned_d) { - if (attributes->used + 1 > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + if (length > F_number_t_size_unsigned_d) { + if (structure->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - size = F_number_t_size_unsigned_d; + length = F_number_t_size_unsigned_d; } - return private_f_thread_lock_attributes_resize(size, attributes); + return private_f_thread_lock_attributes_resize(length, structure); } return F_data_not; @@ -73,20 +63,20 @@ extern "C" { #endif // _di_f_thread_lock_attributes_increase_ #ifndef _di_f_thread_lock_attributes_increase_by_ - f_status_t f_thread_lock_attributes_increase_by(const f_number_unsigned_t amount, f_thread_lock_attributes_t * const attributes) { + f_status_t f_thread_lock_attributes_increase_by(const f_number_unsigned_t amount, f_thread_lock_attributes_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!attributes) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (amount) { - if (attributes->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + if (structure->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - const f_number_unsigned_t length = attributes->used + amount; + const f_number_unsigned_t length = structure->used + amount; - if (length > attributes->size) { + if (length > structure->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 private_f_thread_lock_attributes_resize(length, structure); } } @@ -95,12 +85,12 @@ extern "C" { #endif // _di_f_thread_lock_attributes_increase_by_ #ifndef _di_f_thread_lock_attributes_resize_ - f_status_t f_thread_lock_attributes_resize(const f_number_unsigned_t length, f_thread_lock_attributes_t * const attributes) { + f_status_t f_thread_lock_attributes_resize(const f_number_unsigned_t length, f_thread_lock_attributes_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!attributes) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_thread_lock_attributes_resize(length, attributes); + return private_f_thread_lock_attributes_resize(length, structure); } #endif // _di_f_thread_lock_attributes_resize_ diff --git a/level_0/f_thread/c/thread/lock_attribute.h b/level_0/f_thread/c/thread/lock_attribute.h index b6f7773..96ec164 100644 --- a/level_0/f_thread/c/thread/lock_attribute.h +++ b/level_0/f_thread/c/thread/lock_attribute.h @@ -66,12 +66,12 @@ extern "C" { #endif // _di_f_thread_lock_attributes_t_ /** - * Resize the thread attributes array. + * Resize the thread lock_attributes array. * * @param length * The new size to use. - * @param attributes - * The string attributes array to resize. + * @param structure + * The thread lock_attributes array to resize. * * @return * F_none on success. @@ -80,11 +80,11 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_lock_attributes_adjust_ - extern f_status_t f_thread_lock_attributes_adjust(const f_number_unsigned_t length, f_thread_lock_attributes_t * const attributes); + extern f_status_t f_thread_lock_attributes_adjust(const f_number_unsigned_t length, f_thread_lock_attributes_t * const structure); #endif // _di_f_thread_lock_attributes_adjust_ /** - * Resize the thread attributes array to a smaller size. + * Resize the thread lock_attributes array to a smaller size. * * This will resize making the array smaller based on (size - given length). * If the given length is too small, then the resize will fail. @@ -92,8 +92,8 @@ extern "C" { * * @param amount * A positive number representing how much to decimate the size by. - * @param attributes - * The string attributes array to resize. + * @param structure + * The thread lock_attributes array to resize. * * @return * F_none on success. @@ -103,11 +103,11 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_lock_attributes_decimate_by_ - extern f_status_t f_thread_lock_attributes_decimate_by(const f_number_unsigned_t amount, f_thread_lock_attributes_t * const attributes); + extern f_status_t f_thread_lock_attributes_decimate_by(const f_number_unsigned_t amount, f_thread_lock_attributes_t * const structure); #endif // _di_f_thread_lock_attributes_decimate_by_ /** - * Resize the thread attributes array to a smaller size. + * Resize the thread lock_attributes array to a smaller size. * * This will resize making the array smaller based on (size - given length). * If the given length is too small, then the resize will fail. @@ -115,8 +115,8 @@ extern "C" { * * @param amount * A positive number representing how much to decrease the size by. - * @param attributes - * The string attributes array to resize. + * @param structure + * The thread lock_attributes array to resize. * * @return * F_none on success. @@ -126,11 +126,11 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_lock_attributes_decrease_by_ - extern f_status_t f_thread_lock_attributes_decrease_by(const f_number_unsigned_t amount, f_thread_lock_attributes_t * const attributes); + extern f_status_t f_thread_lock_attributes_decrease_by(const f_number_unsigned_t amount, f_thread_lock_attributes_t * const structure); #endif // _di_f_thread_lock_attributes_decrease_by_ /** - * Increase the size of the thread attributes array, but only if necessary. + * Increase the size of the thread lock_attributes array, 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. @@ -138,8 +138,8 @@ extern "C" { * @param step * The allocation step to use. * Must be greater than 0. - * @param attributes - * The string attributes array to resize. + * @param structure + * The thread lock_attributes array to resize. * * @return * F_none on success. @@ -150,11 +150,11 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_lock_attributes_increase_ - extern f_status_t f_thread_lock_attributes_increase(const f_number_unsigned_t step, f_thread_lock_attributes_t * const attributes); + extern f_status_t f_thread_lock_attributes_increase(const f_number_unsigned_t step, f_thread_lock_attributes_t * const structure); #endif // _di_f_thread_lock_attributes_increase_ /** - * Resize the thread attributes array to a larger size. + * Resize the thread lock_attributes array 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). @@ -162,28 +162,28 @@ extern "C" { * * @param amount * A positive number representing how much to increase the size by. - * @param attributes - * The string attributes array to resize. + * @param structure + * The thread lock_attributes array to resize. * * @return * F_none on success. * F_data_not on success, but there is no reason to increase size (used + amount <= size). * - * F_array_too_large (with error bit) if the new array length is too large + * 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. */ #ifndef _di_f_thread_lock_attributes_increase_by_ - extern f_status_t f_thread_lock_attributes_increase_by(const f_number_unsigned_t amount, f_thread_lock_attributes_t * const attributes); + extern f_status_t f_thread_lock_attributes_increase_by(const f_number_unsigned_t amount, f_thread_lock_attributes_t * const structure); #endif // _di_f_thread_lock_attributes_increase_by_ /** - * Resize the thread attributes array. + * Resize the thread lock_attributes array. * * @param length * The new size to use. - * @param attributes - * The string attributes array to adjust. + * @param structure + * The thread lock_attributes array to adjust. * * @return * F_none on success. @@ -192,7 +192,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_lock_attributes_resize_ - extern f_status_t f_thread_lock_attributes_resize(const f_number_unsigned_t length, f_thread_lock_attributes_t * const attributes); + extern f_status_t f_thread_lock_attributes_resize(const f_number_unsigned_t length, f_thread_lock_attributes_t * const structure); #endif // _di_f_thread_lock_attributes_resize_ #ifdef __cplusplus diff --git a/level_0/f_thread/c/thread/mutex.c b/level_0/f_thread/c/thread/mutex.c index 8a29002..376cf61 100644 --- a/level_0/f_thread/c/thread/mutex.c +++ b/level_0/f_thread/c/thread/mutex.c @@ -7,65 +7,55 @@ extern "C" { #endif #ifndef _di_f_thread_mutexs_adjust_ - f_status_t f_thread_mutexs_adjust(const f_number_unsigned_t length, f_thread_mutexs_t * const mutexs) { + f_status_t f_thread_mutexs_adjust(const f_number_unsigned_t length, f_thread_mutexs_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!mutexs) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_thread_mutexs_adjust(length, mutexs); + return private_f_thread_mutexs_adjust(length, structure); } #endif // _di_f_thread_mutexs_adjust_ #ifndef _di_f_thread_mutexs_decimate_by_ - f_status_t f_thread_mutexs_decimate_by(const f_number_unsigned_t amount, f_thread_mutexs_t * const mutexs) { + f_status_t f_thread_mutexs_decimate_by(const f_number_unsigned_t amount, f_thread_mutexs_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!mutexs) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - if (mutexs->size > amount) { - return private_f_thread_mutexs_adjust(mutexs->size - amount, mutexs); - } - - return private_f_thread_mutexs_adjust(0, mutexs); + return private_f_thread_mutexs_adjust((structure->size > amount) ? structure->size - amount : 0, structure); } #endif // _di_f_thread_mutexs_decimate_by_ #ifndef _di_f_thread_mutexs_decrease_by_ - f_status_t f_thread_mutexs_decrease_by(const f_number_unsigned_t amount, f_thread_mutexs_t * const mutexs) { + f_status_t f_thread_mutexs_decrease_by(const f_number_unsigned_t amount, f_thread_mutexs_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!mutexs) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - if (mutexs->size > amount) { - return private_f_thread_mutexs_resize(mutexs->size - amount, mutexs); - } - - return private_f_thread_mutexs_resize(0, mutexs); + return private_f_thread_mutexs_resize((structure->size > amount) ? structure->size - amount : 0, structure); } #endif // _di_f_thread_mutexs_decrease_by_ #ifndef _di_f_thread_mutexs_increase_ - f_status_t f_thread_mutexs_increase(const f_number_unsigned_t step, f_thread_mutexs_t * const mutexs) { + f_status_t f_thread_mutexs_increase(const f_number_unsigned_t step, f_thread_mutexs_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!mutexs) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (step && mutexs->used + 1 > mutexs->size) { - f_number_unsigned_t size = mutexs->used + step; + if (step && structure->used + 1 > structure->size) { + f_number_unsigned_t length = structure->used + step; - if (size > F_number_t_size_unsigned_d) { - if (mutexs->used + 1 > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + if (length > F_number_t_size_unsigned_d) { + if (structure->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - size = F_number_t_size_unsigned_d; + length = F_number_t_size_unsigned_d; } - return private_f_thread_mutexs_resize(size, mutexs); + return private_f_thread_mutexs_resize(length, structure); } return F_data_not; @@ -73,20 +63,20 @@ extern "C" { #endif // _di_f_thread_mutexs_increase_ #ifndef _di_f_thread_mutexs_increase_by_ - f_status_t f_thread_mutexs_increase_by(const f_number_unsigned_t amount, f_thread_mutexs_t * const mutexs) { + f_status_t f_thread_mutexs_increase_by(const f_number_unsigned_t amount, f_thread_mutexs_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!mutexs) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (amount) { - if (mutexs->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + if (structure->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - const f_number_unsigned_t length = mutexs->used + amount; + const f_number_unsigned_t length = structure->used + amount; - if (length > mutexs->size) { + if (length > structure->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 private_f_thread_mutexs_resize(length, structure); } } @@ -95,12 +85,12 @@ extern "C" { #endif // _di_f_thread_mutexs_increase_by_ #ifndef _di_f_thread_mutexs_resize_ - f_status_t f_thread_mutexs_resize(const f_number_unsigned_t length, f_thread_mutexs_t * const mutexs) { + f_status_t f_thread_mutexs_resize(const f_number_unsigned_t length, f_thread_mutexs_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!mutexs) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_thread_mutexs_resize(length, mutexs); + return private_f_thread_mutexs_resize(length, structure); } #endif // _di_f_thread_mutexs_resize_ diff --git a/level_0/f_thread/c/thread/mutex.h b/level_0/f_thread/c/thread/mutex.h index d159e8e..cacf0aa 100644 --- a/level_0/f_thread/c/thread/mutex.h +++ b/level_0/f_thread/c/thread/mutex.h @@ -72,8 +72,8 @@ extern "C" { * * @param length * The new size to use. - * @param mutexs - * The string mutexs array to resize. + * @param structure + * The thread mutexs array to resize. * * @return * F_none on success. @@ -82,7 +82,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_mutexs_adjust_ - extern f_status_t f_thread_mutexs_adjust(const f_number_unsigned_t length, f_thread_mutexs_t * const mutexs); + extern f_status_t f_thread_mutexs_adjust(const f_number_unsigned_t length, f_thread_mutexs_t * const structure); #endif // _di_f_thread_mutexs_adjust_ /** @@ -94,8 +94,8 @@ extern "C" { * * @param amount * A positive number representing how much to decimate the size by. - * @param mutexs - * The string mutexs array to resize. + * @param structure + * The thread mutexs array to resize. * * @return * F_none on success. @@ -105,7 +105,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_mutexs_decimate_by_ - extern f_status_t f_thread_mutexs_decimate_by(const f_number_unsigned_t amount, f_thread_mutexs_t * const mutexs); + extern f_status_t f_thread_mutexs_decimate_by(const f_number_unsigned_t amount, f_thread_mutexs_t * const structure); #endif // _di_f_thread_mutexs_decimate_by_ /** @@ -117,8 +117,8 @@ extern "C" { * * @param amount * A positive number representing how much to decrease the size by. - * @param mutexs - * The string mutexs array to resize. + * @param structure + * The thread mutexs array to resize. * * @return * F_none on success. @@ -128,7 +128,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_mutexs_decrease_by_ - extern f_status_t f_thread_mutexs_decrease_by(const f_number_unsigned_t amount, f_thread_mutexs_t * const mutexs); + extern f_status_t f_thread_mutexs_decrease_by(const f_number_unsigned_t amount, f_thread_mutexs_t * const structure); #endif // _di_f_thread_mutexs_decrease_by_ /** @@ -140,8 +140,8 @@ extern "C" { * @param step * The allocation step to use. * Must be greater than 0. - * @param mutexs - * The string mutexs array to resize. + * @param structure + * The thread mutexs array to resize. * * @return * F_none on success. @@ -152,7 +152,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_mutexs_increase_ - extern f_status_t f_thread_mutexs_increase(const f_number_unsigned_t step, f_thread_mutexs_t * const mutexs); + extern f_status_t f_thread_mutexs_increase(const f_number_unsigned_t step, f_thread_mutexs_t * const structure); #endif // _di_f_thread_mutexs_increase_ /** @@ -164,8 +164,8 @@ extern "C" { * * @param amount * A positive number representing how much to increase the size by. - * @param mutexs - * The string mutexs array to resize. + * @param structure + * The thread mutexs array to resize. * * @return * F_none on success. @@ -176,7 +176,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_mutexs_increase_by_ - extern f_status_t f_thread_mutexs_increase_by(const f_number_unsigned_t amount, f_thread_mutexs_t * const mutexs); + extern f_status_t f_thread_mutexs_increase_by(const f_number_unsigned_t amount, f_thread_mutexs_t * const structure); #endif // _di_f_thread_mutexs_increase_by_ /** @@ -184,8 +184,8 @@ extern "C" { * * @param length * The new size to use. - * @param mutexs - * The string mutexs array to adjust. + * @param structure + * The thread mutexs array to adjust. * * @return * F_none on success. @@ -194,7 +194,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_mutexs_resize_ - extern f_status_t f_thread_mutexs_resize(const f_number_unsigned_t length, f_thread_mutexs_t * const mutexs); + extern f_status_t f_thread_mutexs_resize(const f_number_unsigned_t length, f_thread_mutexs_t * const structure); #endif // _di_f_thread_mutexs_resize_ #ifdef __cplusplus diff --git a/level_0/f_thread/c/thread/mutex_attribute.c b/level_0/f_thread/c/thread/mutex_attribute.c index ea3ee60..4cc71ac 100644 --- a/level_0/f_thread/c/thread/mutex_attribute.c +++ b/level_0/f_thread/c/thread/mutex_attribute.c @@ -7,65 +7,55 @@ extern "C" { #endif #ifndef _di_f_thread_mutex_attributes_adjust_ - f_status_t f_thread_mutex_attributes_adjust(const f_number_unsigned_t length, f_thread_mutex_attributes_t * const attributes) { + f_status_t f_thread_mutex_attributes_adjust(const f_number_unsigned_t length, f_thread_mutex_attributes_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!attributes) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_thread_mutex_attributes_adjust(length, attributes); + return private_f_thread_mutex_attributes_adjust(length, structure); } #endif // _di_f_thread_mutex_attributes_adjust_ #ifndef _di_f_thread_mutex_attributes_decimate_by_ - f_status_t f_thread_mutex_attributes_decimate_by(const f_number_unsigned_t amount, f_thread_mutex_attributes_t * const attributes) { + f_status_t f_thread_mutex_attributes_decimate_by(const f_number_unsigned_t amount, f_thread_mutex_attributes_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!attributes) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - if (attributes->size > amount) { - return private_f_thread_mutex_attributes_adjust(attributes->size - amount, attributes); - } - - return private_f_thread_mutex_attributes_adjust(0, attributes); + return private_f_thread_mutex_attributes_adjust((structure->size > amount) ? structure->size - amount : 0, structure); } #endif // _di_f_thread_mutex_attributes_decimate_by_ #ifndef _di_f_thread_mutex_attributes_decrease_by_ - f_status_t f_thread_mutex_attributes_decrease_by(const f_number_unsigned_t amount, f_thread_mutex_attributes_t * const attributes) { + f_status_t f_thread_mutex_attributes_decrease_by(const f_number_unsigned_t amount, f_thread_mutex_attributes_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!attributes) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - if (attributes->size > amount) { - return private_f_thread_mutex_attributes_resize(attributes->size - amount, attributes); - } - - return private_f_thread_mutex_attributes_resize(0, attributes); + return private_f_thread_mutex_attributes_resize((structure->size > amount) ? structure->size - amount : 0, structure); } #endif // _di_f_thread_mutex_attributes_decrease_by_ #ifndef _di_f_thread_mutex_attributes_increase_ - f_status_t f_thread_mutex_attributes_increase(const f_number_unsigned_t step, f_thread_mutex_attributes_t * const attributes) { + f_status_t f_thread_mutex_attributes_increase(const f_number_unsigned_t step, f_thread_mutex_attributes_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!attributes) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (step && attributes->used + 1 > attributes->size) { - f_number_unsigned_t size = attributes->used + step; + if (step && structure->used + 1 > structure->size) { + f_number_unsigned_t length = structure->used + step; - if (size > F_number_t_size_unsigned_d) { - if (attributes->used + 1 > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + if (length > F_number_t_size_unsigned_d) { + if (structure->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - size = F_number_t_size_unsigned_d; + length = F_number_t_size_unsigned_d; } - return private_f_thread_mutex_attributes_resize(size, attributes); + return private_f_thread_mutex_attributes_resize(length, structure); } return F_data_not; @@ -73,20 +63,20 @@ extern "C" { #endif // _di_f_thread_mutex_attributes_increase_ #ifndef _di_f_thread_mutex_attributes_increase_by_ - f_status_t f_thread_mutex_attributes_increase_by(const f_number_unsigned_t amount, f_thread_mutex_attributes_t * const attributes) { + f_status_t f_thread_mutex_attributes_increase_by(const f_number_unsigned_t amount, f_thread_mutex_attributes_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!attributes) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (amount) { - if (attributes->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + if (structure->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - const f_number_unsigned_t length = attributes->used + amount; + const f_number_unsigned_t length = structure->used + amount; - if (length > attributes->size) { + if (length > structure->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 private_f_thread_mutex_attributes_resize(length, structure); } } @@ -95,12 +85,12 @@ extern "C" { #endif // _di_f_thread_mutex_attributes_increase_by_ #ifndef _di_f_thread_mutex_attributes_resize_ - f_status_t f_thread_mutex_attributes_resize(const f_number_unsigned_t length, f_thread_mutex_attributes_t * const attributes) { + f_status_t f_thread_mutex_attributes_resize(const f_number_unsigned_t length, f_thread_mutex_attributes_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!attributes) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_thread_mutex_attributes_resize(length, attributes); + return private_f_thread_mutex_attributes_resize(length, structure); } #endif // _di_f_thread_mutex_attributes_resize_ diff --git a/level_0/f_thread/c/thread/mutex_attribute.h b/level_0/f_thread/c/thread/mutex_attribute.h index 0cfd9a8..f3d06ef 100644 --- a/level_0/f_thread/c/thread/mutex_attribute.h +++ b/level_0/f_thread/c/thread/mutex_attribute.h @@ -66,12 +66,12 @@ extern "C" { #endif // _di_f_thread_mutex_attributes_t_ /** - * Resize the thread attributes array. + * Resize the thread mutex_attributes array. * * @param length * The new size to use. - * @param attributes - * The thread mutex attributes array to resize. + * @param structure + * The thread mutex_attributes array to resize. * * @return * F_none on success. @@ -80,11 +80,11 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_mutex_attributes_adjust_ - extern f_status_t f_thread_mutex_attributes_adjust(const f_number_unsigned_t length, f_thread_mutex_attributes_t * const attributes); + extern f_status_t f_thread_mutex_attributes_adjust(const f_number_unsigned_t length, f_thread_mutex_attributes_t * const structure); #endif // _di_f_thread_mutex_attributes_adjust_ /** - * Resize the thread attributes array to a smaller size. + * Resize the thread mutex_attributes array to a smaller size. * * This will resize making the array smaller based on (size - given length). * If the given length is too small, then the resize will fail. @@ -92,8 +92,8 @@ extern "C" { * * @param amount * A positive number representing how much to decimate the size by. - * @param attributes - * The thread mutex attributes array to resize. + * @param structure + * The thread mutex_attributes array to resize. * * @return * F_none on success. @@ -103,11 +103,11 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_mutex_attributes_decimate_by_ - extern f_status_t f_thread_mutex_attributes_decimate_by(const f_number_unsigned_t amount, f_thread_mutex_attributes_t * const attributes); + extern f_status_t f_thread_mutex_attributes_decimate_by(const f_number_unsigned_t amount, f_thread_mutex_attributes_t * const structure); #endif // _di_f_thread_mutex_attributes_decimate_by_ /** - * Resize the thread attributes array to a smaller size. + * Resize the thread mutex_attributes array to a smaller size. * * This will resize making the array smaller based on (size - given length). * If the given length is too small, then the resize will fail. @@ -115,8 +115,8 @@ extern "C" { * * @param amount * A positive number representing how much to decrease the size by. - * @param attributes - * The thread mutex attributes array to resize. + * @param structure + * The thread mutex_attributes array to resize. * * @return * F_none on success. @@ -126,11 +126,11 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_mutex_attributes_decrease_by_ - extern f_status_t f_thread_mutex_attributes_decrease_by(const f_number_unsigned_t amount, f_thread_mutex_attributes_t * const attributes); + extern f_status_t f_thread_mutex_attributes_decrease_by(const f_number_unsigned_t amount, f_thread_mutex_attributes_t * const structure); #endif // _di_f_thread_mutex_attributes_decrease_by_ /** - * Increase the size of the thread attributes array, but only if necessary. + * Increase the size of the thread mutex_attributes array, 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. @@ -138,8 +138,8 @@ extern "C" { * @param step * The allocation step to use. * Must be greater than 0. - * @param attributes - * The thread mutex attributes array to resize. + * @param structure + * The thread mutex_attributes array to resize. * * @return * F_none on success. @@ -150,11 +150,11 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_mutex_attributes_increase_ - extern f_status_t f_thread_mutex_attributes_increase(const f_number_unsigned_t step, f_thread_mutex_attributes_t * const attributes); + extern f_status_t f_thread_mutex_attributes_increase(const f_number_unsigned_t step, f_thread_mutex_attributes_t * const structure); #endif // _di_f_thread_mutex_attributes_increase_ /** - * Resize the thread attributes array to a larger size. + * Resize the thread mutex_attributes array 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). @@ -162,8 +162,8 @@ extern "C" { * * @param amount * A positive number representing how much to increase the size by. - * @param attributes - * The thread mutex attributes array to resize. + * @param structure + * The thread mutex_attributes array to resize. * * @return * F_none on success. @@ -174,16 +174,16 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_mutex_attributes_increase_by_ - extern f_status_t f_thread_mutex_attributes_increase_by(const f_number_unsigned_t amount, f_thread_mutex_attributes_t * const attributes); + extern f_status_t f_thread_mutex_attributes_increase_by(const f_number_unsigned_t amount, f_thread_mutex_attributes_t * const structure); #endif // _di_f_thread_mutex_attributes_increase_by_ /** - * Resize the thread attributes array. + * Resize the thread mutex_attributes array. * * @param length * The new size to use. - * @param attributes - * The thread mutex attributes array to adjust. + * @param structure + * The thread mutex_attributes array to adjust. * * @return * F_none on success. @@ -192,7 +192,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_mutex_attributes_resize_ - extern f_status_t f_thread_mutex_attributes_resize(const f_number_unsigned_t length, f_thread_mutex_attributes_t * const attributes); + extern f_status_t f_thread_mutex_attributes_resize(const f_number_unsigned_t length, f_thread_mutex_attributes_t * const structure); #endif // _di_f_thread_mutex_attributes_resize_ #ifdef __cplusplus diff --git a/level_0/f_thread/c/thread/once.c b/level_0/f_thread/c/thread/once.c index 93e0e8e..f7a7514 100644 --- a/level_0/f_thread/c/thread/once.c +++ b/level_0/f_thread/c/thread/once.c @@ -7,100 +7,62 @@ extern "C" { #endif #ifndef _di_f_thread_onces_adjust_ - f_status_t f_thread_onces_adjust(const f_number_unsigned_t length, f_thread_onces_t * const onces) { + f_status_t f_thread_onces_adjust(const f_number_unsigned_t length, f_thread_onces_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!onces) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_thread_onces_adjust(length, onces); + return f_memory_array_adjust(length, sizeof(f_thread_once_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_thread_onces_adjust_ #ifndef _di_f_thread_onces_decimate_by_ - f_status_t f_thread_onces_decimate_by(const f_number_unsigned_t amount, f_thread_onces_t * const onces) { + f_status_t f_thread_onces_decimate_by(const f_number_unsigned_t amount, f_thread_onces_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!onces) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; - - if (onces->size > amount) { - return private_f_thread_onces_adjust(onces->size - amount, onces); - } - - return private_f_thread_onces_adjust(0, onces); + return f_memory_array_decimate_by(amount, sizeof(f_thread_once_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_thread_onces_decimate_by_ #ifndef _di_f_thread_onces_decrease_by_ - f_status_t f_thread_onces_decrease_by(const f_number_unsigned_t amount, f_thread_onces_t * const onces) { + f_status_t f_thread_onces_decrease_by(const f_number_unsigned_t amount, f_thread_onces_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!onces) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; - - if (onces->size > amount) { - return private_f_thread_onces_resize(onces->size - amount, onces); - } - - return private_f_thread_onces_resize(0, onces); + return f_memory_array_decrease_by(amount, sizeof(f_thread_once_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_thread_onces_decrease_by_ #ifndef _di_f_thread_onces_increase_ - f_status_t f_thread_onces_increase(const f_number_unsigned_t step, f_thread_onces_t * const onces) { + f_status_t f_thread_onces_increase(const f_number_unsigned_t step, f_thread_onces_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!onces) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (step && onces->used + 1 > onces->size) { - f_number_unsigned_t size = onces->used + step; - - if (size > F_number_t_size_unsigned_d) { - if (onces->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_thread_onces_resize(size, onces); - } - - return F_data_not; + return f_memory_array_increase(step, sizeof(f_thread_once_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_thread_onces_increase_ #ifndef _di_f_thread_onces_increase_by_ - f_status_t f_thread_onces_increase_by(const f_number_unsigned_t amount, f_thread_onces_t * const onces) { + f_status_t f_thread_onces_increase_by(const f_number_unsigned_t amount, f_thread_onces_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!onces) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (amount) { - if (onces->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - - const f_number_unsigned_t length = onces->used + amount; - - 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; + return f_memory_array_increase_by(amount, sizeof(f_thread_once_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_thread_onces_increase_by_ #ifndef _di_f_thread_onces_resize_ - f_status_t f_thread_onces_resize(const f_number_unsigned_t length, f_thread_onces_t * const onces) { + f_status_t f_thread_onces_resize(const f_number_unsigned_t length, f_thread_onces_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!onces) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_thread_onces_resize(length, onces); + return f_memory_array_resize(length, sizeof(f_thread_once_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_thread_onces_resize_ diff --git a/level_0/f_thread/c/thread/once.h b/level_0/f_thread/c/thread/once.h index d62c39f..52c55aa 100644 --- a/level_0/f_thread/c/thread/once.h +++ b/level_0/f_thread/c/thread/once.h @@ -70,7 +70,7 @@ extern "C" { * * @param length * The new size to use. - * @param onces + * @param structure * The thread onces array to resize. * * @return @@ -80,7 +80,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_onces_adjust_ - extern f_status_t f_thread_onces_adjust(const f_number_unsigned_t length, f_thread_onces_t * const onces); + extern f_status_t f_thread_onces_adjust(const f_number_unsigned_t length, f_thread_onces_t * const structure); #endif // _di_f_thread_onces_adjust_ /** @@ -92,7 +92,7 @@ extern "C" { * * @param amount * A positive number representing how much to decimate the size by. - * @param onces + * @param structure * The thread onces array to resize. * * @return @@ -103,7 +103,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_onces_decimate_by_ - extern f_status_t f_thread_onces_decimate_by(const f_number_unsigned_t amount, f_thread_onces_t * const onces); + extern f_status_t f_thread_onces_decimate_by(const f_number_unsigned_t amount, f_thread_onces_t * const structure); #endif // _di_f_thread_onces_decimate_by_ /** @@ -115,7 +115,7 @@ extern "C" { * * @param amount * A positive number representing how much to decrease the size by. - * @param onces + * @param structure * The thread onces array to resize. * * @return @@ -126,7 +126,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_onces_decrease_by_ - extern f_status_t f_thread_onces_decrease_by(const f_number_unsigned_t amount, f_thread_onces_t * const onces); + extern f_status_t f_thread_onces_decrease_by(const f_number_unsigned_t amount, f_thread_onces_t * const structure); #endif // _di_f_thread_onces_decrease_by_ /** @@ -138,7 +138,7 @@ extern "C" { * @param step * The allocation step to use. * Must be greater than 0. - * @param onces + * @param structure * The thread onces array to resize. * * @return @@ -150,7 +150,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_onces_increase_ - extern f_status_t f_thread_onces_increase(const f_number_unsigned_t step, f_thread_onces_t * const onces); + extern f_status_t f_thread_onces_increase(const f_number_unsigned_t step, f_thread_onces_t * const structure); #endif // _di_f_thread_onces_increase_ /** @@ -162,7 +162,7 @@ extern "C" { * * @param amount * A positive number representing how much to increase the size by. - * @param onces + * @param structure * The thread onces array to resize. * * @return @@ -174,7 +174,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_onces_increase_by_ - extern f_status_t f_thread_onces_increase_by(const f_number_unsigned_t amount, f_thread_onces_t * const onces); + extern f_status_t f_thread_onces_increase_by(const f_number_unsigned_t amount, f_thread_onces_t * const structure); #endif // _di_f_thread_onces_increase_by_ /** @@ -182,7 +182,7 @@ extern "C" { * * @param length * The new size to use. - * @param onces + * @param structure * The thread onces array to adjust. * * @return @@ -192,7 +192,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_onces_resize_ - extern f_status_t f_thread_onces_resize(const f_number_unsigned_t length, f_thread_onces_t * const onces); + extern f_status_t f_thread_onces_resize(const f_number_unsigned_t length, f_thread_onces_t * const structure); #endif // _di_f_thread_onces_resize_ #ifdef __cplusplus diff --git a/level_0/f_thread/c/thread/private-attribute.c b/level_0/f_thread/c/thread/private-attribute.c index e2491f3..40425bb 100644 --- a/level_0/f_thread/c/thread/private-attribute.c +++ b/level_0/f_thread/c/thread/private-attribute.c @@ -6,11 +6,9 @@ extern "C" { #endif #if !defined(_di_f_thread_attributes_adjust_) || !defined(_di_f_thread_attributes_decimate_by_) || !defined(_di_f_thread_attributes_decrease_) || !defined(_di_f_thread_attributes_decrease_by_) || !defined(_di_f_thread_attributes_increase_) || !defined(_di_f_thread_attributes_increase_by_) || !defined(_di_f_thread_attributes_resize_) || !defined(_di_f_thread_sets_adjust_) || !defined(_di_f_thread_sets_decimate_by_) || !defined(_di_f_thread_sets_decrease_) || !defined(_di_f_thread_sets_decrease_by_) || !defined(_di_f_thread_sets_increase_) || !defined(_di_f_thread_sets_increase_by_) || !defined(_di_f_thread_sets_resize_) - f_status_t private_f_thread_attribute_delete(f_thread_attribute_t *attribute) { + f_status_t private_f_thread_attribute_delete(f_thread_attribute_t *structure) { - if (pthread_attr_destroy(attribute)) return F_status_set_error(F_failure); - - attribute = 0; + if (pthread_attr_destroy(structure)) return F_status_set_error(F_failure); return F_none; } diff --git a/level_0/f_thread/c/thread/private-attribute.h b/level_0/f_thread/c/thread/private-attribute.h index 3926891..195cd6f 100644 --- a/level_0/f_thread/c/thread/private-attribute.h +++ b/level_0/f_thread/c/thread/private-attribute.h @@ -22,8 +22,8 @@ extern "C" { * * @param length * The new size to use. - * @param attributes - * The attributes to adjust. + * @param structure + * The thread attribute to delete. * * @return * F_none on success. @@ -50,7 +50,7 @@ extern "C" { * @see f_thread_sets_resize() */ #if !defined(_di_f_thread_attributes_adjust_) || !defined(_di_f_thread_attributes_decimate_by_) || !defined(_di_f_thread_attributes_decrease_) || !defined(_di_f_thread_attributes_decrease_by_) || !defined(_di_f_thread_attributes_increase_) || !defined(_di_f_thread_attributes_increase_by_) || !defined(_di_f_thread_attributes_resize_) || !defined(_di_f_thread_sets_adjust_) || !defined(_di_f_thread_sets_decimate_by_) || !defined(_di_f_thread_sets_decrease_) || !defined(_di_f_thread_sets_decrease_by_) || !defined(_di_f_thread_sets_increase_) || !defined(_di_f_thread_sets_increase_by_) || !defined(_di_f_thread_sets_resize_) - extern f_status_t private_f_thread_attribute_delete(f_thread_attribute_t *attribute) F_attribute_visibility_internal_d; + extern f_status_t private_f_thread_attribute_delete(f_thread_attribute_t *structure) F_attribute_visibility_internal_d; #endif // !defined(_di_f_thread_attributes_adjust_) || !defined(_di_f_thread_attributes_decimate_by_) || !defined(_di_f_thread_attributes_decrease_) || !defined(_di_f_thread_attributes_decrease_by_) || !defined(_di_f_thread_attributes_increase_) || !defined(_di_f_thread_attributes_increase_by_) || !defined(_di_f_thread_sets_adjust_) || !defined(_di_f_thread_sets_decimate_by_) || !defined(_di_f_thread_sets_decrease_) || !defined(_di_f_thread_sets_decrease_by_) || !defined(_di_f_thread_sets_increase_) || !defined(_di_f_thread_sets_increase_by_) /** @@ -144,9 +144,10 @@ extern "C" { * @return * F_none on success. * - * Errors (with error bit) from: f_memory_adjust(). + * Errors (with error bit) from: f_memory_array_adjust(). + * + * @see f_memory_array_adjust() * - * @see f_memory_adjust() * @see f_thread_barriers_adjust() * @see f_thread_barriers_decimate_by() */ diff --git a/level_0/f_thread/c/thread/private-barrier.c b/level_0/f_thread/c/thread/private-barrier.c index 895804e..b9535e5 100644 --- a/level_0/f_thread/c/thread/private-barrier.c +++ b/level_0/f_thread/c/thread/private-barrier.c @@ -6,9 +6,9 @@ extern "C" { #endif #if !defined(_di_f_thread_barriers_adjust_) || !defined(_di_f_thread_barriers_decimate_by_) || !defined(_di_f_thread_barriers_decrease_) || !defined(_di_f_thread_barriers_decrease_by_) || !defined(_di_f_thread_barriers_increase_) || !defined(_di_f_thread_barriers_increase_by_) || !defined(_di_f_thread_barriers_resize_) - f_status_t private_f_thread_barrier_delete(f_thread_barrier_t *barrier) { + f_status_t private_f_thread_barrier_delete(f_thread_barrier_t *structure) { - const int error = pthread_barrier_destroy(barrier); + const int error = pthread_barrier_destroy(structure); if (error) { if (error == EBUSY) return F_status_set_error(F_busy); @@ -17,39 +17,37 @@ extern "C" { return F_status_set_error(F_failure); } - barrier = 0; - return F_none; } #endif // !defined(_di_f_thread_barriers_adjust_) || !defined(_di_f_thread_barriers_decimate_by_) || !defined(_di_f_thread_barriers_decrease_) || !defined(_di_f_thread_barriers_decrease_by_) || !defined(_di_f_thread_barriers_increase_) || !defined(_di_f_thread_barriers_increase_by_) || !defined(_di_f_thread_barriers_resize_) #if !defined(_di_f_thread_barriers_adjust_) || !defined(_di_f_thread_barriers_decimate_by_) - f_status_t private_f_thread_barriers_adjust(const f_number_unsigned_t length, f_thread_barriers_t * const barriers) { + f_status_t private_f_thread_barriers_adjust(const f_number_unsigned_t length, f_thread_barriers_t * const structure) { f_status_t status = F_none; - for (f_number_unsigned_t i = length; i < barriers->size; ++i) { + for (f_number_unsigned_t i = length; i < structure->size; ++i) { - status = private_f_thread_barrier_delete(&barriers->array[i]); + status = private_f_thread_barrier_delete(&structure->array[i]); if (F_status_is_error(status)) return status; } // for - return f_memory_array_adjust(length, sizeof(f_thread_barrier_t), (void **) &barriers->array, &barriers->used, &barriers->size); + return f_memory_array_adjust(length, sizeof(f_thread_barrier_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // !defined(_di_f_thread_barriers_adjust_) || !defined(_di_f_thread_barriers_decimate_by_) #if !defined(_di_f_thread_barriers_decrease_) || !defined(_di_f_thread_barriers_decrease_by_) || !defined(_di_f_thread_barriers_increase_) || !defined(_di_f_thread_barriers_increase_by_) - f_status_t private_f_thread_barriers_resize(const f_number_unsigned_t length, f_thread_barriers_t * const barriers) { + f_status_t private_f_thread_barriers_resize(const f_number_unsigned_t length, f_thread_barriers_t * const structure) { f_status_t status = F_none; - for (f_number_unsigned_t i = length; i < barriers->size; ++i) { + for (f_number_unsigned_t i = length; i < structure->size; ++i) { - status = private_f_thread_barrier_delete(&barriers->array[i]); + status = private_f_thread_barrier_delete(&structure->array[i]); if (F_status_is_error(status)) return status; } // for - return f_memory_array_resize(length, sizeof(f_thread_barrier_t), (void **) &barriers->array, &barriers->used, &barriers->size); + return f_memory_array_resize(length, sizeof(f_thread_barrier_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // !defined(_di_f_thread_barriers_decrease_) || !defined(_di_f_thread_barriers_decrease_by_) || !defined(_di_f_thread_barriers_increase_) || !defined(_di_f_thread_barriers_increase_by_) diff --git a/level_0/f_thread/c/thread/private-barrier.h b/level_0/f_thread/c/thread/private-barrier.h index 7a13de5..a0551a0 100644 --- a/level_0/f_thread/c/thread/private-barrier.h +++ b/level_0/f_thread/c/thread/private-barrier.h @@ -22,8 +22,8 @@ extern "C" { * * @param length * The new size to use. - * @param barriers - * The barriers to adjust. + * @param structure + * The barrier to delete. * * @return * F_none on success. @@ -43,7 +43,7 @@ extern "C" { * @see f_thread_barriers_resize() */ #if !defined(_di_f_thread_barriers_adjust_) || !defined(_di_f_thread_barriers_decimate_by_) || !defined(_di_f_thread_barriers_decrease_) || !defined(_di_f_thread_barriers_decrease_by_) || !defined(_di_f_thread_barriers_increase_) || !defined(_di_f_thread_barriers_increase_by_) || !defined(_di_f_thread_barriers_resize_) - extern f_status_t private_f_thread_barrier_delete(f_thread_barrier_t *barrier) F_attribute_visibility_internal_d; + extern f_status_t private_f_thread_barrier_delete(f_thread_barrier_t *structure) F_attribute_visibility_internal_d; #endif // !defined(_di_f_thread_barriers_adjust_) || !defined(_di_f_thread_barriers_decimate_by_) || !defined(_di_f_thread_barriers_decrease_) || !defined(_di_f_thread_barriers_decrease_by_) || !defined(_di_f_thread_barriers_increase_) || !defined(_di_f_thread_barriers_increase_by_) || !defined(_di_f_thread_barriers_resize_) /** @@ -53,20 +53,21 @@ extern "C" { * * @param length * The new size to use. - * @param barriers + * @param structure * The barriers to adjust. * * @return * F_none on success. * - * Errors (with error bit) from: f_memory_adjust(). + * Errors (with error bit) from: f_memory_array_resize(). + * + * @see f_memory_array_resize() * - * @see f_memory_adjust() * @see f_thread_barriers_adjust() * @see f_thread_barriers_decimate_by() */ #if !defined(_di_f_thread_barriers_adjust_) || !defined(_di_f_thread_barriers_decimate_by_) - extern f_status_t private_f_thread_barriers_adjust(const f_number_unsigned_t length, f_thread_barriers_t * const barriers) F_attribute_visibility_internal_d; + extern f_status_t private_f_thread_barriers_adjust(const f_number_unsigned_t length, f_thread_barriers_t * const structure) F_attribute_visibility_internal_d; #endif // !defined(_di_f_thread_barriers_adjust_) || !defined(_di_f_thread_barriers_decimate_by_) /** @@ -76,21 +77,22 @@ extern "C" { * * @param length * The new size to use. - * @param barriers + * @param structure * The barriers to resize. * * @return * F_none on success. * - * Errors (with error bit) from: f_memory_resize(). + * Errors (with error bit) from: f_memory_array_resize(). + * + * @see f_memory_array_resize() * - * @see f_memory_resize() * @see f_thread_barriers_decrease_by() * @see f_thread_barriers_increase() * @see f_thread_barriers_increase_by() */ #if !defined(_di_f_thread_barriers_decrease_by_) || !defined(_di_f_thread_barriers_increase_) || !defined(_di_f_thread_barriers_increase_by_) - extern f_status_t private_f_thread_barriers_resize(const f_number_unsigned_t length, f_thread_barriers_t * const barriers) F_attribute_visibility_internal_d; + extern f_status_t private_f_thread_barriers_resize(const f_number_unsigned_t length, f_thread_barriers_t * const structure) F_attribute_visibility_internal_d; #endif // !defined(_di_f_thread_barriers_decrease_by_) || !defined(_di_f_thread_barriers_increase_) || !defined(_di_f_thread_barriers_increase_by_) #ifdef __cplusplus diff --git a/level_0/f_thread/c/thread/private-barrier_attribute.c b/level_0/f_thread/c/thread/private-barrier_attribute.c index 2545b86..b5182f1 100644 --- a/level_0/f_thread/c/thread/private-barrier_attribute.c +++ b/level_0/f_thread/c/thread/private-barrier_attribute.c @@ -6,11 +6,9 @@ extern "C" { #endif #if !defined(_di_f_thread_barrier_attributes_adjust_) || !defined(_di_f_thread_barrier_attributes_decimate_by_) || !defined(_di_f_thread_barrier_attributes_decrease_) || !defined(_di_f_thread_barrier_attributes_decrease_by_) || !defined(_di_f_thread_barrier_attributes_increase_) || !defined(_di_f_thread_barrier_attributes_increase_by_) || !defined(_di_f_thread_barrier_attributes_resize_) - f_status_t private_f_thread_barrier_attribute_delete(f_thread_barrier_attribute_t *attribute) { + f_status_t private_f_thread_barrier_attribute_delete(f_thread_barrier_attribute_t *structure) { - if (pthread_barrierattr_destroy(attribute)) return F_status_set_error(F_failure); - - attribute = 0; + if (pthread_barrierattr_destroy(structure)) return F_status_set_error(F_failure); return F_none; } diff --git a/level_0/f_thread/c/thread/private-barrier_attribute.h b/level_0/f_thread/c/thread/private-barrier_attribute.h index 8ee63fd..e56a8cd 100644 --- a/level_0/f_thread/c/thread/private-barrier_attribute.h +++ b/level_0/f_thread/c/thread/private-barrier_attribute.h @@ -22,8 +22,8 @@ extern "C" { * * @param length * The new size to use. - * @param attributes - * The attributes to adjust. + * @param structure + * The attribute to delete. * * @return * F_none on success. @@ -43,7 +43,7 @@ extern "C" { * @see f_thread_barrier_attributes_resize() */ #if !defined(_di_f_thread_barrier_attributes_adjust_) || !defined(_di_f_thread_barrier_attributes_decimate_by_) || !defined(_di_f_thread_barrier_attributes_decrease_) || !defined(_di_f_thread_barrier_attributes_decrease_by_) || !defined(_di_f_thread_barrier_attributes_increase_) || !defined(_di_f_thread_barrier_attributes_increase_by_) || !defined(_di_f_thread_barrier_attributes_resize_) - extern f_status_t private_f_thread_barrier_attribute_delete(f_thread_barrier_attribute_t *attribute) F_attribute_visibility_internal_d; + extern f_status_t private_f_thread_barrier_attribute_delete(f_thread_barrier_attribute_t *structure) F_attribute_visibility_internal_d; #endif // !defined(_di_f_thread_barrier_attributes_adjust_) || !defined(_di_f_thread_barrier_attributes_decimate_by_) || !defined(_di_f_thread_barrier_attributes_decrease_) || !defined(_di_f_thread_barrier_attributes_decrease_by_) || !defined(_di_f_thread_barrier_attributes_increase_) || !defined(_di_f_thread_barrier_attributes_increase_by_) || !defined(_di_f_thread_barrier_attributes_resize_) /** @@ -53,20 +53,21 @@ extern "C" { * * @param length * The new size to use. - * @param attributes - * The attributes to adjust. + * @param structure + * The barrier_attributes to adjust. * * @return * F_none on success. * - * Errors (with error bit) from: f_memory_adjust(). + * Errors (with error bit) from: f_memory_array_resize(). + * + * @see f_memory_array_resize() * - * @see f_memory_adjust() * @see f_thread_barrier_attributes_adjust() * @see f_thread_barrier_attributes_decimate_by() */ #if !defined(_di_f_thread_barrier_attributes_adjust_) || !defined(_di_f_thread_barrier_attributes_decimate_by_) - extern f_status_t private_f_thread_barrier_attributes_adjust(const f_number_unsigned_t length, f_thread_barrier_attributes_t * const attributes) F_attribute_visibility_internal_d; + extern f_status_t private_f_thread_barrier_attributes_adjust(const f_number_unsigned_t length, f_thread_barrier_attributes_t * const structure) F_attribute_visibility_internal_d; #endif // !defined(_di_f_thread_barrier_attributes_adjust_) || !defined(_di_f_thread_barrier_attributes_decimate_by_) /** @@ -76,21 +77,22 @@ extern "C" { * * @param length * The new size to use. - * @param attributes - * The attributes to resize. + * @param structure + * The barrier_attributes to resize. * * @return * F_none on success. * - * Errors (with error bit) from: f_memory_resize(). + * Errors (with error bit) from: f_memory_array_resize(). + * + * @see f_memory_array_resize() * - * @see f_memory_resize() * @see f_thread_barrier_attributes_decrease_by() * @see f_thread_barrier_attributes_increase() * @see f_thread_barrier_attributes_increase_by() */ #if !defined(_di_f_thread_barrier_attributes_decrease_by_) || !defined(_di_f_thread_barrier_attributes_increase_) || !defined(_di_f_thread_barrier_attributes_increase_by_) - extern f_status_t private_f_thread_barrier_attributes_resize(const f_number_unsigned_t length, f_thread_barrier_attributes_t * const attributes) F_attribute_visibility_internal_d; + extern f_status_t private_f_thread_barrier_attributes_resize(const f_number_unsigned_t length, f_thread_barrier_attributes_t * const structure) F_attribute_visibility_internal_d; #endif // !defined(_di_f_thread_barrier_attributes_decrease_by_) || !defined(_di_f_thread_barrier_attributes_increase_) || !defined(_di_f_thread_barrier_attributes_increase_by_) #ifdef __cplusplus diff --git a/level_0/f_thread/c/thread/private-condition.c b/level_0/f_thread/c/thread/private-condition.c index 24d45e6..36a1aa5 100644 --- a/level_0/f_thread/c/thread/private-condition.c +++ b/level_0/f_thread/c/thread/private-condition.c @@ -22,32 +22,32 @@ extern "C" { #endif // !defined(_di_f_thread_condition_delete_) || !defined(_di_f_thread_conditions_adjust_) || !defined(_di_f_thread_conditions_decimate_by_) || !defined(_di_f_thread_conditions_decrease_) || !defined(_di_f_thread_conditions_decrease_by_) || !defined(_di_f_thread_conditions_increase_) || !defined(_di_f_thread_conditions_increase_by_) || !defined(_di_f_thread_conditions_resize_) #if !defined(_di_f_thread_conditions_adjust_) || !defined(_di_f_thread_conditions_decimate_by_) - f_status_t private_f_thread_conditions_adjust(const f_number_unsigned_t length, f_thread_conditions_t * const conditions) { + f_status_t private_f_thread_conditions_adjust(const f_number_unsigned_t length, f_thread_conditions_t * const structure) { f_status_t status = F_none; - for (f_number_unsigned_t i = length; i < conditions->size; ++i) { + for (f_number_unsigned_t i = length; i < structure->size; ++i) { - status = private_f_thread_condition_delete(&conditions->array[i]); + status = private_f_thread_condition_delete(&structure->array[i]); if (F_status_is_error(status)) return status; } // for - return f_memory_array_adjust(length, sizeof(f_thread_condition_t), (void **) &conditions->array, &conditions->used, &conditions->size); + return f_memory_array_adjust(length, sizeof(f_thread_condition_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // !defined(_di_f_thread_conditions_adjust_) || !defined(_di_f_thread_conditions_decimate_by_) #if !defined(_di_f_thread_conditions_decrease_) || !defined(_di_f_thread_conditions_decrease_by_) || !defined(_di_f_thread_conditions_increase_) || !defined(_di_f_thread_conditions_increase_by_) - f_status_t private_f_thread_conditions_resize(const f_number_unsigned_t length, f_thread_conditions_t * const conditions) { + f_status_t private_f_thread_conditions_resize(const f_number_unsigned_t length, f_thread_conditions_t * const structure) { f_status_t status = F_none; - for (f_number_unsigned_t i = length; i < conditions->size; ++i) { + for (f_number_unsigned_t i = length; i < structure->size; ++i) { - status = private_f_thread_condition_delete(&conditions->array[i]); + status = private_f_thread_condition_delete(&structure->array[i]); if (F_status_is_error(status)) return status; } // for - return f_memory_array_resize(length, sizeof(f_thread_condition_t), (void **) &conditions->array, &conditions->used, &conditions->size); + return f_memory_array_resize(length, sizeof(f_thread_condition_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // !defined(_di_f_thread_conditions_decrease_) || !defined(_di_f_thread_conditions_decrease_by_) || !defined(_di_f_thread_conditions_increase_) || !defined(_di_f_thread_conditions_increase_by_) diff --git a/level_0/f_thread/c/thread/private-condition.h b/level_0/f_thread/c/thread/private-condition.h index 0441ba8..e5d9c51 100644 --- a/level_0/f_thread/c/thread/private-condition.h +++ b/level_0/f_thread/c/thread/private-condition.h @@ -22,7 +22,7 @@ extern "C" { * * @param length * The new size to use. - * @param conditions + * @param structure * The conditions to adjust. * * @return @@ -44,7 +44,7 @@ extern "C" { * @see f_thread_conditions_resize() */ #if !defined(_di_f_thread_condition_delete_) || !defined(_di_f_thread_conditions_adjust_) || !defined(_di_f_thread_conditions_decimate_by_) || !defined(_di_f_thread_conditions_decrease_) || !defined(_di_f_thread_conditions_decrease_by_) || !defined(_di_f_thread_conditions_increase_) || !defined(_di_f_thread_conditions_increase_by_) || !defined(_di_f_thread_conditions_resize_) - extern f_status_t private_f_thread_condition_delete(f_thread_condition_t *condition) F_attribute_visibility_internal_d; + extern f_status_t private_f_thread_condition_delete(f_thread_condition_t *structure) F_attribute_visibility_internal_d; #endif // !defined(_di_f_thread_condition_delete_) || !defined(_di_f_thread_conditions_adjust_) || !defined(_di_f_thread_conditions_decimate_by_) || !defined(_di_f_thread_conditions_decrease_) || !defined(_di_f_thread_conditions_decrease_by_) || !defined(_di_f_thread_conditions_increase_) || !defined(_di_f_thread_conditions_increase_by_) || !defined(_di_f_thread_conditions_resize_) /** @@ -54,20 +54,21 @@ extern "C" { * * @param length * The new size to use. - * @param conditions + * @param structure * The conditions to adjust. * * @return * F_none on success. * - * Errors (with error bit) from: f_memory_adjust(). + * Errors (with error bit) from: f_memory_array_resize(). + * + * @see f_memory_array_resize() * - * @see f_memory_adjust() * @see f_thread_conditions_adjust() * @see f_thread_conditions_decimate_by() */ #if !defined(_di_f_thread_conditions_adjust_) || !defined(_di_f_thread_conditions_decimate_by_) - extern f_status_t private_f_thread_conditions_adjust(const f_number_unsigned_t length, f_thread_conditions_t * const conditions) F_attribute_visibility_internal_d; + extern f_status_t private_f_thread_conditions_adjust(const f_number_unsigned_t length, f_thread_conditions_t * const structure) F_attribute_visibility_internal_d; #endif // !defined(_di_f_thread_conditions_adjust_) || !defined(_di_f_thread_conditions_decimate_by_) /** @@ -77,21 +78,22 @@ extern "C" { * * @param length * The new size to use. - * @param conditions + * @param structure * The conditions to resize. * * @return * F_none on success. * - * Errors (with error bit) from: f_memory_resize(). + * Errors (with error bit) from: f_memory_array_resize(). + * + * @see f_memory_array_resize() * - * @see f_memory_resize() * @see f_thread_conditions_decrease_by() * @see f_thread_conditions_increase() * @see f_thread_conditions_increase_by() */ #if !defined(_di_f_thread_conditions_decrease_by_) || !defined(_di_f_thread_conditions_increase_) || !defined(_di_f_thread_conditions_increase_by_) - extern f_status_t private_f_thread_conditions_resize(const f_number_unsigned_t length, f_thread_conditions_t * const conditions) F_attribute_visibility_internal_d; + extern f_status_t private_f_thread_conditions_resize(const f_number_unsigned_t length, f_thread_conditions_t * const structure) F_attribute_visibility_internal_d; #endif // !defined(_di_f_thread_conditions_decrease_by_) || !defined(_di_f_thread_conditions_increase_) || !defined(_di_f_thread_conditions_increase_by_) #ifdef __cplusplus diff --git a/level_0/f_thread/c/thread/private-condition_attribute.c b/level_0/f_thread/c/thread/private-condition_attribute.c index 218411a..bc36c33 100644 --- a/level_0/f_thread/c/thread/private-condition_attribute.c +++ b/level_0/f_thread/c/thread/private-condition_attribute.c @@ -22,32 +22,32 @@ extern "C" { #endif // !defined(_di_f_thread_condition_attributes_adjust_) || !defined(_di_f_thread_condition_attributes_decimate_by_) || !defined(_di_f_thread_condition_attributes_decrease_) || !defined(_di_f_thread_condition_attributes_decrease_by_) || !defined(_di_f_thread_condition_attributes_increase_) || !defined(_di_f_thread_condition_attributes_increase_by_) || !defined(_di_f_thread_condition_attributes_resize_) #if !defined(_di_f_thread_condition_attributes_adjust_) || !defined(_di_f_thread_condition_attributes_decimate_by_) - f_status_t private_f_thread_condition_attributes_adjust(const f_number_unsigned_t length, f_thread_condition_attributes_t * const attributes) { + f_status_t private_f_thread_condition_attributes_adjust(const f_number_unsigned_t length, f_thread_condition_attributes_t * const structure) { f_status_t status = F_none; - for (f_number_unsigned_t i = length; i < attributes->size; ++i) { + for (f_number_unsigned_t i = length; i < structure->size; ++i) { - status = private_f_thread_condition_attribute_delete(&attributes->array[i]); + status = private_f_thread_condition_attribute_delete(&structure->array[i]); if (F_status_is_error(status)) return status; } // for - return f_memory_array_adjust(length, sizeof(f_thread_condition_attribute_t), (void **) &attributes->array, &attributes->used, &attributes->size); + return f_memory_array_adjust(length, sizeof(f_thread_condition_attribute_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // !defined(_di_f_thread_condition_attributes_adjust_) || !defined(_di_f_thread_condition_attributes_decimate_by_) #if !defined(_di_f_thread_condition_attributes_decrease_) || !defined(_di_f_thread_condition_attributes_decrease_by_) || !defined(_di_f_thread_condition_attributes_increase_) || !defined(_di_f_thread_condition_attributes_increase_by_) - f_status_t private_f_thread_condition_attributes_resize(const f_number_unsigned_t length, f_thread_condition_attributes_t * const attributes) { + f_status_t private_f_thread_condition_attributes_resize(const f_number_unsigned_t length, f_thread_condition_attributes_t * const structure) { f_status_t status = F_none; - for (f_number_unsigned_t i = length; i < attributes->size; ++i) { + for (f_number_unsigned_t i = length; i < structure->size; ++i) { - status = private_f_thread_condition_attribute_delete(&attributes->array[i]); + status = private_f_thread_condition_attribute_delete(&structure->array[i]); if (F_status_is_error(status)) return status; } // for - return f_memory_array_resize(length, sizeof(f_thread_condition_attribute_t), (void **) &attributes->array, &attributes->used, &attributes->size); + return f_memory_array_resize(length, sizeof(f_thread_condition_attribute_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // !defined(_di_f_thread_condition_attributes_decrease_) || !defined(_di_f_thread_condition_attributes_decrease_by_) || !defined(_di_f_thread_condition_attributes_increase_) || !defined(_di_f_thread_condition_attributes_increase_by_) diff --git a/level_0/f_thread/c/thread/private-condition_attribute.h b/level_0/f_thread/c/thread/private-condition_attribute.h index fdefb9b..50e670d 100644 --- a/level_0/f_thread/c/thread/private-condition_attribute.h +++ b/level_0/f_thread/c/thread/private-condition_attribute.h @@ -22,8 +22,8 @@ extern "C" { * * @param length * The new size to use. - * @param attribute - * The attribute to adjust. + * @param structure + * The attribute to delete. * * @return * F_none on success. @@ -43,7 +43,7 @@ extern "C" { * @see f_thread_condition_attributes_resize() */ #if !defined(_di_f_thread_condition_attributes_adjust_) || !defined(_di_f_thread_condition_attributes_decimate_by_) || !defined(_di_f_thread_condition_attributes_decrease_) || !defined(_di_f_thread_condition_attributes_decrease_by_) || !defined(_di_f_thread_condition_attributes_increase_) || !defined(_di_f_thread_condition_attributes_increase_by_) || !defined(_di_f_thread_condition_attributes_resize_) - extern f_status_t private_f_thread_condition_attribute_delete(f_thread_condition_attribute_t *attribute) F_attribute_visibility_internal_d; + extern f_status_t private_f_thread_condition_attribute_delete(f_thread_condition_attribute_t *structure) F_attribute_visibility_internal_d; #endif // !defined(_di_f_thread_condition_attributes_adjust_) || !defined(_di_f_thread_condition_attributes_decimate_by_) || !defined(_di_f_thread_condition_attributes_decrease_) || !defined(_di_f_thread_condition_attributes_decrease_by_) || !defined(_di_f_thread_condition_attributes_increase_) || !defined(_di_f_thread_condition_attributes_increase_by_) || !defined(_di_f_thread_condition_attributes_resize_) /** @@ -53,20 +53,21 @@ extern "C" { * * @param length * The new size to use. - * @param attributes - * The attributes to adjust. + * @param structure + * The condition_attributes to adjust. * * @return * F_none on success. * - * Errors (with error bit) from: f_memory_adjust(). + * Errors (with error bit) from: f_memory_array_resize(). + * + * @see f_memory_array_resize() * - * @see f_memory_adjust() * @see f_thread_condition_attributes_adjust() * @see f_thread_condition_attributes_decimate_by() */ #if !defined(_di_f_thread_condition_attributes_adjust_) || !defined(_di_f_thread_condition_attributes_decimate_by_) - extern f_status_t private_f_thread_condition_attributes_adjust(const f_number_unsigned_t length, f_thread_condition_attributes_t * const attributes) F_attribute_visibility_internal_d; + extern f_status_t private_f_thread_condition_attributes_adjust(const f_number_unsigned_t length, f_thread_condition_attributes_t * const structure) F_attribute_visibility_internal_d; #endif // !defined(_di_f_thread_condition_attributes_adjust_) || !defined(_di_f_thread_condition_attributes_decimate_by_) /** @@ -76,21 +77,22 @@ extern "C" { * * @param length * The new size to use. - * @param attributes - * The attributes to resize. + * @param structure + * The condition_attributes to resize. * * @return * F_none on success. * - * Errors (with error bit) from: f_memory_resize(). + * Errors (with error bit) from: f_memory_array_resize(). + * + * @see f_memory_array_resize() * - * @see f_memory_resize() * @see f_thread_condition_attributes_decrease_by() * @see f_thread_condition_attributes_increase() * @see f_thread_condition_attributes_increase_by() */ #if !defined(_di_f_thread_condition_attributes_decrease_by_) || !defined(_di_f_thread_condition_attributes_increase_) || !defined(_di_f_thread_condition_attributes_increase_by_) - extern f_status_t private_f_thread_condition_attributes_resize(const f_number_unsigned_t length, f_thread_condition_attributes_t * const attributes) F_attribute_visibility_internal_d; + extern f_status_t private_f_thread_condition_attributes_resize(const f_number_unsigned_t length, f_thread_condition_attributes_t * const structure) F_attribute_visibility_internal_d; #endif // !defined(_di_f_thread_condition_attributes_decrease_by_) || !defined(_di_f_thread_condition_attributes_increase_) || !defined(_di_f_thread_condition_attributes_increase_by_) #ifdef __cplusplus diff --git a/level_0/f_thread/c/thread/private-id.c b/level_0/f_thread/c/thread/private-id.c index 3a37e91..b96ca12 100644 --- a/level_0/f_thread/c/thread/private-id.c +++ b/level_0/f_thread/c/thread/private-id.c @@ -5,24 +5,6 @@ extern "C" { #endif -#if !defined(_di_f_thread_ids_adjust_) || !defined(_di_f_thread_ids_decimate_by_) - f_status_t private_f_thread_ids_adjust(const f_number_unsigned_t length, f_thread_ids_t * const ids) { - - if (ids->size) { - memset(ids->array, 0, sizeof(f_thread_id_t) * ids->size); - } - - return f_memory_array_adjust(length, sizeof(f_thread_id_t), (void **) &ids->array, &ids->used, &ids->size); - } -#endif // !defined(_di_f_thread_ids_adjust_) || !defined(_di_f_thread_ids_decimate_by_) - -#if !defined(_di_f_thread_ids_decrease_) || !defined(_di_f_thread_ids_decrease_by_) || !defined(_di_f_thread_ids_increase_) || !defined(_di_f_thread_ids_increase_by_) - f_status_t private_f_thread_ids_resize(const f_number_unsigned_t length, f_thread_ids_t * const ids) { - - return f_memory_array_resize(length, sizeof(f_thread_id_t), (void **) &ids->array, &ids->used, &ids->size); - } -#endif // !defined(_di_f_thread_ids_decrease_) || !defined(_di_f_thread_ids_decrease_by_) || !defined(_di_f_thread_ids_increase_) || !defined(_di_f_thread_ids_increase_by_) - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_0/f_thread/c/thread/private-id.h b/level_0/f_thread/c/thread/private-id.h index 5bd9a38..22fa219 100644 --- a/level_0/f_thread/c/thread/private-id.h +++ b/level_0/f_thread/c/thread/private-id.h @@ -15,53 +15,6 @@ extern "C" { #endif -/** - * Private implementation for resizing. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @param ids - * The ids to adjust. - * - * @return - * F_none on success. - * - * Errors (with error bit) from: f_memory_adjust(). - * - * @see f_memory_adjust() - * @see f_thread_ids_adjust() - * @see f_thread_ids_decimate_by() - */ -#if !defined(_di_f_thread_ids_adjust_) || !defined(_di_f_thread_ids_decimate_by_) - extern f_status_t private_f_thread_ids_adjust(const f_number_unsigned_t length, f_thread_ids_t * const ids) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_thread_ids_adjust_) || !defined(_di_f_thread_ids_decimate_by_) - -/** - * Private implementation for resizing. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @param ids - * The ids to resize. - * - * @return - * F_none on success. - * - * Errors (with error bit) from: f_memory_resize(). - * - * @see f_memory_resize() - * @see f_thread_ids_decrease_by() - * @see f_thread_ids_increase() - * @see f_thread_ids_increase_by() - */ -#if !defined(_di_f_thread_ids_decrease_by_) || !defined(_di_f_thread_ids_increase_) || !defined(_di_f_thread_ids_increase_by_) - extern f_status_t private_f_thread_ids_resize(const f_number_unsigned_t length, f_thread_ids_t * const ids) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_thread_ids_decrease_by_) || !defined(_di_f_thread_ids_increase_) || !defined(_di_f_thread_ids_increase_by_) - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_0/f_thread/c/thread/private-key.c b/level_0/f_thread/c/thread/private-key.c index df4feaa..c4e3731 100644 --- a/level_0/f_thread/c/thread/private-key.c +++ b/level_0/f_thread/c/thread/private-key.c @@ -6,43 +6,43 @@ extern "C" { #endif #if !defined(_di_f_thread_keys_adjust_) || !defined(_di_f_thread_keys_decimate_by_) || !defined(_di_f_thread_keys_decrease_) || !defined(_di_f_thread_keys_decrease_by_) || !defined(_di_f_thread_keys_increase_) || !defined(_di_f_thread_keys_increase_by_) || !defined(_di_f_thread_keys_resize_) - f_status_t private_f_thread_key_delete(f_thread_key_t *key) { + f_status_t private_f_thread_key_delete(f_thread_key_t *structure) { - if (pthread_key_delete(*key)) return F_status_set_error(F_failure); + if (pthread_key_delete(*structure)) return F_status_set_error(F_failure); - *key = 0; + *structure = 0; return F_none; } #endif // !defined(_di_f_thread_keys_adjust_) || !defined(_di_f_thread_keys_decimate_by_) || !defined(_di_f_thread_keys_decrease_) || !defined(_di_f_thread_keys_decrease_by_) || !defined(_di_f_thread_keys_increase_) || !defined(_di_f_thread_keys_increase_by_) || !defined(_di_f_thread_keys_resize_) #if !defined(_di_f_thread_keys_adjust_) || !defined(_di_f_thread_keys_decimate_by_) - f_status_t private_f_thread_keys_adjust(const f_number_unsigned_t length, f_thread_keys_t * const keys) { + f_status_t private_f_thread_keys_adjust(const f_number_unsigned_t length, f_thread_keys_t * const structure) { f_status_t status = F_none; - for (f_number_unsigned_t i = length; i < keys->size; ++i) { + for (f_number_unsigned_t i = length; i < structure->size; ++i) { - status = private_f_thread_key_delete(&keys->array[i]); + status = private_f_thread_key_delete(&structure->array[i]); if (F_status_is_error(status)) return status; } // for - return f_memory_array_adjust(length, sizeof(f_thread_key_t), (void **) &keys->array, &keys->used, &keys->size); + return f_memory_array_adjust(length, sizeof(f_thread_key_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // !defined(_di_f_thread_keys_adjust_) || !defined(_di_f_thread_keys_decimate_by_) #if !defined(_di_f_thread_keys_decrease_) || !defined(_di_f_thread_keys_decrease_by_) || !defined(_di_f_thread_keys_increase_) || !defined(_di_f_thread_keys_increase_by_) - f_status_t private_f_thread_keys_resize(const f_number_unsigned_t length, f_thread_keys_t * const keys) { + f_status_t private_f_thread_keys_resize(const f_number_unsigned_t length, f_thread_keys_t * const structure) { f_status_t status = F_none; - for (f_number_unsigned_t i = length; i < keys->size; ++i) { + for (f_number_unsigned_t i = length; i < structure->size; ++i) { - status = private_f_thread_key_delete(&keys->array[i]); + status = private_f_thread_key_delete(&structure->array[i]); if (F_status_is_error(status)) return status; } // for - return f_memory_array_resize(length, sizeof(f_thread_key_t), (void **) &keys->array, &keys->used, &keys->size); + return f_memory_array_resize(length, sizeof(f_thread_key_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // !defined(_di_f_thread_keys_decrease_) || !defined(_di_f_thread_keys_decrease_by_) || !defined(_di_f_thread_keys_increase_) || !defined(_di_f_thread_keys_increase_by_) diff --git a/level_0/f_thread/c/thread/private-key.h b/level_0/f_thread/c/thread/private-key.h index 0595175..8345e1e 100644 --- a/level_0/f_thread/c/thread/private-key.h +++ b/level_0/f_thread/c/thread/private-key.h @@ -20,8 +20,8 @@ extern "C" { * * Intended to be shared to each of the different implementation variations. * - * @param key - * The keys to delete. + * @param structure + * The key to delete. * * @return * F_none on success. @@ -41,7 +41,7 @@ extern "C" { * @see f_thread_keys_resize() */ #if !defined(_di_f_thread_keys_adjust_) || !defined(_di_f_thread_keys_decimate_by_) || !defined(_di_f_thread_keys_decrease_) || !defined(_di_f_thread_keys_decrease_by_) || !defined(_di_f_thread_keys_increase_) || !defined(_di_f_thread_keys_increase_by_) || !defined(_di_f_thread_keys_resize_) - extern f_status_t private_f_thread_key_delete(f_thread_key_t *key) F_attribute_visibility_internal_d; + extern f_status_t private_f_thread_key_delete(f_thread_key_t *structure) F_attribute_visibility_internal_d; #endif // !defined(_di_f_thread_keys_adjust_) || !defined(_di_f_thread_keys_decimate_by_) || !defined(_di_f_thread_keys_decrease_) || !defined(_di_f_thread_keys_decrease_by_) || !defined(_di_f_thread_keys_increase_) || !defined(_di_f_thread_keys_increase_by_) || !defined(_di_f_thread_keys_resize_) /** @@ -51,20 +51,21 @@ extern "C" { * * @param length * The new size to use. - * @param keys + * @param structure * The keys to adjust. * * @return * F_none on success. * - * Errors (with error bit) from: f_memory_adjust(). + * Errors (with error bit) from: f_memory_array_resize(). + * + * @see f_memory_array_resize() * - * @see f_memory_adjust() * @see f_thread_keys_adjust() * @see f_thread_keys_decimate_by() */ #if !defined(_di_f_thread_keys_adjust_) || !defined(_di_f_thread_keys_decimate_by_) - extern f_status_t private_f_thread_keys_adjust(const f_number_unsigned_t length, f_thread_keys_t * const keys) F_attribute_visibility_internal_d; + extern f_status_t private_f_thread_keys_adjust(const f_number_unsigned_t length, f_thread_keys_t * const structure) F_attribute_visibility_internal_d; #endif // !defined(_di_f_thread_keys_adjust_) || !defined(_di_f_thread_keys_decimate_by_) /** @@ -74,21 +75,22 @@ extern "C" { * * @param length * The new size to use. - * @param keys + * @param structure * The keys to resize. * * @return * F_none on success. * - * Errors (with error bit) from: f_memory_resize(). + * Errors (with error bit) from: f_memory_array_resize(). + * + * @see f_memory_array_resize() * - * @see f_memory_resize() * @see f_thread_keys_decrease_by() * @see f_thread_keys_increase() * @see f_thread_keys_increase_by() */ #if !defined(_di_f_thread_keys_decrease_by_) || !defined(_di_f_thread_keys_increase_) || !defined(_di_f_thread_keys_increase_by_) - extern f_status_t private_f_thread_keys_resize(const f_number_unsigned_t length, f_thread_keys_t * const keys) F_attribute_visibility_internal_d; + extern f_status_t private_f_thread_keys_resize(const f_number_unsigned_t length, f_thread_keys_t * const structure) F_attribute_visibility_internal_d; #endif // !defined(_di_f_thread_keys_decrease_by_) || !defined(_di_f_thread_keys_increase_) || !defined(_di_f_thread_keys_increase_by_) #ifdef __cplusplus diff --git a/level_0/f_thread/c/thread/private-lock.c b/level_0/f_thread/c/thread/private-lock.c index 96293c8..ca9950d 100644 --- a/level_0/f_thread/c/thread/private-lock.c +++ b/level_0/f_thread/c/thread/private-lock.c @@ -6,9 +6,9 @@ extern "C" { #endif #if !defined(_di_f_thread_lock_delete_) || !defined(_di_f_thread_locks_adjust_) || !defined(_di_f_thread_locks_decimate_by_) || !defined(_di_f_thread_locks_decrease_) || !defined(_di_f_thread_locks_decrease_by_) || !defined(_di_f_thread_locks_increase_) || !defined(_di_f_thread_locks_increase_by_) || !defined(_di_f_thread_locks_resize_) - f_status_t private_f_thread_lock_delete(f_thread_lock_t *lock) { + f_status_t private_f_thread_lock_delete(f_thread_lock_t *structure) { - const int error = pthread_rwlock_destroy(lock); + const int error = pthread_rwlock_destroy(structure); if (error) { if (error == EBUSY) return F_status_set_error(F_busy); @@ -22,32 +22,32 @@ extern "C" { #endif // !defined(_di_f_thread_lock_delete_) || !defined(_di_f_thread_locks_adjust_) || !defined(_di_f_thread_locks_decimate_by_) || !defined(_di_f_thread_locks_decrease_) || !defined(_di_f_thread_locks_decrease_by_) || !defined(_di_f_thread_locks_increase_) || !defined(_di_f_thread_locks_increase_by_) || !defined(_di_f_thread_locks_resize_) #if !defined(_di_f_thread_locks_adjust_) || !defined(_di_f_thread_locks_decimate_by_) - f_status_t private_f_thread_locks_adjust(const f_number_unsigned_t length, f_thread_locks_t * const locks) { + f_status_t private_f_thread_locks_adjust(const f_number_unsigned_t length, f_thread_locks_t * const structure) { f_status_t status = F_none; - for (f_number_unsigned_t i = length; i < locks->size; ++i) { + for (f_number_unsigned_t i = length; i < structure->size; ++i) { - status = private_f_thread_lock_delete(&locks->array[i]); + status = private_f_thread_lock_delete(&structure->array[i]); if (F_status_is_error(status)) return status; } // for - return f_memory_array_adjust(length, sizeof(f_thread_lock_t), (void **) &locks->array, &locks->used, &locks->size); + return f_memory_array_adjust(length, sizeof(f_thread_lock_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // !defined(_di_f_thread_locks_adjust_) || !defined(_di_f_thread_locks_decimate_by_) #if !defined(_di_f_thread_locks_decrease_) || !defined(_di_f_thread_locks_decrease_by_) || !defined(_di_f_thread_locks_increase_) || !defined(_di_f_thread_locks_increase_by_) - f_status_t private_f_thread_locks_resize(const f_number_unsigned_t length, f_thread_locks_t * const locks) { + f_status_t private_f_thread_locks_resize(const f_number_unsigned_t length, f_thread_locks_t * const structure) { f_status_t status = F_none; - for (f_number_unsigned_t i = length; i < locks->size; ++i) { + for (f_number_unsigned_t i = length; i < structure->size; ++i) { - status = private_f_thread_lock_delete(&locks->array[i]); + status = private_f_thread_lock_delete(&structure->array[i]); if (F_status_is_error(status)) return status; } // for - return f_memory_array_resize(length, sizeof(f_thread_lock_t), (void **) &locks->array, &locks->used, &locks->size); + return f_memory_array_resize(length, sizeof(f_thread_lock_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // !defined(_di_f_thread_locks_decrease_) || !defined(_di_f_thread_locks_decrease_by_) || !defined(_di_f_thread_locks_increase_) || !defined(_di_f_thread_locks_increase_by_) diff --git a/level_0/f_thread/c/thread/private-lock.h b/level_0/f_thread/c/thread/private-lock.h index 7532111..687dbb4 100644 --- a/level_0/f_thread/c/thread/private-lock.h +++ b/level_0/f_thread/c/thread/private-lock.h @@ -20,8 +20,8 @@ extern "C" { * * Intended to be shared to each of the different implementation variations. * - * @param lock - * The locks to delete. + * @param structure + * The lock to delete. * * @return * F_none on success. @@ -42,7 +42,7 @@ extern "C" { * @see f_thread_locks_resize() */ #if !defined(_di_f_thread_lock_delete_) || !defined(_di_f_thread_locks_adjust_) || !defined(_di_f_thread_locks_decimate_by_) || !defined(_di_f_thread_locks_decrease_) || !defined(_di_f_thread_locks_decrease_by_) || !defined(_di_f_thread_locks_increase_) || !defined(_di_f_thread_locks_increase_by_) || !defined(_di_f_thread_locks_resize_) - extern f_status_t private_f_thread_lock_delete(f_thread_lock_t *lock) F_attribute_visibility_internal_d; + extern f_status_t private_f_thread_lock_delete(f_thread_lock_t *structure) F_attribute_visibility_internal_d; #endif // !defined(_di_f_thread_lock_delete_) || !defined(_di_f_thread_locks_adjust_) || !defined(_di_f_thread_locks_decimate_by_) || !defined(_di_f_thread_locks_decrease_) || !defined(_di_f_thread_locks_decrease_by_) || !defined(_di_f_thread_locks_increase_) || !defined(_di_f_thread_locks_increase_by_) || !defined(_di_f_thread_locks_resize_) /** @@ -52,20 +52,21 @@ extern "C" { * * @param length * The new size to use. - * @param locks + * @param structure * The locks to adjust. * * @return * F_none on success. * - * Errors (with error bit) from: f_memory_adjust(). + * Errors (with error bit) from: f_memory_array_resize(). + * + * @see f_memory_array_resize() * - * @see f_memory_adjust() * @see f_thread_locks_adjust() * @see f_thread_locks_decimate_by() */ #if !defined(_di_f_thread_locks_adjust_) || !defined(_di_f_thread_locks_decimate_by_) - extern f_status_t private_f_thread_locks_adjust(const f_number_unsigned_t length, f_thread_locks_t * const locks) F_attribute_visibility_internal_d; + extern f_status_t private_f_thread_locks_adjust(const f_number_unsigned_t length, f_thread_locks_t * const structure) F_attribute_visibility_internal_d; #endif // !defined(_di_f_thread_locks_adjust_) || !defined(_di_f_thread_locks_decimate_by_) /** @@ -75,21 +76,22 @@ extern "C" { * * @param length * The new size to use. - * @param locks + * @param structure * The locks to resize. * * @return * F_none on success. * - * Errors (with error bit) from: f_memory_resize(). + * Errors (with error bit) from: f_memory_array_resize(). + * + * @see f_memory_array_resize() * - * @see f_memory_resize() * @see f_thread_locks_decrease_by() * @see f_thread_locks_increase() * @see f_thread_locks_increase_by() */ #if !defined(_di_f_thread_locks_decrease_by_) || !defined(_di_f_thread_locks_increase_) || !defined(_di_f_thread_locks_increase_by_) - extern f_status_t private_f_thread_locks_resize(const f_number_unsigned_t length, f_thread_locks_t * const locks) F_attribute_visibility_internal_d; + extern f_status_t private_f_thread_locks_resize(const f_number_unsigned_t length, f_thread_locks_t * const structure) F_attribute_visibility_internal_d; #endif // !defined(_di_f_thread_locks_decrease_by_) || !defined(_di_f_thread_locks_increase_) || !defined(_di_f_thread_locks_increase_by_) #ifdef __cplusplus diff --git a/level_0/f_thread/c/thread/private-lock_attribute.c b/level_0/f_thread/c/thread/private-lock_attribute.c index 42d3ed2..14a2615 100644 --- a/level_0/f_thread/c/thread/private-lock_attribute.c +++ b/level_0/f_thread/c/thread/private-lock_attribute.c @@ -6,9 +6,9 @@ extern "C" { #endif #if !defined(_di_f_thread_lock_attributes_adjust_) || !defined(_di_f_thread_lock_attributes_decimate_by_) || !defined(_di_f_thread_lock_attributes_decrease_) || !defined(_di_f_thread_lock_attributes_decrease_by_) || !defined(_di_f_thread_lock_attributes_increase_) || !defined(_di_f_thread_lock_attributes_increase_by_) || !defined(_di_f_thread_lock_attributes_resize_) - f_status_t private_f_thread_lock_attribute_delete(f_thread_lock_attribute_t *attribute) { + f_status_t private_f_thread_lock_attribute_delete(f_thread_lock_attribute_t *structure) { - const int error = pthread_rwlockattr_destroy(attribute); + const int error = pthread_rwlockattr_destroy(structure); if (error) { if (error == EBUSY) return F_status_set_error(F_busy); @@ -22,32 +22,32 @@ extern "C" { #endif // !defined(_di_f_thread_lock_attributes_adjust_) || !defined(_di_f_thread_lock_attributes_decimate_by_) || !defined(_di_f_thread_lock_attributes_decrease_) || !defined(_di_f_thread_lock_attributes_decrease_by_) || !defined(_di_f_thread_lock_attributes_increase_) || !defined(_di_f_thread_lock_attributes_increase_by_) || !defined(_di_f_thread_lock_attributes_resize_) #if !defined(_di_f_thread_lock_attributes_adjust_) || !defined(_di_f_thread_lock_attributes_decimate_by_) - f_status_t private_f_thread_lock_attributes_adjust(const f_number_unsigned_t length, f_thread_lock_attributes_t * const attributes) { + f_status_t private_f_thread_lock_attributes_adjust(const f_number_unsigned_t length, f_thread_lock_attributes_t * const structure) { f_status_t status = F_none; - for (f_number_unsigned_t i = length; i < attributes->size; ++i) { + for (f_number_unsigned_t i = length; i < structure->size; ++i) { - status = private_f_thread_lock_attribute_delete(&attributes->array[i]); + status = private_f_thread_lock_attribute_delete(&structure->array[i]); if (F_status_is_error(status)) return status; } // for - return f_memory_array_adjust(length, sizeof(f_thread_lock_attribute_t), (void **) &attributes->array, &attributes->used, &attributes->size); + return f_memory_array_adjust(length, sizeof(f_thread_lock_attribute_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // !defined(_di_f_thread_lock_attributes_adjust_) || !defined(_di_f_thread_lock_attributes_decimate_by_) #if !defined(_di_f_thread_lock_attributes_decrease_) || !defined(_di_f_thread_lock_attributes_decrease_by_) || !defined(_di_f_thread_lock_attributes_increase_) || !defined(_di_f_thread_lock_attributes_increase_by_) - f_status_t private_f_thread_lock_attributes_resize(const f_number_unsigned_t length, f_thread_lock_attributes_t * const attributes) { + f_status_t private_f_thread_lock_attributes_resize(const f_number_unsigned_t length, f_thread_lock_attributes_t * const structure) { f_status_t status = F_none; - for (f_number_unsigned_t i = length; i < attributes->size; ++i) { + for (f_number_unsigned_t i = length; i < structure->size; ++i) { - status = private_f_thread_lock_attribute_delete(&attributes->array[i]); + status = private_f_thread_lock_attribute_delete(&structure->array[i]); if (F_status_is_error(status)) return status; } // for - return f_memory_array_resize(length, sizeof(f_thread_lock_attribute_t), (void **) &attributes->array, &attributes->used, &attributes->size); + return f_memory_array_resize(length, sizeof(f_thread_lock_attribute_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // !defined(_di_f_thread_lock_attributes_decrease_) || !defined(_di_f_thread_lock_attributes_decrease_by_) || !defined(_di_f_thread_lock_attributes_increase_) || !defined(_di_f_thread_lock_attributes_increase_by_) diff --git a/level_0/f_thread/c/thread/private-lock_attribute.h b/level_0/f_thread/c/thread/private-lock_attribute.h index e0f8cd3..d0419ee 100644 --- a/level_0/f_thread/c/thread/private-lock_attribute.h +++ b/level_0/f_thread/c/thread/private-lock_attribute.h @@ -20,7 +20,7 @@ extern "C" { * * Intended to be shared to each of the different implementation variations. * - * @param attribute + * @param structure * The attribute to delete. * * @return @@ -41,7 +41,7 @@ extern "C" { * @see f_thread_lock_attributes_resize() */ #if !defined(_di_f_thread_lock_attributes_adjust_) || !defined(_di_f_thread_lock_attributes_decimate_by_) || !defined(_di_f_thread_lock_attributes_decrease_) || !defined(_di_f_thread_lock_attributes_decrease_by_) || !defined(_di_f_thread_lock_attributes_increase_) || !defined(_di_f_thread_lock_attributes_increase_by_) || !defined(_di_f_thread_lock_attributes_resize_) - extern f_status_t private_f_thread_lock_attribute_delete(f_thread_lock_attribute_t *attribute) F_attribute_visibility_internal_d; + extern f_status_t private_f_thread_lock_attribute_delete(f_thread_lock_attribute_t *structure) F_attribute_visibility_internal_d; #endif // !defined(_di_f_thread_lock_attributes_adjust_) || !defined(_di_f_thread_lock_attributes_decimate_by_) || !defined(_di_f_thread_lock_attributes_decrease_) || !defined(_di_f_thread_lock_attributes_decrease_by_) || !defined(_di_f_thread_lock_attributes_increase_) || !defined(_di_f_thread_lock_attributes_increase_by_) || !defined(_di_f_thread_lock_attributes_resize_) /** @@ -51,20 +51,21 @@ extern "C" { * * @param length * The new size to use. - * @param attributes - * The attributes to adjust. + * @param structure + * The lock_attributes to adjust. * * @return * F_none on success. * - * Errors (with error bit) from: f_memory_adjust(). + * Errors (with error bit) from: f_memory_array_resize(). + * + * @see f_memory_array_resize() * - * @see f_memory_adjust() * @see f_thread_lock_attributes_adjust() * @see f_thread_lock_attributes_decimate_by() */ #if !defined(_di_f_thread_lock_attributes_adjust_) || !defined(_di_f_thread_lock_attributes_decimate_by_) - extern f_status_t private_f_thread_lock_attributes_adjust(const f_number_unsigned_t length, f_thread_lock_attributes_t * const attributes) F_attribute_visibility_internal_d; + extern f_status_t private_f_thread_lock_attributes_adjust(const f_number_unsigned_t length, f_thread_lock_attributes_t * const structure) F_attribute_visibility_internal_d; #endif // !defined(_di_f_thread_lock_attributes_adjust_) || !defined(_di_f_thread_lock_attributes_decimate_by_) /** @@ -74,21 +75,22 @@ extern "C" { * * @param length * The new size to use. - * @param attributes - * The attributes to resize. + * @param structure + * The lock_attributes to resize. * * @return * F_none on success. * - * Errors (with error bit) from: f_memory_resize(). + * Errors (with error bit) from: f_memory_array_resize(). + * + * @see f_memory_array_resize() * - * @see f_memory_resize() * @see f_thread_lock_attributes_decrease_by() * @see f_thread_lock_attributes_increase() * @see f_thread_lock_attributes_increase_by() */ #if !defined(_di_f_thread_lock_attributes_decrease_by_) || !defined(_di_f_thread_lock_attributes_increase_) || !defined(_di_f_thread_lock_attributes_increase_by_) - extern f_status_t private_f_thread_lock_attributes_resize(const f_number_unsigned_t length, f_thread_lock_attributes_t * const attributes) F_attribute_visibility_internal_d; + extern f_status_t private_f_thread_lock_attributes_resize(const f_number_unsigned_t length, f_thread_lock_attributes_t * const structure) F_attribute_visibility_internal_d; #endif // !defined(_di_f_thread_lock_attributes_decrease_by_) || !defined(_di_f_thread_lock_attributes_increase_) || !defined(_di_f_thread_lock_attributes_increase_by_) #ifdef __cplusplus diff --git a/level_0/f_thread/c/thread/private-mutex.c b/level_0/f_thread/c/thread/private-mutex.c index 3beab4c..6a0135b 100644 --- a/level_0/f_thread/c/thread/private-mutex.c +++ b/level_0/f_thread/c/thread/private-mutex.c @@ -6,9 +6,9 @@ extern "C" { #endif #if !defined(_di_f_thread_mutex_delete_) || !defined(_di_f_thread_mutexs_adjust_) || !defined(_di_f_thread_mutexs_decimate_by_) || !defined(_di_f_thread_mutexs_decrease_) || !defined(_di_f_thread_mutexs_decrease_by_) || !defined(_di_f_thread_mutexs_increase_) || !defined(_di_f_thread_mutexs_increase_by_) || !defined(_di_f_thread_mutexs_resize_) - f_status_t private_f_thread_mutex_delete(f_thread_mutex_t *mutex) { + f_status_t private_f_thread_mutex_delete(f_thread_mutex_t *structure) { - const int error = pthread_mutex_destroy(mutex); + const int error = pthread_mutex_destroy(structure); if (error) { if (error == EBUSY) return F_status_set_error(F_busy); @@ -22,32 +22,32 @@ extern "C" { #endif // !defined(_di_f_thread_mutex_delete_) || !defined(_di_f_thread_mutexs_adjust_) || !defined(_di_f_thread_mutexs_decimate_by_) || !defined(_di_f_thread_mutexs_decrease_) || !defined(_di_f_thread_mutexs_decrease_by_) || !defined(_di_f_thread_mutexs_increase_) || !defined(_di_f_thread_mutexs_increase_by_) || !defined(_di_f_thread_mutexs_resize_) #if !defined(_di_f_thread_mutexs_adjust_) || !defined(_di_f_thread_mutexs_decimate_by_) - f_status_t private_f_thread_mutexs_adjust(const f_number_unsigned_t length, f_thread_mutexs_t * const mutexs) { + f_status_t private_f_thread_mutexs_adjust(const f_number_unsigned_t length, f_thread_mutexs_t * const structure) { f_status_t status = F_none; - for (f_number_unsigned_t i = length; i < mutexs->size; ++i) { + for (f_number_unsigned_t i = length; i < structure->size; ++i) { - status = private_f_thread_mutex_delete(&mutexs->array[i]); + status = private_f_thread_mutex_delete(&structure->array[i]); if (F_status_is_error(status)) return status; } // for - return f_memory_array_adjust(length, sizeof(f_thread_mutex_t), (void **) &mutexs->array, &mutexs->used, &mutexs->size); + return f_memory_array_adjust(length, sizeof(f_thread_mutex_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // !defined(_di_f_thread_mutexs_adjust_) || !defined(_di_f_thread_mutexs_decimate_by_) #if !defined(_di_f_thread_mutexs_decrease_) || !defined(_di_f_thread_mutexs_decrease_by_) || !defined(_di_f_thread_mutexs_increase_) || !defined(_di_f_thread_mutexs_increase_by_) - f_status_t private_f_thread_mutexs_resize(const f_number_unsigned_t length, f_thread_mutexs_t * const mutexs) { + f_status_t private_f_thread_mutexs_resize(const f_number_unsigned_t length, f_thread_mutexs_t * const structure) { f_status_t status = F_none; - for (f_number_unsigned_t i = length; i < mutexs->size; ++i) { + for (f_number_unsigned_t i = length; i < structure->size; ++i) { - status = private_f_thread_mutex_delete(&mutexs->array[i]); + status = private_f_thread_mutex_delete(&structure->array[i]); if (F_status_is_error(status)) return status; } // for - return f_memory_array_resize(length, sizeof(f_thread_mutex_t), (void **) &mutexs->array, &mutexs->used, &mutexs->size); + return f_memory_array_resize(length, sizeof(f_thread_mutex_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // !defined(_di_f_thread_mutexs_decrease_) || !defined(_di_f_thread_mutexs_decrease_by_) || !defined(_di_f_thread_mutexs_increase_) || !defined(_di_f_thread_mutexs_increase_by_) diff --git a/level_0/f_thread/c/thread/private-mutex.h b/level_0/f_thread/c/thread/private-mutex.h index f0a2a05..908ca39 100644 --- a/level_0/f_thread/c/thread/private-mutex.h +++ b/level_0/f_thread/c/thread/private-mutex.h @@ -20,8 +20,8 @@ extern "C" { * * Intended to be shared to each of the different implementation variations. * - * @param mutex - * The mutexs to delete. + * @param structure + * The mutex to delete. * * @return * F_none on success. @@ -42,7 +42,7 @@ extern "C" { * @see f_thread_mutexs_resize() */ #if !defined(_di_f_thread_mutex_delete_) || !defined(_di_f_thread_mutexs_adjust_) || !defined(_di_f_thread_mutexs_decimate_by_) || !defined(_di_f_thread_mutexs_decrease_) || !defined(_di_f_thread_mutexs_decrease_by_) || !defined(_di_f_thread_mutexs_increase_) || !defined(_di_f_thread_mutexs_increase_by_) || !defined(_di_f_thread_mutexs_resize_) - extern f_status_t private_f_thread_mutex_delete(f_thread_mutex_t *mutex) F_attribute_visibility_internal_d; + extern f_status_t private_f_thread_mutex_delete(f_thread_mutex_t *structure) F_attribute_visibility_internal_d; #endif // !defined(_di_f_thread_mutex_delete_) || !defined(_di_f_thread_mutexs_adjust_) || !defined(_di_f_thread_mutexs_decimate_by_) || !defined(_di_f_thread_mutexs_decrease_) || !defined(_di_f_thread_mutexs_decrease_by_) || !defined(_di_f_thread_mutexs_increase_) || !defined(_di_f_thread_mutexs_increase_by_) || !defined(_di_f_thread_mutexs_resize_) /** @@ -52,20 +52,21 @@ extern "C" { * * @param length * The new size to use. - * @param mutexs + * @param structure * The mutexs to adjust. * * @return * F_none on success. * - * Errors (with error bit) from: f_memory_adjust(). + * Errors (with error bit) from: f_memory_array_resize(). + * + * @see f_memory_array_resize() * - * @see f_memory_adjust() * @see f_thread_mutexs_adjust() * @see f_thread_mutexs_decimate_by() */ #if !defined(_di_f_thread_mutexs_adjust_) || !defined(_di_f_thread_mutexs_decimate_by_) - extern f_status_t private_f_thread_mutexs_adjust(const f_number_unsigned_t length, f_thread_mutexs_t * const mutexs) F_attribute_visibility_internal_d; + extern f_status_t private_f_thread_mutexs_adjust(const f_number_unsigned_t length, f_thread_mutexs_t * const structure) F_attribute_visibility_internal_d; #endif // !defined(_di_f_thread_mutexs_adjust_) || !defined(_di_f_thread_mutexs_decimate_by_) /** @@ -75,21 +76,22 @@ extern "C" { * * @param length * The new size to use. - * @param mutexs + * @param structure * The mutexs to resize. * * @return * F_none on success. * - * Errors (with error bit) from: f_memory_resize(). + * Errors (with error bit) from: f_memory_array_resize(). + * + * @see f_memory_array_resize() * - * @see f_memory_resize() * @see f_thread_mutexs_decrease_by() * @see f_thread_mutexs_increase() * @see f_thread_mutexs_increase_by() */ #if !defined(_di_f_thread_mutexs_decrease_by_) || !defined(_di_f_thread_mutexs_increase_) || !defined(_di_f_thread_mutexs_increase_by_) - extern f_status_t private_f_thread_mutexs_resize(const f_number_unsigned_t length, f_thread_mutexs_t * const mutexs) F_attribute_visibility_internal_d; + extern f_status_t private_f_thread_mutexs_resize(const f_number_unsigned_t length, f_thread_mutexs_t * const structure) F_attribute_visibility_internal_d; #endif // !defined(_di_f_thread_mutexs_decrease_by_) || !defined(_di_f_thread_mutexs_increase_) || !defined(_di_f_thread_mutexs_increase_by_) #ifdef __cplusplus diff --git a/level_0/f_thread/c/thread/private-mutex_attribute.c b/level_0/f_thread/c/thread/private-mutex_attribute.c index 9b7c448..08fdc0b 100644 --- a/level_0/f_thread/c/thread/private-mutex_attribute.c +++ b/level_0/f_thread/c/thread/private-mutex_attribute.c @@ -6,9 +6,9 @@ extern "C" { #endif #if !defined(_di_f_thread_mutex_attributes_adjust_) || !defined(_di_f_thread_mutex_attributes_decimate_by_) || !defined(_di_f_thread_mutex_attributes_decrease_) || !defined(_di_f_thread_mutex_attributes_decrease_by_) || !defined(_di_f_thread_mutex_attributes_increase_) || !defined(_di_f_thread_mutex_attributes_increase_by_) || !defined(_di_f_thread_mutex_attributes_resize_) - f_status_t private_f_thread_mutex_attribute_delete(f_thread_mutex_attribute_t *attribute) { + f_status_t private_f_thread_mutex_attribute_delete(f_thread_mutex_attribute_t *structure) { - const int error = pthread_mutexattr_destroy(attribute); + const int error = pthread_mutexattr_destroy(structure); if (error) { if (error == EBUSY) return F_status_set_error(F_busy); @@ -22,32 +22,32 @@ extern "C" { #endif // !defined(_di_f_thread_mutex_attributes_adjust_) || !defined(_di_f_thread_mutex_attributes_decimate_by_) || !defined(_di_f_thread_mutex_attributes_decrease_) || !defined(_di_f_thread_mutex_attributes_decrease_by_) || !defined(_di_f_thread_mutex_attributes_increase_) || !defined(_di_f_thread_mutex_attributes_increase_by_) || !defined(_di_f_thread_mutex_attributes_resize_) #if !defined(_di_f_thread_mutex_attributes_adjust_) || !defined(_di_f_thread_mutex_attributes_decimate_by_) - f_status_t private_f_thread_mutex_attributes_adjust(const f_number_unsigned_t length, f_thread_mutex_attributes_t * const attributes) { + f_status_t private_f_thread_mutex_attributes_adjust(const f_number_unsigned_t length, f_thread_mutex_attributes_t * const structure) { f_status_t status = F_none; - for (f_number_unsigned_t i = length; i < attributes->size; ++i) { + for (f_number_unsigned_t i = length; i < structure->size; ++i) { - status = private_f_thread_mutex_attribute_delete(&attributes->array[i]); + status = private_f_thread_mutex_attribute_delete(&structure->array[i]); if (F_status_is_error(status)) return status; } // for - return f_memory_array_adjust(length, sizeof(f_thread_mutex_attribute_t), (void **) &attributes->array, &attributes->used, &attributes->size); + return f_memory_array_adjust(length, sizeof(f_thread_mutex_attribute_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // !defined(_di_f_thread_mutex_attributes_adjust_) || !defined(_di_f_thread_mutex_attributes_decimate_by_) #if !defined(_di_f_thread_mutex_attributes_decrease_) || !defined(_di_f_thread_mutex_attributes_decrease_by_) || !defined(_di_f_thread_mutex_attributes_increase_) || !defined(_di_f_thread_mutex_attributes_increase_by_) - f_status_t private_f_thread_mutex_attributes_resize(const f_number_unsigned_t length, f_thread_mutex_attributes_t * const attributes) { + f_status_t private_f_thread_mutex_attributes_resize(const f_number_unsigned_t length, f_thread_mutex_attributes_t * const structure) { f_status_t status = F_none; - for (f_number_unsigned_t i = length; i < attributes->size; ++i) { + for (f_number_unsigned_t i = length; i < structure->size; ++i) { - status = private_f_thread_mutex_attribute_delete(&attributes->array[i]); + status = private_f_thread_mutex_attribute_delete(&structure->array[i]); if (F_status_is_error(status)) return status; } // for - return f_memory_array_resize(length, sizeof(f_thread_mutex_attribute_t), (void **) &attributes->array, &attributes->used, &attributes->size); + return f_memory_array_resize(length, sizeof(f_thread_mutex_attribute_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // !defined(_di_f_thread_mutex_attributes_decrease_) || !defined(_di_f_thread_mutex_attributes_decrease_by_) || !defined(_di_f_thread_mutex_attributes_increase_) || !defined(_di_f_thread_mutex_attributes_increase_by_) diff --git a/level_0/f_thread/c/thread/private-mutex_attribute.h b/level_0/f_thread/c/thread/private-mutex_attribute.h index 74e90b5..2a0b863 100644 --- a/level_0/f_thread/c/thread/private-mutex_attribute.h +++ b/level_0/f_thread/c/thread/private-mutex_attribute.h @@ -20,7 +20,7 @@ extern "C" { * * Intended to be shared to each of the different implementation variations. * - * @param attribute + * @param structure * The attribute to delete. * * @return @@ -41,7 +41,7 @@ extern "C" { * @see f_thread_mutex_attributes_resize() */ #if !defined(_di_f_thread_mutex_attributes_adjust_) || !defined(_di_f_thread_mutex_attributes_decimate_by_) || !defined(_di_f_thread_mutex_attributes_decrease_) || !defined(_di_f_thread_mutex_attributes_decrease_by_) || !defined(_di_f_thread_mutex_attributes_increase_) || !defined(_di_f_thread_mutex_attributes_increase_by_) || !defined(_di_f_thread_mutex_attributes_resize_) - extern f_status_t private_f_thread_mutex_attribute_delete(f_thread_mutex_attribute_t *attribute) F_attribute_visibility_internal_d; + extern f_status_t private_f_thread_mutex_attribute_delete(f_thread_mutex_attribute_t *structure) F_attribute_visibility_internal_d; #endif // !defined(_di_f_thread_mutex_attributes_adjust_) || !defined(_di_f_thread_mutex_attributes_decimate_by_) || !defined(_di_f_thread_mutex_attributes_decrease_) || !defined(_di_f_thread_mutex_attributes_decrease_by_) || !defined(_di_f_thread_mutex_attributes_increase_) || !defined(_di_f_thread_mutex_attributes_increase_by_) || !defined(_di_f_thread_mutex_attributes_resize_) /** @@ -51,20 +51,21 @@ extern "C" { * * @param length * The new size to use. - * @param attributes - * The attributes to adjust. + * @param structure + * The mutex_attributes to adjust. * * @return * F_none on success. * - * Errors (with error bit) from: f_memory_adjust(). + * Errors (with error bit) from: f_memory_array_resize(). + * + * @see f_memory_array_resize() * - * @see f_memory_adjust() * @see f_thread_mutex_attributes_adjust() * @see f_thread_mutex_attributes_decimate_by() */ #if !defined(_di_f_thread_mutex_attributes_adjust_) || !defined(_di_f_thread_mutex_attributes_decimate_by_) - extern f_status_t private_f_thread_mutex_attributes_adjust(const f_number_unsigned_t length, f_thread_mutex_attributes_t * const attributes) F_attribute_visibility_internal_d; + extern f_status_t private_f_thread_mutex_attributes_adjust(const f_number_unsigned_t length, f_thread_mutex_attributes_t * const structure) F_attribute_visibility_internal_d; #endif // !defined(_di_f_thread_mutex_attributes_adjust_) || !defined(_di_f_thread_mutex_attributes_decimate_by_) /** @@ -74,21 +75,22 @@ extern "C" { * * @param length * The new size to use. - * @param attributes - * The attributes to resize. + * @param structure + * The mutex_attributes to resize. * * @return * F_none on success. * - * Errors (with error bit) from: f_memory_resize(). + * Errors (with error bit) from: f_memory_array_resize(). + * + * @see f_memory_array_resize() * - * @see f_memory_resize() * @see f_thread_mutex_attributes_decrease_by() * @see f_thread_mutex_attributes_increase() * @see f_thread_mutex_attributes_increase_by() */ #if !defined(_di_f_thread_mutex_attributes_decrease_by_) || !defined(_di_f_thread_mutex_attributes_increase_) || !defined(_di_f_thread_mutex_attributes_increase_by_) - extern f_status_t private_f_thread_mutex_attributes_resize(const f_number_unsigned_t length, f_thread_mutex_attributes_t * const attributes) F_attribute_visibility_internal_d; + extern f_status_t private_f_thread_mutex_attributes_resize(const f_number_unsigned_t length, f_thread_mutex_attributes_t * const structure) F_attribute_visibility_internal_d; #endif // !defined(_di_f_thread_mutex_attributes_decrease_by_) || !defined(_di_f_thread_mutex_attributes_increase_) || !defined(_di_f_thread_mutex_attributes_increase_by_) #ifdef __cplusplus diff --git a/level_0/f_thread/c/thread/private-once.c b/level_0/f_thread/c/thread/private-once.c index 80aaa24..34c1509 100644 --- a/level_0/f_thread/c/thread/private-once.c +++ b/level_0/f_thread/c/thread/private-once.c @@ -5,24 +5,6 @@ extern "C" { #endif -#if !defined(_di_f_thread_onces_adjust_) || !defined(_di_f_thread_onces_decimate_by_) - f_status_t private_f_thread_onces_adjust(const f_number_unsigned_t length, f_thread_onces_t * const onces) { - - if (onces->size) { - memset(onces->array, 0, sizeof(f_thread_once_t) * onces->size); - } - - return f_memory_array_adjust(length, sizeof(f_thread_once_t), (void **) &onces->array, &onces->used, &onces->size); - } -#endif // !defined(_di_f_thread_onces_adjust_) || !defined(_di_f_thread_onces_decimate_by_) - -#if !defined(_di_f_thread_onces_decrease_) || !defined(_di_f_thread_onces_decrease_by_) || !defined(_di_f_thread_onces_increase_) || !defined(_di_f_thread_onces_increase_by_) - f_status_t private_f_thread_onces_resize(const f_number_unsigned_t length, f_thread_onces_t * const onces) { - - return f_memory_array_resize(length, sizeof(f_thread_once_t), (void **) &onces->array, &onces->used, &onces->size); - } -#endif // !defined(_di_f_thread_onces_decrease_) || !defined(_di_f_thread_onces_decrease_by_) || !defined(_di_f_thread_onces_increase_) || !defined(_di_f_thread_onces_increase_by_) - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_0/f_thread/c/thread/private-once.h b/level_0/f_thread/c/thread/private-once.h index ecc8bd3..06504d6 100644 --- a/level_0/f_thread/c/thread/private-once.h +++ b/level_0/f_thread/c/thread/private-once.h @@ -15,53 +15,6 @@ extern "C" { #endif -/** - * Private implementation for resizing. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @param onces - * The onces to adjust. - * - * @return - * F_none on success. - * - * Errors (with error bit) from: f_memory_adjust(). - * - * @see f_memory_adjust() - * @see f_thread_onces_adjust() - * @see f_thread_onces_decimate_by() - */ -#if !defined(_di_f_thread_onces_adjust_) || !defined(_di_f_thread_onces_decimate_by_) - extern f_status_t private_f_thread_onces_adjust(const f_number_unsigned_t length, f_thread_onces_t * const onces) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_thread_onces_adjust_) || !defined(_di_f_thread_onces_decimate_by_) - -/** - * Private implementation for resizing. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @param onces - * The onces to resize. - * - * @return - * F_none on success. - * - * Errors (with error bit) from: f_memory_resize(). - * - * @see f_memory_resize() - * @see f_thread_onces_decrease_by() - * @see f_thread_onces_increase() - * @see f_thread_onces_increase_by() - */ -#if !defined(_di_f_thread_onces_decrease_by_) || !defined(_di_f_thread_onces_increase_) || !defined(_di_f_thread_onces_increase_by_) - extern f_status_t private_f_thread_onces_resize(const f_number_unsigned_t length, f_thread_onces_t * const onces) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_thread_onces_decrease_by_) || !defined(_di_f_thread_onces_increase_) || !defined(_di_f_thread_onces_increase_by_) - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_0/f_thread/c/thread/private-semaphore.c b/level_0/f_thread/c/thread/private-semaphore.c index c69bda7..e01b53b 100644 --- a/level_0/f_thread/c/thread/private-semaphore.c +++ b/level_0/f_thread/c/thread/private-semaphore.c @@ -6,9 +6,9 @@ extern "C" { #endif #if !defined(_di_f_thread_semaphores_adjust_) || !defined(_di_f_thread_semaphores_decimate_by_) || !defined(_di_f_thread_semaphores_decrease_) || !defined(_di_f_thread_semaphores_decrease_by_) || !defined(_di_f_thread_semaphores_increase_) || !defined(_di_f_thread_semaphores_increase_by_) || !defined(_di_f_thread_semaphores_resize_) - f_status_t private_f_thread_semaphore_delete(f_thread_semaphore_t *semaphore) { + f_status_t private_f_thread_semaphore_delete(f_thread_semaphore_t *structure) { - const int result = sem_destroy(semaphore); + const int result = sem_destroy(structure); if (result == -1) { if (errno == EINVAL) return F_status_set_error(F_parameter); @@ -21,32 +21,32 @@ extern "C" { #endif // !defined(_di_f_thread_semaphores_adjust_) || !defined(_di_f_thread_semaphores_decimate_by_) || !defined(_di_f_thread_semaphores_decrease_) || !defined(_di_f_thread_semaphores_decrease_by_) || !defined(_di_f_thread_semaphores_increase_) || !defined(_di_f_thread_semaphores_increase_by_) || !defined(_di_f_thread_semaphores_resize_) #if !defined(_di_f_thread_semaphores_adjust_) || !defined(_di_f_thread_semaphores_decimate_by_) - f_status_t private_f_thread_semaphores_adjust(const f_number_unsigned_t length, f_thread_semaphores_t * const semaphores) { + f_status_t private_f_thread_semaphores_adjust(const f_number_unsigned_t length, f_thread_semaphores_t * const structure) { f_status_t status = F_none; - for (f_number_unsigned_t i = length; i < semaphores->size; ++i) { + for (f_number_unsigned_t i = length; i < structure->size; ++i) { - status = private_f_thread_semaphore_delete(&semaphores->array[i]); + status = private_f_thread_semaphore_delete(&structure->array[i]); if (F_status_is_error(status)) return status; } // for - return f_memory_array_adjust(length, sizeof(f_thread_semaphore_t), (void **) &semaphores->array, &semaphores->used, &semaphores->size); + return f_memory_array_adjust(length, sizeof(f_thread_semaphore_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // !defined(_di_f_thread_semaphores_adjust_) || !defined(_di_f_thread_semaphores_decimate_by_) #if !defined(_di_f_thread_semaphores_decrease_) || !defined(_di_f_thread_semaphores_decrease_by_) || !defined(_di_f_thread_semaphores_increase_) || !defined(_di_f_thread_semaphores_increase_by_) - f_status_t private_f_thread_semaphores_resize(const f_number_unsigned_t length, f_thread_semaphores_t * const semaphores) { + f_status_t private_f_thread_semaphores_resize(const f_number_unsigned_t length, f_thread_semaphores_t * const structure) { f_status_t status = F_none; - for (f_number_unsigned_t i = length; i < semaphores->size; ++i) { + for (f_number_unsigned_t i = length; i < structure->size; ++i) { - status = private_f_thread_semaphore_delete(&semaphores->array[i]); + status = private_f_thread_semaphore_delete(&structure->array[i]); if (F_status_is_error(status)) return status; } // for - return f_memory_array_resize(length, sizeof(f_thread_semaphore_t), (void **) &semaphores->array, &semaphores->used, &semaphores->size); + return f_memory_array_resize(length, sizeof(f_thread_semaphore_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // !defined(_di_f_thread_semaphores_decrease_) || !defined(_di_f_thread_semaphores_decrease_by_) || !defined(_di_f_thread_semaphores_increase_) || !defined(_di_f_thread_semaphores_increase_by_) diff --git a/level_0/f_thread/c/thread/private-semaphore.h b/level_0/f_thread/c/thread/private-semaphore.h index abe7f48..06ffc6d 100644 --- a/level_0/f_thread/c/thread/private-semaphore.h +++ b/level_0/f_thread/c/thread/private-semaphore.h @@ -20,7 +20,7 @@ extern "C" { * * Intended to be shared to each of the different implementation variations. * - * @param semaphore + * @param structure * The semaphores to delete. * * @return @@ -41,7 +41,7 @@ extern "C" { * @see f_thread_semaphores_resize() */ #if !defined(_di_f_thread_semaphores_adjust_) || !defined(_di_f_thread_semaphores_decimate_by_) || !defined(_di_f_thread_semaphores_decrease_) || !defined(_di_f_thread_semaphores_decrease_by_) || !defined(_di_f_thread_semaphores_increase_) || !defined(_di_f_thread_semaphores_increase_by_) || !defined(_di_f_thread_semaphores_resize_) - extern f_status_t private_f_thread_semaphore_delete(f_thread_semaphore_t *semaphore) F_attribute_visibility_internal_d; + extern f_status_t private_f_thread_semaphore_delete(f_thread_semaphore_t *structure) F_attribute_visibility_internal_d; #endif // !defined(_di_f_thread_semaphores_adjust_) || !defined(_di_f_thread_semaphores_decimate_by_) || !defined(_di_f_thread_semaphores_decrease_) || !defined(_di_f_thread_semaphores_decrease_by_) || !defined(_di_f_thread_semaphores_increase_) || !defined(_di_f_thread_semaphores_increase_by_) || !defined(_di_f_thread_semaphores_resize_) /** @@ -51,20 +51,21 @@ extern "C" { * * @param length * The new size to use. - * @param semaphores + * @param structure * The semaphores to adjust. * * @return * F_none on success. * - * Errors (with error bit) from: f_memory_adjust(). + * Errors (with error bit) from: f_memory_array_resize(). + * + * @see f_memory_array_resize() * - * @see f_memory_adjust() * @see f_thread_semaphores_adjust() * @see f_thread_semaphores_decimate_by() */ #if !defined(_di_f_thread_semaphores_adjust_) || !defined(_di_f_thread_semaphores_decimate_by_) - extern f_status_t private_f_thread_semaphores_adjust(const f_number_unsigned_t length, f_thread_semaphores_t * const semaphores) F_attribute_visibility_internal_d; + extern f_status_t private_f_thread_semaphores_adjust(const f_number_unsigned_t length, f_thread_semaphores_t * const structure) F_attribute_visibility_internal_d; #endif // !defined(_di_f_thread_semaphores_adjust_) || !defined(_di_f_thread_semaphores_decimate_by_) /** @@ -74,21 +75,22 @@ extern "C" { * * @param length * The new size to use. - * @param semaphores + * @param structure * The semaphores to resize. * * @return * F_none on success. * - * Errors (with error bit) from: f_memory_resize(). + * Errors (with error bit) from: f_memory_array_resize(). + * + * @see f_memory_array_resize() * - * @see f_memory_resize() * @see f_thread_semaphores_decrease_by() * @see f_thread_semaphores_increase() * @see f_thread_semaphores_increase_by() */ #if !defined(_di_f_thread_semaphores_decrease_by_) || !defined(_di_f_thread_semaphores_increase_) || !defined(_di_f_thread_semaphores_increase_by_) - extern f_status_t private_f_thread_semaphores_resize(const f_number_unsigned_t length, f_thread_semaphores_t * const semaphores) F_attribute_visibility_internal_d; + extern f_status_t private_f_thread_semaphores_resize(const f_number_unsigned_t length, f_thread_semaphores_t * const structure) F_attribute_visibility_internal_d; #endif // !defined(_di_f_thread_semaphores_decrease_by_) || !defined(_di_f_thread_semaphores_increase_) || !defined(_di_f_thread_semaphores_increase_by_) #ifdef __cplusplus diff --git a/level_0/f_thread/c/thread/private-set.c b/level_0/f_thread/c/thread/private-set.c index 30e15f7..97b1370 100644 --- a/level_0/f_thread/c/thread/private-set.c +++ b/level_0/f_thread/c/thread/private-set.c @@ -7,32 +7,32 @@ extern "C" { #endif #if !defined(_di_f_thread_sets_adjust_) || !defined(_di_f_thread_sets_decimate_by_) - f_status_t private_f_thread_sets_adjust(const f_number_unsigned_t length, f_thread_sets_t * const sets) { + f_status_t private_f_thread_sets_adjust(const f_number_unsigned_t length, f_thread_sets_t * const structure) { 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 < structure->size; ++i) { - status = private_f_thread_attribute_delete(&sets->array[i].attribute); + status = private_f_thread_attribute_delete(&structure->array[i].attribute); if (F_status_is_error(status)) return status; } // for - return f_memory_array_adjust(length, sizeof(f_thread_set_t), (void **) &sets->array, &sets->used, &sets->size); + return f_memory_array_adjust(length, sizeof(f_thread_set_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // !defined(_di_f_thread_sets_adjust_) || !defined(_di_f_thread_sets_decimate_by_) #if !defined(_di_f_thread_sets_decrease_) || !defined(_di_f_thread_sets_decrease_by_) || !defined(_di_f_thread_sets_increase_) || !defined(_di_f_thread_sets_increase_by_) - f_status_t private_f_thread_sets_resize(const f_number_unsigned_t length, f_thread_sets_t * const sets) { + f_status_t private_f_thread_sets_resize(const f_number_unsigned_t length, f_thread_sets_t * const structure) { 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 < structure->size; ++i) { - status = private_f_thread_attribute_delete(&sets->array[i].attribute); + status = private_f_thread_attribute_delete(&structure->array[i].attribute); if (F_status_is_error(status)) return status; } // for - return f_memory_array_resize(length, sizeof(f_thread_set_t), (void **) &sets->array, &sets->used, &sets->size); + return f_memory_array_resize(length, sizeof(f_thread_set_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // !defined(_di_f_thread_sets_decrease_) || !defined(_di_f_thread_sets_decrease_by_) || !defined(_di_f_thread_sets_increase_) || !defined(_di_f_thread_sets_increase_by_) diff --git a/level_0/f_thread/c/thread/private-set.h b/level_0/f_thread/c/thread/private-set.h index ab8eb20..2f95a45 100644 --- a/level_0/f_thread/c/thread/private-set.h +++ b/level_0/f_thread/c/thread/private-set.h @@ -22,20 +22,21 @@ extern "C" { * * @param length * The new size to use. - * @param sets + * @param structure * The sets to adjust. * * @return * F_none on success. * - * Errors (with error bit) from: f_memory_adjust(). + * Errors (with error bit) from: f_memory_array_resize(). + * + * @see f_memory_array_resize() * - * @see f_memory_adjust() * @see f_thread_sets_adjust() * @see f_thread_sets_decimate_by() */ #if !defined(_di_f_thread_sets_adjust_) || !defined(_di_f_thread_sets_decimate_by_) - extern f_status_t private_f_thread_sets_adjust(const f_number_unsigned_t length, f_thread_sets_t * const sets) F_attribute_visibility_internal_d; + extern f_status_t private_f_thread_sets_adjust(const f_number_unsigned_t length, f_thread_sets_t * const structure) F_attribute_visibility_internal_d; #endif // !defined(_di_f_thread_sets_adjust_) || !defined(_di_f_thread_sets_decimate_by_) /** @@ -45,21 +46,22 @@ extern "C" { * * @param length * The new size to use. - * @param sets + * @param structure * The sets to resize. * * @return * F_none on success. * - * Errors (with error bit) from: f_memory_resize(). + * Errors (with error bit) from: f_memory_array_resize(). + * + * @see f_memory_array_resize() * - * @see f_memory_resize() * @see f_thread_sets_decrease_by() * @see f_thread_sets_increase() * @see f_thread_sets_increase_by() */ #if !defined(_di_f_thread_sets_decrease_by_) || !defined(_di_f_thread_sets_increase_) || !defined(_di_f_thread_sets_increase_by_) - extern f_status_t private_f_thread_sets_resize(const f_number_unsigned_t length, f_thread_sets_t * const sets) F_attribute_visibility_internal_d; + extern f_status_t private_f_thread_sets_resize(const f_number_unsigned_t length, f_thread_sets_t * const structure) F_attribute_visibility_internal_d; #endif // !defined(_di_f_thread_sets_decrease_by_) || !defined(_di_f_thread_sets_increase_) || !defined(_di_f_thread_sets_increase_by_) #ifdef __cplusplus diff --git a/level_0/f_thread/c/thread/private-spin.c b/level_0/f_thread/c/thread/private-spin.c index d5de418..5251c77 100644 --- a/level_0/f_thread/c/thread/private-spin.c +++ b/level_0/f_thread/c/thread/private-spin.c @@ -6,9 +6,9 @@ extern "C" { #endif #if !defined(_di_f_thread_spins_adjust_) || !defined(_di_f_thread_spins_decimate_by_) || !defined(_di_f_thread_spins_decrease_) || !defined(_di_f_thread_spins_decrease_by_) || !defined(_di_f_thread_spins_increase_) || !defined(_di_f_thread_spins_increase_by_) || !defined(_di_f_thread_spins_resize_) - f_status_t private_f_thread_spin_delete(f_thread_spin_t *spin) { + f_status_t private_f_thread_spin_delete(f_thread_spin_t *structure) { - const int error = pthread_spin_destroy(spin); + const int error = pthread_spin_destroy(structure); if (error) { if (error == EBUSY) return F_status_set_error(F_busy); @@ -22,32 +22,32 @@ extern "C" { #endif // !defined(_di_f_thread_spins_adjust_) || !defined(_di_f_thread_spins_decimate_by_) || !defined(_di_f_thread_spins_decrease_) || !defined(_di_f_thread_spins_decrease_by_) || !defined(_di_f_thread_spins_increase_) || !defined(_di_f_thread_spins_increase_by_) || !defined(_di_f_thread_spins_resize_) #if !defined(_di_f_thread_spins_adjust_) || !defined(_di_f_thread_spins_decimate_by_) - f_status_t private_f_thread_spins_adjust(const f_number_unsigned_t length, f_thread_spins_t * const spins) { + f_status_t private_f_thread_spins_adjust(const f_number_unsigned_t length, f_thread_spins_t * const structure) { f_status_t status = F_none; - for (f_number_unsigned_t i = length; i < spins->size; ++i) { + for (f_number_unsigned_t i = length; i < structure->size; ++i) { - status = private_f_thread_spin_delete(&spins->array[i]); + status = private_f_thread_spin_delete(&structure->array[i]); if (F_status_is_error(status)) return status; } // for - return f_memory_array_adjust(length, sizeof(f_thread_spin_t), (void **) &spins->array, &spins->used, &spins->size); + return f_memory_array_adjust(length, sizeof(f_thread_spin_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // !defined(_di_f_thread_spins_adjust_) || !defined(_di_f_thread_spins_decimate_by_) #if !defined(_di_f_thread_spins_decrease_) || !defined(_di_f_thread_spins_decrease_by_) || !defined(_di_f_thread_spins_increase_) || !defined(_di_f_thread_spins_increase_by_) - f_status_t private_f_thread_spins_resize(const f_number_unsigned_t length, f_thread_spins_t * const spins) { + f_status_t private_f_thread_spins_resize(const f_number_unsigned_t length, f_thread_spins_t * const structure) { f_status_t status = F_none; - for (f_number_unsigned_t i = length; i < spins->size; ++i) { + for (f_number_unsigned_t i = length; i < structure->size; ++i) { - status = private_f_thread_spin_delete(&spins->array[i]); + status = private_f_thread_spin_delete(&structure->array[i]); if (F_status_is_error(status)) return status; } // for - return f_memory_array_resize(length, sizeof(f_thread_spin_t), (void **) &spins->array, &spins->used, &spins->size); + return f_memory_array_resize(length, sizeof(f_thread_spin_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // !defined(_di_f_thread_spins_decrease_) || !defined(_di_f_thread_spins_decrease_by_) || !defined(_di_f_thread_spins_increase_) || !defined(_di_f_thread_spins_increase_by_) diff --git a/level_0/f_thread/c/thread/private-spin.h b/level_0/f_thread/c/thread/private-spin.h index a49ac72..c38d35d 100644 --- a/level_0/f_thread/c/thread/private-spin.h +++ b/level_0/f_thread/c/thread/private-spin.h @@ -20,7 +20,7 @@ extern "C" { * * Intended to be shared to each of the different implementation variations. * - * @param spin + * @param structure * The spins to delete. * * @return @@ -41,7 +41,7 @@ extern "C" { * @see f_thread_spins_resize() */ #if !defined(_di_f_thread_spins_adjust_) || !defined(_di_f_thread_spins_decimate_by_) || !defined(_di_f_thread_spins_decrease_) || !defined(_di_f_thread_spins_decrease_by_) || !defined(_di_f_thread_spins_increase_) || !defined(_di_f_thread_spins_increase_by_) || !defined(_di_f_thread_spins_resize_) - extern f_status_t private_f_thread_spin_delete(f_thread_spin_t *spin) F_attribute_visibility_internal_d; + extern f_status_t private_f_thread_spin_delete(f_thread_spin_t *structure) F_attribute_visibility_internal_d; #endif // !defined(_di_f_thread_spins_adjust_) || !defined(_di_f_thread_spins_decimate_by_) || !defined(_di_f_thread_spins_decrease_) || !defined(_di_f_thread_spins_decrease_by_) || !defined(_di_f_thread_spins_increase_) || !defined(_di_f_thread_spins_increase_by_) || !defined(_di_f_thread_spins_resize_) /** @@ -51,20 +51,21 @@ extern "C" { * * @param length * The new size to use. - * @param spins + * @param structure * The spins to adjust. * * @return * F_none on success. * - * Errors (with error bit) from: f_memory_adjust(). + * Errors (with error bit) from: f_memory_array_resize(). + * + * @see f_memory_array_resize() * - * @see f_memory_adjust() * @see f_thread_spins_adjust() * @see f_thread_spins_decimate_by() */ #if !defined(_di_f_thread_spins_adjust_) || !defined(_di_f_thread_spins_decimate_by_) - extern f_status_t private_f_thread_spins_adjust(const f_number_unsigned_t length, f_thread_spins_t * const spins) F_attribute_visibility_internal_d; + extern f_status_t private_f_thread_spins_adjust(const f_number_unsigned_t length, f_thread_spins_t * const structure) F_attribute_visibility_internal_d; #endif // !defined(_di_f_thread_spins_adjust_) || !defined(_di_f_thread_spins_decimate_by_) /** @@ -74,21 +75,22 @@ extern "C" { * * @param length * The new size to use. - * @param spins + * @param structure * The spins to resize. * * @return * F_none on success. * - * Errors (with error bit) from: f_memory_resize(). + * Errors (with error bit) from: f_memory_array_resize(). + * + * @see f_memory_array_resize() * - * @see f_memory_resize() * @see f_thread_spins_decrease_by() * @see f_thread_spins_increase() * @see f_thread_spins_increase_by() */ #if !defined(_di_f_thread_spins_decrease_by_) || !defined(_di_f_thread_spins_increase_) || !defined(_di_f_thread_spins_increase_by_) - extern f_status_t private_f_thread_spins_resize(const f_number_unsigned_t length, f_thread_spins_t * const spins) F_attribute_visibility_internal_d; + extern f_status_t private_f_thread_spins_resize(const f_number_unsigned_t length, f_thread_spins_t * const structure) F_attribute_visibility_internal_d; #endif // !defined(_di_f_thread_spins_decrease_by_) || !defined(_di_f_thread_spins_increase_) || !defined(_di_f_thread_spins_increase_by_) #ifdef __cplusplus diff --git a/level_0/f_thread/c/thread/semaphore.c b/level_0/f_thread/c/thread/semaphore.c index 9eb802e..366dda0 100644 --- a/level_0/f_thread/c/thread/semaphore.c +++ b/level_0/f_thread/c/thread/semaphore.c @@ -7,55 +7,55 @@ extern "C" { #endif #ifndef _di_f_thread_semaphores_adjust_ - f_status_t f_thread_semaphores_adjust(const f_number_unsigned_t length, f_thread_semaphores_t * const semaphores) { + f_status_t f_thread_semaphores_adjust(const f_number_unsigned_t length, f_thread_semaphores_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!semaphores) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_thread_semaphores_adjust(length, semaphores); + return private_f_thread_semaphores_adjust(length, structure); } #endif // _di_f_thread_semaphores_adjust_ #ifndef _di_f_thread_semaphores_decimate_by_ - f_status_t f_thread_semaphores_decimate_by(const f_number_unsigned_t amount, f_thread_semaphores_t * const semaphores) { + f_status_t f_thread_semaphores_decimate_by(const f_number_unsigned_t amount, f_thread_semaphores_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!semaphores) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - return private_f_thread_semaphores_adjust((semaphores->size > amount) ? semaphores->size - amount : 0, semaphores); + return private_f_thread_semaphores_adjust((structure->size > amount) ? structure->size - amount : 0, structure); } #endif // _di_f_thread_semaphores_decimate_by_ #ifndef _di_f_thread_semaphores_decrease_by_ - f_status_t f_thread_semaphores_decrease_by(const f_number_unsigned_t amount, f_thread_semaphores_t * const semaphores) { + f_status_t f_thread_semaphores_decrease_by(const f_number_unsigned_t amount, f_thread_semaphores_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!semaphores) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - return private_f_thread_semaphores_resize((semaphores->size > amount) ? semaphores->size - amount : 0, semaphores); + return private_f_thread_semaphores_resize((structure->size > amount) ? structure->size - amount : 0, structure); } #endif // _di_f_thread_semaphores_decrease_by_ #ifndef _di_f_thread_semaphores_increase_ - f_status_t f_thread_semaphores_increase(const f_number_unsigned_t step, f_thread_semaphores_t * const semaphores) { + f_status_t f_thread_semaphores_increase(const f_number_unsigned_t step, f_thread_semaphores_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!semaphores) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (step && semaphores->used + 1 > semaphores->size) { - f_number_unsigned_t size = semaphores->used + step; + if (step && structure->used + 1 > structure->size) { + f_number_unsigned_t length = structure->used + step; - if (size > F_number_t_size_unsigned_d) { - if (semaphores->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + if (length > F_number_t_size_unsigned_d) { + if (structure->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - size = F_number_t_size_unsigned_d; + length = F_number_t_size_unsigned_d; } - return private_f_thread_semaphores_resize(size, semaphores); + return private_f_thread_semaphores_resize(length, structure); } return F_data_not; @@ -63,20 +63,20 @@ extern "C" { #endif // _di_f_thread_semaphores_increase_ #ifndef _di_f_thread_semaphores_increase_by_ - f_status_t f_thread_semaphores_increase_by(const f_number_unsigned_t amount, f_thread_semaphores_t * const semaphores) { + f_status_t f_thread_semaphores_increase_by(const f_number_unsigned_t amount, f_thread_semaphores_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!semaphores) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (amount) { - if (semaphores->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + if (structure->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - const f_number_unsigned_t length = semaphores->used + amount; + const f_number_unsigned_t length = structure->used + amount; - if (length > semaphores->size) { + if (length > structure->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 private_f_thread_semaphores_resize(length, structure); } } @@ -85,12 +85,12 @@ extern "C" { #endif // _di_f_thread_semaphores_increase_by_ #ifndef _di_f_thread_semaphores_resize_ - f_status_t f_thread_semaphores_resize(const f_number_unsigned_t length, f_thread_semaphores_t * const semaphores) { + f_status_t f_thread_semaphores_resize(const f_number_unsigned_t length, f_thread_semaphores_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!semaphores) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_thread_semaphores_resize(length, semaphores); + return private_f_thread_semaphores_resize(length, structure); } #endif // _di_f_thread_semaphores_resize_ diff --git a/level_0/f_thread/c/thread/semaphore.h b/level_0/f_thread/c/thread/semaphore.h index 56ac067..1f622fe 100644 --- a/level_0/f_thread/c/thread/semaphore.h +++ b/level_0/f_thread/c/thread/semaphore.h @@ -71,8 +71,8 @@ extern "C" { * * @param length * The new size to use. - * @param semaphores - * The string semaphores array to resize. + * @param structure + * The thread semaphores array to resize. * * @return * F_none on success. @@ -81,7 +81,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_semaphores_adjust_ - extern f_status_t f_thread_semaphores_adjust(const f_number_unsigned_t length, f_thread_semaphores_t * const semaphores); + extern f_status_t f_thread_semaphores_adjust(const f_number_unsigned_t length, f_thread_semaphores_t * const structure); #endif // _di_f_thread_semaphores_adjust_ /** @@ -93,8 +93,8 @@ extern "C" { * * @param amount * A positive number representing how much to decimate the size by. - * @param semaphores - * The string semaphores array to resize. + * @param structure + * The thread semaphores array to resize. * * @return * F_none on success. @@ -104,7 +104,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_semaphores_decimate_by_ - extern f_status_t f_thread_semaphores_decimate_by(const f_number_unsigned_t amount, f_thread_semaphores_t * const semaphores); + extern f_status_t f_thread_semaphores_decimate_by(const f_number_unsigned_t amount, f_thread_semaphores_t * const structure); #endif // _di_f_thread_semaphores_decimate_by_ /** @@ -116,8 +116,8 @@ extern "C" { * * @param amount * A positive number representing how much to decrease the size by. - * @param semaphores - * The string semaphores array to resize. + * @param structure + * The thread semaphores array to resize. * * @return * F_none on success. @@ -127,7 +127,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_semaphores_decrease_by_ - extern f_status_t f_thread_semaphores_decrease_by(const f_number_unsigned_t amount, f_thread_semaphores_t * const semaphores); + extern f_status_t f_thread_semaphores_decrease_by(const f_number_unsigned_t amount, f_thread_semaphores_t * const structure); #endif // _di_f_thread_semaphores_decrease_by_ /** @@ -139,8 +139,8 @@ extern "C" { * @param step * The allocation step to use. * Must be greater than 0. - * @param semaphores - * The string semaphores array to resize. + * @param structure + * The thread semaphores array to resize. * * @return * F_none on success. @@ -151,7 +151,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_semaphores_increase_ - extern f_status_t f_thread_semaphores_increase(const f_number_unsigned_t step, f_thread_semaphores_t * const semaphores); + extern f_status_t f_thread_semaphores_increase(const f_number_unsigned_t step, f_thread_semaphores_t * const structure); #endif // _di_f_thread_semaphores_increase_ /** @@ -163,8 +163,8 @@ extern "C" { * * @param amount * A positive number representing how much to increase the size by. - * @param semaphores - * The string semaphores array to resize. + * @param structure + * The thread semaphores array to resize. * * @return * F_none on success. @@ -175,7 +175,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_semaphores_increase_by_ - extern f_status_t f_thread_semaphores_increase_by(const f_number_unsigned_t amount, f_thread_semaphores_t * const semaphores); + extern f_status_t f_thread_semaphores_increase_by(const f_number_unsigned_t amount, f_thread_semaphores_t * const structure); #endif // _di_f_thread_semaphores_increase_by_ /** @@ -183,8 +183,8 @@ extern "C" { * * @param length * The new size to use. - * @param semaphores - * The string semaphores array to adjust. + * @param structure + * The thread semaphores array to adjust. * * @return * F_none on success. @@ -193,7 +193,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_semaphores_resize_ - extern f_status_t f_thread_semaphores_resize(const f_number_unsigned_t length, f_thread_semaphores_t * const semaphores); + extern f_status_t f_thread_semaphores_resize(const f_number_unsigned_t length, f_thread_semaphores_t * const structure); #endif // _di_f_thread_semaphores_resize_ #ifdef __cplusplus diff --git a/level_0/f_thread/c/thread/set.c b/level_0/f_thread/c/thread/set.c index d2fd766..2b4f782 100644 --- a/level_0/f_thread/c/thread/set.c +++ b/level_0/f_thread/c/thread/set.c @@ -7,55 +7,55 @@ extern "C" { #endif #ifndef _di_f_thread_sets_adjust_ - f_status_t f_thread_sets_adjust(const f_number_unsigned_t length, f_thread_sets_t * const sets) { + f_status_t f_thread_sets_adjust(const f_number_unsigned_t length, f_thread_sets_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!sets) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_thread_sets_adjust(length, sets); + return private_f_thread_sets_adjust(length, structure); } #endif // _di_f_thread_sets_adjust_ #ifndef _di_f_thread_sets_decimate_by_ - f_status_t f_thread_sets_decimate_by(const f_number_unsigned_t amount, f_thread_sets_t * const sets) { + f_status_t f_thread_sets_decimate_by(const f_number_unsigned_t amount, f_thread_sets_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!sets) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - return private_f_thread_sets_adjust((sets->size > amount) ? sets->size - amount : 0, sets); + return private_f_thread_sets_adjust((structure->size > amount) ? structure->size - amount : 0, structure); } #endif // _di_f_thread_sets_decimate_by_ #ifndef _di_f_thread_sets_decrease_by_ - f_status_t f_thread_sets_decrease_by(const f_number_unsigned_t amount, f_thread_sets_t * const sets) { + f_status_t f_thread_sets_decrease_by(const f_number_unsigned_t amount, f_thread_sets_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!sets) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - return private_f_thread_sets_resize((sets->size > amount) ? sets->size - amount : 0, sets); + return private_f_thread_sets_resize((structure->size > amount) ? structure->size - amount : 0, structure); } #endif // _di_f_thread_sets_decrease_by_ #ifndef _di_f_thread_sets_increase_ - f_status_t f_thread_sets_increase(const f_number_unsigned_t step, f_thread_sets_t * const sets) { + f_status_t f_thread_sets_increase(const f_number_unsigned_t step, f_thread_sets_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!sets) return F_status_set_error(F_parameter); + if (!structure) 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 (step && structure->used + 1 > structure->size) { + f_number_unsigned_t length = structure->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); + if (length > F_number_t_size_unsigned_d) { + if (structure->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - size = F_number_t_size_unsigned_d; + length = F_number_t_size_unsigned_d; } - return private_f_thread_sets_resize(size, sets); + return private_f_thread_sets_resize(length, structure); } return F_data_not; @@ -63,20 +63,20 @@ extern "C" { #endif // _di_f_thread_sets_increase_ #ifndef _di_f_thread_sets_increase_by_ - f_status_t f_thread_sets_increase_by(const f_number_unsigned_t amount, f_thread_sets_t * const sets) { + f_status_t f_thread_sets_increase_by(const f_number_unsigned_t amount, f_thread_sets_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!sets) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (amount) { - if (sets->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + if (structure->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - const f_number_unsigned_t length = sets->used + amount; + const f_number_unsigned_t length = structure->used + amount; - if (length > sets->size) { + if (length > structure->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 private_f_thread_sets_resize(length, structure); } } @@ -85,12 +85,12 @@ extern "C" { #endif // _di_f_thread_sets_increase_by_ #ifndef _di_f_thread_sets_resize_ - f_status_t f_thread_sets_resize(const f_number_unsigned_t length, f_thread_sets_t * const sets) { + f_status_t f_thread_sets_resize(const f_number_unsigned_t length, f_thread_sets_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!sets) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_thread_sets_resize(length, sets); + return private_f_thread_sets_resize(length, structure); } #endif // _di_f_thread_sets_resize_ diff --git a/level_0/f_thread/c/thread/set.h b/level_0/f_thread/c/thread/set.h index c092154..539f630 100644 --- a/level_0/f_thread/c/thread/set.h +++ b/level_0/f_thread/c/thread/set.h @@ -81,8 +81,8 @@ extern "C" { * * @param length * The new size to use. - * @param sets - * The string sets array to resize. + * @param structure + * The thread sets array to resize. * * @return * F_none on success. @@ -91,7 +91,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_sets_adjust_ - extern f_status_t f_thread_sets_adjust(const f_number_unsigned_t length, f_thread_sets_t * const sets); + extern f_status_t f_thread_sets_adjust(const f_number_unsigned_t length, f_thread_sets_t * const structure); #endif // _di_f_thread_sets_adjust_ /** @@ -103,8 +103,8 @@ extern "C" { * * @param amount * A positive number representing how much to decimate the size by. - * @param sets - * The string sets array to resize. + * @param structure + * The thread sets array to resize. * * @return * F_none on success. @@ -114,7 +114,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_sets_decimate_by_ - extern f_status_t f_thread_sets_decimate_by(const f_number_unsigned_t amount, f_thread_sets_t * const sets); + extern f_status_t f_thread_sets_decimate_by(const f_number_unsigned_t amount, f_thread_sets_t * const structure); #endif // _di_f_thread_sets_decimate_by_ /** @@ -126,8 +126,8 @@ extern "C" { * * @param amount * A positive number representing how much to decrease the size by. - * @param sets - * The string sets array to resize. + * @param structure + * The thread sets array to resize. * * @return * F_none on success. @@ -137,7 +137,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_sets_decrease_by_ - extern f_status_t f_thread_sets_decrease_by(const f_number_unsigned_t amount, f_thread_sets_t * const sets); + extern f_status_t f_thread_sets_decrease_by(const f_number_unsigned_t amount, f_thread_sets_t * const structure); #endif // _di_f_thread_sets_decrease_by_ /** @@ -149,8 +149,8 @@ extern "C" { * @param step * The allocation step to use. * Must be greater than 0. - * @param sets - * The string sets array to resize. + * @param structure + * The thread sets array to resize. * * @return * F_none on success. @@ -161,7 +161,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_sets_increase_ - extern f_status_t f_thread_sets_increase(const f_number_unsigned_t step, f_thread_sets_t * const sets); + extern f_status_t f_thread_sets_increase(const f_number_unsigned_t step, f_thread_sets_t * const structure); #endif // _di_f_thread_sets_increase_ /** @@ -173,8 +173,8 @@ extern "C" { * * @param amount * A positive number representing how much to increase the size by. - * @param sets - * The string sets array to resize. + * @param structure + * The thread sets array to resize. * * @return * F_none on success. @@ -185,7 +185,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_sets_increase_by_ - extern f_status_t f_thread_sets_increase_by(const f_number_unsigned_t amount, f_thread_sets_t * const sets); + extern f_status_t f_thread_sets_increase_by(const f_number_unsigned_t amount, f_thread_sets_t * const structure); #endif // _di_f_thread_sets_increase_by_ /** @@ -193,8 +193,8 @@ extern "C" { * * @param length * The new size to use. - * @param sets - * The string sets array to adjust. + * @param structure + * The thread sets array to adjust. * * @return * F_none on success. @@ -203,7 +203,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_sets_resize_ - extern f_status_t f_thread_sets_resize(const f_number_unsigned_t length, f_thread_sets_t * const sets); + extern f_status_t f_thread_sets_resize(const f_number_unsigned_t length, f_thread_sets_t * const structure); #endif // _di_f_thread_sets_resize_ #ifdef __cplusplus diff --git a/level_0/f_thread/c/thread/spin.c b/level_0/f_thread/c/thread/spin.c index a74a2f5..7bcebc9 100644 --- a/level_0/f_thread/c/thread/spin.c +++ b/level_0/f_thread/c/thread/spin.c @@ -7,57 +7,55 @@ extern "C" { #endif #ifndef _di_f_thread_spins_adjust_ - f_status_t f_thread_spins_adjust(const f_number_unsigned_t length, f_thread_spins_t * const spins) { + f_status_t f_thread_spins_adjust(const f_number_unsigned_t length, f_thread_spins_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!spins) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_thread_spins_adjust(length, spins); + return private_f_thread_spins_adjust(length, structure); } #endif // _di_f_thread_spins_adjust_ #ifndef _di_f_thread_spins_decimate_by_ - f_status_t f_thread_spins_decimate_by(const f_number_unsigned_t amount, f_thread_spins_t * const spins) { + f_status_t f_thread_spins_decimate_by(const f_number_unsigned_t amount, f_thread_spins_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!spins) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - return private_f_thread_spins_adjust((spins->size > amount) ? spins->size - amount : 0, spins); + return private_f_thread_spins_adjust((structure->size > amount) ? structure->size - amount : 0, structure); } #endif // _di_f_thread_spins_decimate_by_ #ifndef _di_f_thread_spins_decrease_by_ - f_status_t f_thread_spins_decrease_by(const f_number_unsigned_t amount, f_thread_spins_t * const spins) { + f_status_t f_thread_spins_decrease_by(const f_number_unsigned_t amount, f_thread_spins_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!spins) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - return private_f_thread_spins_resize((spins->size > amount) ? spins->size - amount : 0, spins); + return private_f_thread_spins_resize((structure->size > amount) ? structure->size - amount : 0, structure); } #endif // _di_f_thread_spins_decrease_by_ #ifndef _di_f_thread_spins_increase_ - f_status_t f_thread_spins_increase(const f_number_unsigned_t step, f_thread_spins_t * const spins) { + f_status_t f_thread_spins_increase(const f_number_unsigned_t step, f_thread_spins_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!spins) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (step && spins->used + 1 > spins->size) { - f_number_unsigned_t size = spins->used + step; + if (step && structure->used + 1 > structure->size) { + f_number_unsigned_t length = structure->used + step; - if (size > F_number_t_size_unsigned_d) { - if (spins->used + 1 > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + if (length > F_number_t_size_unsigned_d) { + if (structure->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - size = F_number_t_size_unsigned_d; + length = F_number_t_size_unsigned_d; } - return private_f_thread_spins_resize(size, spins); + return private_f_thread_spins_resize(length, structure); } return F_data_not; @@ -65,20 +63,20 @@ extern "C" { #endif // _di_f_thread_spins_increase_ #ifndef _di_f_thread_spins_increase_by_ - f_status_t f_thread_spins_increase_by(const f_number_unsigned_t amount, f_thread_spins_t * const spins) { + f_status_t f_thread_spins_increase_by(const f_number_unsigned_t amount, f_thread_spins_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!spins) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (amount) { - if (spins->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + if (structure->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - const f_number_unsigned_t length = spins->used + amount; + const f_number_unsigned_t length = structure->used + amount; - if (length > spins->size) { + if (length > structure->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 private_f_thread_spins_resize(length, structure); } } @@ -87,12 +85,12 @@ extern "C" { #endif // _di_f_thread_spins_increase_by_ #ifndef _di_f_thread_spins_resize_ - f_status_t f_thread_spins_resize(const f_number_unsigned_t length, f_thread_spins_t * const spins) { + f_status_t f_thread_spins_resize(const f_number_unsigned_t length, f_thread_spins_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!spins) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_thread_spins_resize(length, spins); + return private_f_thread_spins_resize(length, structure); } #endif // _di_f_thread_spins_resize_ diff --git a/level_0/f_thread/c/thread/spin.h b/level_0/f_thread/c/thread/spin.h index d6f7f92..fd67e6f 100644 --- a/level_0/f_thread/c/thread/spin.h +++ b/level_0/f_thread/c/thread/spin.h @@ -65,12 +65,12 @@ extern "C" { #endif // _di_f_thread_spins_t_ /** - * Resize the thread spin locks array. + * Resize the thread spins array. * * @param length * The new size to use. - * @param spins - * The string spins array to resize. + * @param structure + * The thread spins array to resize. * * @return * F_none on success. @@ -79,11 +79,11 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_spins_adjust_ - extern f_status_t f_thread_spins_adjust(const f_number_unsigned_t length, f_thread_spins_t * const spins); + extern f_status_t f_thread_spins_adjust(const f_number_unsigned_t length, f_thread_spins_t * const structure); #endif // _di_f_thread_spins_adjust_ /** - * Resize the thread spin locks array to a smaller size. + * Resize the thread spins array to a smaller size. * * This will resize making the array smaller based on (size - given length). * If the given length is too small, then the resize will fail. @@ -91,8 +91,8 @@ extern "C" { * * @param amount * A positive number representing how much to decimate the size by. - * @param spins - * The string spins array to resize. + * @param structure + * The thread spins array to resize. * * @return * F_none on success. @@ -102,11 +102,11 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_spins_decimate_by_ - extern f_status_t f_thread_spins_decimate_by(const f_number_unsigned_t amount, f_thread_spins_t * const spins); + extern f_status_t f_thread_spins_decimate_by(const f_number_unsigned_t amount, f_thread_spins_t * const structure); #endif // _di_f_thread_spins_decimate_by_ /** - * Resize the thread spin locks array to a smaller size. + * Resize the thread spins array to a smaller size. * * This will resize making the array smaller based on (size - given length). * If the given length is too small, then the resize will fail. @@ -114,8 +114,8 @@ extern "C" { * * @param amount * A positive number representing how much to decrease the size by. - * @param spins - * The string spins array to resize. + * @param structure + * The thread spins array to resize. * * @return * F_none on success. @@ -125,11 +125,11 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_spins_decrease_by_ - extern f_status_t f_thread_spins_decrease_by(const f_number_unsigned_t amount, f_thread_spins_t * const spins); + extern f_status_t f_thread_spins_decrease_by(const f_number_unsigned_t amount, f_thread_spins_t * const structure); #endif // _di_f_thread_spins_decrease_by_ /** - * Increase the size of the thread spin locks array, but only if necessary. + * Increase the size of the thread spins array, 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. @@ -137,8 +137,8 @@ extern "C" { * @param step * The allocation step to use. * Must be greater than 0. - * @param spins - * The string spins array to resize. + * @param structure + * The thread spins array to resize. * * @return * F_none on success. @@ -149,11 +149,11 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_spins_increase_ - extern f_status_t f_thread_spins_increase(const f_number_unsigned_t step, f_thread_spins_t * const spins); + extern f_status_t f_thread_spins_increase(const f_number_unsigned_t step, f_thread_spins_t * const structure); #endif // _di_f_thread_spins_increase_ /** - * Resize the thread spin locks array to a larger size. + * Resize the thread spins array 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). @@ -161,8 +161,8 @@ extern "C" { * * @param amount * A positive number representing how much to increase the size by. - * @param spins - * The string spins array to resize. + * @param structure + * The thread spins array to resize. * * @return * F_none on success. @@ -173,16 +173,16 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_spins_increase_by_ - extern f_status_t f_thread_spins_increase_by(const f_number_unsigned_t amount, f_thread_spins_t * const spins); + extern f_status_t f_thread_spins_increase_by(const f_number_unsigned_t amount, f_thread_spins_t * const structure); #endif // _di_f_thread_spins_increase_by_ /** - * Resize the thread spin locks array. + * Resize the thread spins array. * * @param length * The new size to use. - * @param spins - * The string spins array to adjust. + * @param structure + * The thread spins array to adjust. * * @return * F_none on success. @@ -191,7 +191,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_spins_resize_ - extern f_status_t f_thread_spins_resize(const f_number_unsigned_t length, f_thread_spins_t * const spins); + extern f_status_t f_thread_spins_resize(const f_number_unsigned_t length, f_thread_spins_t * const structure); #endif // _di_f_thread_spins_resize_ #ifdef __cplusplus diff --git a/level_0/f_type_array/c/type_array/cell.c b/level_0/f_type_array/c/type_array/cell.c index 159d219..2de2111 100644 --- a/level_0/f_type_array/c/type_array/cell.c +++ b/level_0/f_type_array/c/type_array/cell.c @@ -7,12 +7,12 @@ extern "C" { #endif #ifndef _di_f_cells_adjust_ - f_status_t f_cells_adjust(const f_number_unsigned_t length, f_cells_t * const cells) { + f_status_t f_cells_adjust(const f_number_unsigned_t length, f_cells_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!cells) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_cells_adjust(length, cells); + return f_memory_array_adjust(length, sizeof(f_cell_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_cells_adjust_ @@ -39,98 +39,62 @@ extern "C" { #endif // _di_f_cells_append_all_ #ifndef _di_f_cells_decimate_by_ - f_status_t f_cells_decimate_by(const f_number_unsigned_t amount, f_cells_t * const cells) { + f_status_t f_cells_decimate_by(const f_number_unsigned_t amount, f_cells_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!cells) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; - - if (cells->size - amount > 0) { - return private_f_cells_adjust(cells->size - amount, cells); - } - - return private_f_cells_adjust(0, cells); + return f_memory_array_decimate_by(amount, sizeof(f_cell_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_cells_decimate_by_ #ifndef _di_f_cells_decrease_by_ - f_status_t f_cells_decrease_by(const f_number_unsigned_t amount, f_cells_t * const cells) { + f_status_t f_cells_decrease_by(const f_number_unsigned_t amount, f_cells_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!cells) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; - - if (cells->size - amount > 0) { - return private_f_cells_resize(cells->size - amount, cells); - } - - return private_f_cells_resize(0, cells); + return f_memory_array_decrease_by(amount, sizeof(f_cell_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_cells_decrease_by_ #ifndef _di_f_cells_increase_ - f_status_t f_cells_increase(const f_number_unsigned_t step, f_cells_t * const cells) { + f_status_t f_cells_increase(const f_number_unsigned_t step, f_cells_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!cells) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (step && cells->used + 1 > cells->size) { - f_number_unsigned_t size = cells->used + step; - - if (size > F_number_t_size_unsigned_d) { - if (cells->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_cells_resize(size, cells); - } - - return F_data_not; + return f_memory_array_increase(step, sizeof(f_cell_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_cells_increase_ #ifndef _di_f_cells_increase_by_ - f_status_t f_cells_increase_by(const f_number_unsigned_t amount, f_cells_t * const cells) { + f_status_t f_cells_increase_by(const f_number_unsigned_t amount, f_cells_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!cells) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; - - if (cells->used + amount > cells->size) { - if (cells->used + amount > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } - - return private_f_cells_resize(cells->used + amount, cells); - } - - return F_data_not; + return f_memory_array_increase_by(amount, sizeof(f_cell_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_cells_increase_by_ #ifndef _di_f_cells_resize_ - f_status_t f_cells_resize(const f_number_unsigned_t length, f_cells_t * const cells) { + f_status_t f_cells_resize(const f_number_unsigned_t length, f_cells_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!cells) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_cells_resize(length, cells); + return f_memory_array_resize(length, sizeof(f_cell_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_cells_resize_ #ifndef _di_f_cellss_adjust_ - f_status_t f_cellss_adjust(const f_number_unsigned_t length, f_cellss_t * const cellss) { + f_status_t f_cellss_adjust(const f_number_unsigned_t length, f_cellss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!cellss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_cellss_adjust(length, cellss); + return private_f_cellss_adjust(length, structure); } #endif // _di_f_cellss_adjust_ @@ -142,12 +106,8 @@ extern "C" { if (!source.used) return F_data_not; - f_status_t status = F_none; - - if (destination->used + 1 > destination->size) { - status = private_f_cellss_resize(destination->used + F_memory_default_allocation_small_d, destination); - if (F_status_is_error(status)) return status; - } + f_status_t status = f_memory_array_increase(F_memory_default_allocation_small_d, sizeof(f_cells_t), (void **) &destination->array, &destination->used, &destination->size); + if (F_status_is_error(status)) return status; status = private_f_cells_append_all(source, &destination->array[destination->used]); if (F_status_is_error(status)) return status; @@ -166,12 +126,8 @@ extern "C" { if (!source.used) return F_data_not; - f_status_t status = F_none; - - if (destination->used + source.used > destination->size) { - status = private_f_cellss_resize(destination->used + source.used, destination); - if (F_status_is_error(status)) return status; - } + f_status_t status = f_memory_array_increase_by(source.used, sizeof(f_cells_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->used) { @@ -188,55 +144,47 @@ extern "C" { #endif // _di_f_cellss_append_all_ #ifndef _di_f_cellss_decimate_by_ - f_status_t f_cellss_decimate_by(const f_number_unsigned_t amount, f_cellss_t * const cellss) { + f_status_t f_cellss_decimate_by(const f_number_unsigned_t amount, f_cellss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!cellss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - if (cellss->size - amount > 0) { - return private_f_cellss_adjust(cellss->size - amount, cellss); - } - - return private_f_cellss_adjust(0, cellss); + return private_f_cellss_adjust((structure->size - amount > 0) ? structure->size - amount : 0, structure); } #endif // _di_f_cellss_decimate_by_ #ifndef _di_f_cellss_decrease_by_ - f_status_t f_cellss_decrease_by(const f_number_unsigned_t amount, f_cellss_t * const cellss) { + f_status_t f_cellss_decrease_by(const f_number_unsigned_t amount, f_cellss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!cellss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - if (cellss->size - amount > 0) { - return private_f_cellss_resize(cellss->size - amount, cellss); - } - - return private_f_cellss_resize(0, cellss); + return private_f_cellss_resize((structure->size - amount > 0) ? structure->size - amount : 0, structure); } #endif // _di_f_cellss_decrease_by_ #ifndef _di_f_cellss_increase_ - f_status_t f_cellss_increase(const f_number_unsigned_t step, f_cellss_t * const cellss) { + f_status_t f_cellss_increase(const f_number_unsigned_t step, f_cellss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!cellss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (step && cellss->used + 1 > cellss->size) { - f_number_unsigned_t size = cellss->used + step; + if (step && structure->used + 1 > structure->size) { + if (structure->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + + f_number_unsigned_t length = structure->used + step; - if (size > F_number_t_size_unsigned_d) { - if (cellss->used + 1 > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + if (length > F_number_t_size_unsigned_d) { + if (structure->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - size = F_number_t_size_unsigned_d; + length = F_number_t_size_unsigned_d; } - return private_f_cellss_resize(size, cellss); + return private_f_cellss_resize(length, structure); } return F_data_not; @@ -244,19 +192,21 @@ extern "C" { #endif // _di_f_cellss_increase_ #ifndef _di_f_cellss_increase_by_ - f_status_t f_cellss_increase_by(const f_number_unsigned_t amount, f_cellss_t * const cellss) { + f_status_t f_cellss_increase_by(const f_number_unsigned_t amount, f_cellss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!cellss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; + if (amount) { + if (structure->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - if (cellss->used + amount > cellss->size) { - if (cellss->used + amount > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + const f_number_unsigned_t length = structure->used + amount; - return private_f_cellss_resize(cellss->used + amount, cellss); + if (length > structure->size) { + if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + + return private_f_cellss_resize(structure->used + amount, structure); + } } return F_data_not; @@ -264,12 +214,12 @@ extern "C" { #endif // _di_f_cellss_increase_by_ #ifndef _di_f_cellss_resize_ - f_status_t f_cellss_resize(const f_number_unsigned_t length, f_cellss_t * const cellss) { + f_status_t f_cellss_resize(const f_number_unsigned_t length, f_cellss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!cellss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_cellss_resize(length, cellss); + return private_f_cellss_resize(length, structure); } #endif // _di_f_cellss_resize_ diff --git a/level_0/f_type_array/c/type_array/cell.h b/level_0/f_type_array/c/type_array/cell.h index d0d40a8..5dcf80c 100644 --- a/level_0/f_type_array/c/type_array/cell.h +++ b/level_0/f_type_array/c/type_array/cell.h @@ -21,7 +21,7 @@ extern "C" { * * @param length * The new size to use. - * @param cells + * @param structure * The string cells array to resize. * * @return @@ -29,10 +29,12 @@ extern "C" { * * 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_array_adjust(). + * + * @see f_memory_array_adjust() */ #ifndef _di_f_cells_adjust_ - extern f_status_t f_cells_adjust(const f_number_unsigned_t length, f_cells_t * const cells); + extern f_status_t f_cells_adjust(const f_number_unsigned_t length, f_cells_t * const structure); #endif // _di_f_cells_adjust_ /** @@ -49,7 +51,9 @@ extern "C" { * * 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(). + * + * @see f_memory_array_increase() */ #ifndef _di_f_cells_append_ extern f_status_t f_cells_append(const f_cell_t source, f_cells_t * const destination); @@ -69,7 +73,9 @@ extern "C" { * * 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() */ #ifndef _di_f_cells_append_all_ extern f_status_t f_cells_append_all(const f_cells_t source, f_cells_t * const destination); @@ -84,7 +90,7 @@ extern "C" { * * @param amount * A positive number representing how much to decimate the size by. - * @param cells + * @param structure * The string cells array to resize. * * @return @@ -93,10 +99,12 @@ extern "C" { * * 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_array_decimate_by(). + * + * @see f_memory_array_decimate_by() */ #ifndef _di_f_cells_decimate_by_ - extern f_status_t f_cells_decimate_by(const f_number_unsigned_t amount, f_cells_t * const cells); + extern f_status_t f_cells_decimate_by(const f_number_unsigned_t amount, f_cells_t * const structure); #endif // _di_f_cells_decimate_by_ /** @@ -108,7 +116,7 @@ extern "C" { * * @param amount * A positive number representing how much to decrease the size by. - * @param cells + * @param structure * The string cells array to resize. * * @return @@ -117,10 +125,12 @@ extern "C" { * * 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_decrease_by(). + * + * @see f_memory_array_decrease_by() */ #ifndef _di_f_cells_decrease_by_ - extern f_status_t f_cells_decrease_by(const f_number_unsigned_t amount, f_cells_t * const cells); + extern f_status_t f_cells_decrease_by(const f_number_unsigned_t amount, f_cells_t * const structure); #endif // _di_f_cells_decrease_by_ /** @@ -132,7 +142,7 @@ extern "C" { * @param step * The allocation step to use. * Must be greater than 0. - * @param cells + * @param structure * The string cells array to resize. * * @return @@ -142,10 +152,12 @@ extern "C" { * F_array_too_large (with error bit) if the new array length is too large. * 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(). + * + * @see f_memory_array_increase() */ #ifndef _di_f_cells_increase_ - extern f_status_t f_cells_increase(const f_number_unsigned_t step, f_cells_t * const cells); + extern f_status_t f_cells_increase(const f_number_unsigned_t step, f_cells_t * const structure); #endif // _di_f_cells_increase_ /** @@ -157,7 +169,7 @@ extern "C" { * * @param amount * A positive number representing how much to increase the size by. - * @param cells + * @param structure * The string cells array to resize. * * @return @@ -167,10 +179,12 @@ extern "C" { * F_array_too_large (with error bit) if the new array length is too large. * 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() */ #ifndef _di_f_cells_increase_by_ - extern f_status_t f_cells_increase_by(const f_number_unsigned_t amount, f_cells_t * const cells); + extern f_status_t f_cells_increase_by(const f_number_unsigned_t amount, f_cells_t * const structure); #endif // _di_f_cells_increase_by_ /** @@ -178,7 +192,7 @@ extern "C" { * * @param length * The new size to use. - * @param cells + * @param structure * The string cells array to adjust. * * @return @@ -186,10 +200,12 @@ extern "C" { * * 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(). + * + * @see f_memory_array_resize() */ #ifndef _di_f_cells_resize_ - extern f_status_t f_cells_resize(const f_number_unsigned_t length, f_cells_t * const cells); + extern f_status_t f_cells_resize(const f_number_unsigned_t length, f_cells_t * const structure); #endif // _di_f_cells_resize_ /** @@ -197,7 +213,7 @@ extern "C" { * * @param length * The new size to use. - * @param cellss + * @param structure * The string cellss array to resize. * * @return @@ -205,11 +221,12 @@ extern "C" { * * 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() */ #ifndef _di_f_cellss_adjust_ - extern f_status_t f_cellss_adjust(const f_number_unsigned_t length, f_cellss_t * const cellss); + extern f_status_t f_cellss_adjust(const f_number_unsigned_t length, f_cellss_t * const structure); #endif // _di_f_cellss_adjust_ /** @@ -226,7 +243,11 @@ extern "C" { * * 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(). + * Errors (with error bit) from: f_memory_array_increase_by(). + * + * @see f_memory_array_increase() + * @see f_memory_array_increase_by() */ #ifndef _di_f_cellss_append_ extern f_status_t f_cellss_append(const f_cells_t source, f_cellss_t * const destination); @@ -246,7 +267,9 @@ extern "C" { * * 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() */ #ifndef _di_f_cellss_append_all_ extern f_status_t f_cellss_append_all(const f_cellss_t source, f_cellss_t * const destination); @@ -261,7 +284,7 @@ extern "C" { * * @param amount * A positive number representing how much to decimate the size by. - * @param cellss + * @param structure * The string cellss array to resize. * * @return @@ -269,11 +292,12 @@ extern "C" { * * 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() */ #ifndef _di_f_cellss_decimate_by_ - extern f_status_t f_cellss_decimate_by(const f_number_unsigned_t amount, f_cellss_t * const cellss); + extern f_status_t f_cellss_decimate_by(const f_number_unsigned_t amount, f_cellss_t * const structure); #endif // _di_f_cellss_decimate_by_ /** @@ -285,7 +309,7 @@ extern "C" { * * @param amount * A positive number representing how much to decrease the size by. - * @param cellss + * @param structure * The string cellss array to resize. * * @return @@ -293,11 +317,12 @@ extern "C" { * * 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() */ #ifndef _di_f_cellss_decrease_by_ - extern f_status_t f_cellss_decrease_by(const f_number_unsigned_t amount, f_cellss_t * const cellss); + extern f_status_t f_cellss_decrease_by(const f_number_unsigned_t amount, f_cellss_t * const structure); #endif // _di_f_cellss_decrease_by_ /** @@ -309,7 +334,7 @@ extern "C" { * @param step * The allocation step to use. * Must be greater than 0. - * @param cellss + * @param structure * The string cellss array to resize. * * @return @@ -319,10 +344,12 @@ extern "C" { * F_array_too_large (with error bit) if the new array length is too large. * 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(). + * + * @see f_memory_array_resize() */ #ifndef _di_f_cellss_increase_ - extern f_status_t f_cellss_increase(const f_number_unsigned_t step, f_cellss_t * const cellss); + extern f_status_t f_cellss_increase(const f_number_unsigned_t step, f_cellss_t * const structure); #endif // _di_f_cellss_increase_ /** @@ -334,7 +361,7 @@ extern "C" { * * @param amount * A positive number representing how much to increase the size by. - * @param cellss + * @param structure * The string cellss array to resize. * * @return @@ -344,10 +371,12 @@ extern "C" { * F_array_too_large (with error bit) if the new array length is too large. * 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(). + * + * @see f_memory_array_resize() */ #ifndef _di_f_cellss_increase_by_ - extern f_status_t f_cellss_increase_by(const f_number_unsigned_t amount, f_cellss_t * const cellss); + extern f_status_t f_cellss_increase_by(const f_number_unsigned_t amount, f_cellss_t * const structure); #endif // _di_f_cellss_increase_by_ /** @@ -355,7 +384,7 @@ extern "C" { * * @param length * The new size to use. - * @param cellss + * @param structure * The string cellss array to adjust. * * @return @@ -363,11 +392,12 @@ extern "C" { * * 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() */ #ifndef _di_f_cellss_resize_ - extern f_status_t f_cellss_resize(const f_number_unsigned_t length, f_cellss_t * const cellss); + extern f_status_t f_cellss_resize(const f_number_unsigned_t length, f_cellss_t * const structure); #endif // _di_f_cellss_resize_ #ifdef __cplusplus diff --git a/level_0/f_type_array/c/type_array/file.c b/level_0/f_type_array/c/type_array/file.c index e03b186..b4f928f 100644 --- a/level_0/f_type_array/c/type_array/file.c +++ b/level_0/f_type_array/c/type_array/file.c @@ -8,12 +8,12 @@ extern "C" { #endif #ifndef _di_f_files_adjust_ - f_status_t f_files_adjust(const f_number_unsigned_t length, f_files_t * const files) { + f_status_t f_files_adjust(const f_number_unsigned_t length, f_files_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!files) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_files_adjust(length, files); + return f_memory_array_adjust(length, sizeof(f_file_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_files_adjust_ @@ -40,88 +40,52 @@ extern "C" { #endif // _di_f_files_append_all_ #ifndef _di_f_files_decimate_by_ - f_status_t f_files_decimate_by(const f_number_unsigned_t amount, f_files_t * const files) { + f_status_t f_files_decimate_by(const f_number_unsigned_t amount, f_files_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!files) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; - - if (files->size - amount > 0) { - return private_f_files_adjust(files->size - amount, files); - } - - return private_f_files_adjust(0, files); + return f_memory_array_decimate_by(amount, sizeof(f_file_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_files_decimate_by_ #ifndef _di_f_files_decrease_by_ - f_status_t f_files_decrease_by(const f_number_unsigned_t amount, f_files_t * const files) { + f_status_t f_files_decrease_by(const f_number_unsigned_t amount, f_files_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!files) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; - - if (files->size - amount > 0) { - return private_f_files_resize(files->size - amount, files); - } - - return private_f_files_resize(0, files); + return f_memory_array_decrease_by(amount, sizeof(f_file_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_files_decrease_by_ #ifndef _di_f_files_increase_ - f_status_t f_files_increase(const f_number_unsigned_t step, f_files_t * const files) { + f_status_t f_files_increase(const f_number_unsigned_t step, f_files_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!files) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (step && files->used + 1 > files->size) { - f_number_unsigned_t size = files->used + step; - - if (size > F_number_t_size_unsigned_d) { - if (files->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_files_resize(size, files); - } - - return F_data_not; + return f_memory_array_increase(step, sizeof(f_file_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_files_increase_ #ifndef _di_f_files_increase_by_ - f_status_t f_files_increase_by(const f_number_unsigned_t amount, f_files_t * const files) { + f_status_t f_files_increase_by(const f_number_unsigned_t amount, f_files_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!files) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; - - if (files->used + amount > files->size) { - if (files->used + amount > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } - - return private_f_files_resize(files->used + amount, files); - } - - return F_data_not; + return f_memory_array_increase_by(amount, sizeof(f_file_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_files_increase_by_ #ifndef _di_f_files_resize_ - f_status_t f_files_resize(const f_number_unsigned_t length, f_files_t * const files) { + f_status_t f_files_resize(const f_number_unsigned_t length, f_files_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!files) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_files_resize(length, files); + return f_memory_array_resize(length, sizeof(f_file_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_files_resize_ @@ -143,12 +107,8 @@ extern "C" { if (!source.used) return F_data_not; - f_status_t status = F_none; - - if (destination->used + 1 > destination->size) { - status = private_f_filess_resize(destination->used + F_memory_default_allocation_small_d, destination); - if (F_status_is_error(status)) return status; - } + f_status_t status = f_memory_array_increase(F_memory_default_allocation_small_d, sizeof(f_files_t), (void **) &destination->array, &destination->used, &destination->size); + if (F_status_is_error(status)) return status; status = private_f_files_append_all(source, &destination->array[destination->used]); if (F_status_is_error(status)) return status; @@ -169,8 +129,8 @@ extern "C" { f_status_t status = F_none; - if (destination->used + source.used > destination->size) { - status = private_f_filess_resize(destination->used + source.used, destination); + { + status = f_memory_array_increase_by(source.used, sizeof(f_files_t), (void **) &destination->array, &destination->used, &destination->size); if (F_status_is_error(status)) return status; } @@ -196,11 +156,7 @@ extern "C" { if (!amount) return F_data_not; - if (filess->size - amount > 0) { - return private_f_filess_adjust(filess->size - amount, filess); - } - - return private_f_filess_adjust(0, filess); + return private_f_filess_adjust((filess->size - amount > 0) ? filess->size - amount : 0, filess); } #endif // _di_f_filess_decimate_by_ @@ -212,11 +168,7 @@ extern "C" { if (!amount) return F_data_not; - if (filess->size - amount > 0) { - return private_f_filess_resize(filess->size - amount, filess); - } - - return private_f_filess_resize(0, filess); + return private_f_filess_resize((filess->size - amount > 0) ? filess->size - amount : 0, filess); } #endif // _di_f_filess_decrease_by_ @@ -227,17 +179,15 @@ extern "C" { #endif // _di_level_0_parameter_checking_ if (step && filess->used + 1 > filess->size) { - f_number_unsigned_t size = filess->used + step; + f_number_unsigned_t length = filess->used + step; - if (size > F_number_t_size_unsigned_d) { - if (filess->used + 1 > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + if (length > F_number_t_size_unsigned_d) { + if (filess->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - size = F_number_t_size_unsigned_d; + length = F_number_t_size_unsigned_d; } - return private_f_filess_resize(size, filess); + return private_f_filess_resize(length, filess); } return F_data_not; @@ -253,9 +203,7 @@ extern "C" { if (!amount) return F_data_not; if (filess->used + amount > filess->size) { - if (filess->used + amount > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + if (filess->used + amount > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); return private_f_filess_resize(filess->used + amount, filess); } diff --git a/level_0/f_type_array/c/type_array/file.h b/level_0/f_type_array/c/type_array/file.h index 109b410..e3060fc 100644 --- a/level_0/f_type_array/c/type_array/file.h +++ b/level_0/f_type_array/c/type_array/file.h @@ -21,7 +21,7 @@ extern "C" { * * @param length * The new size to use. - * @param files + * @param structure * The files array to resize. * * @return @@ -29,10 +29,12 @@ extern "C" { * * 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_array_adjust(). + * + * @see f_memory_array_adjust() */ #ifndef _di_f_files_adjust_ - extern f_status_t f_files_adjust(const f_number_unsigned_t length, f_files_t * const files); + extern f_status_t f_files_adjust(const f_number_unsigned_t length, f_files_t * const structure); #endif // _di_f_files_adjust_ /** @@ -49,7 +51,9 @@ extern "C" { * * 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(). + * + * @see f_memory_array_increase() */ #ifndef _di_f_files_append_ extern f_status_t f_files_append(const f_file_t source, f_files_t * const destination); @@ -69,7 +73,9 @@ extern "C" { * * 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() */ #ifndef _di_f_files_append_all_ extern f_status_t f_files_append_all(const f_files_t source, f_files_t * const destination); @@ -93,10 +99,12 @@ extern "C" { * * 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_array_adjust(). + * + * @see f_memory_array_adjust() */ #ifndef _di_f_files_decimate_by_ - extern f_status_t f_files_decimate_by(const f_number_unsigned_t amount, f_files_t * const files); + extern f_status_t f_files_decimate_by(const f_number_unsigned_t amount, f_files_t * const structure); #endif // _di_f_files_decimate_by_ /** @@ -117,7 +125,9 @@ extern "C" { * * 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(). + * + * @see f_memory_array_resize() */ #ifndef _di_f_files_decrease_by_ extern f_status_t f_files_decrease_by(const f_number_unsigned_t amount, f_files_t * const files); @@ -142,7 +152,9 @@ extern "C" { * F_array_too_large (with error bit) if the new array length is too large. * 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(). + * + * @see f_memory_array_increase() */ #ifndef _di_f_files_increase_ extern f_status_t f_files_increase(const f_number_unsigned_t step, f_files_t * const files); @@ -167,7 +179,9 @@ extern "C" { * F_array_too_large (with error bit) if the new array length is too large. * 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() */ #ifndef _di_f_files_increase_by_ extern f_status_t f_files_increase_by(const f_number_unsigned_t amount, f_files_t * const files); @@ -186,7 +200,9 @@ extern "C" { * * 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(). + * + * @see f_memory_array_resize() */ #ifndef _di_f_files_resize_ extern f_status_t f_files_resize(const f_number_unsigned_t length, f_files_t * const files); @@ -205,8 +221,9 @@ extern "C" { * * 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() */ #ifndef _di_f_filess_adjust_ extern f_status_t f_filess_adjust(const f_number_unsigned_t length, f_filess_t * const filess); @@ -226,7 +243,11 @@ extern "C" { * * 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(). + * Errors (with error bit) from: f_memory_array_increase_by(). + * + * @see f_memory_array_increase() + * @see f_memory_array_increase_by() */ #ifndef _di_f_filess_append_ extern f_status_t f_filess_append(const f_files_t source, f_filess_t * const destination); @@ -246,7 +267,9 @@ extern "C" { * * 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() */ #ifndef _di_f_filess_append_all_ extern f_status_t f_filess_append_all(const f_filess_t source, f_filess_t * const destination); @@ -270,8 +293,9 @@ extern "C" { * * 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() */ #ifndef _di_f_filess_decimate_by_ extern f_status_t f_filess_decimate_by(const f_number_unsigned_t amount, f_filess_t * const filess); @@ -295,8 +319,9 @@ extern "C" { * * 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() */ #ifndef _di_f_filess_decrease_by_ extern f_status_t f_filess_decrease_by(const f_number_unsigned_t amount, f_filess_t * const filess); @@ -321,7 +346,9 @@ extern "C" { * F_array_too_large (with error bit) if the new array length is too large. * 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(). + * + * @see f_memory_array_resize() */ #ifndef _di_f_filess_increase_ extern f_status_t f_filess_increase(const f_number_unsigned_t step, f_filess_t * const filess); @@ -346,7 +373,9 @@ extern "C" { * F_array_too_large (with error bit) if the new array length is too large. * 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(). + * + * @see f_memory_array_resize() */ #ifndef _di_f_filess_increase_by_ extern f_status_t f_filess_increase_by(const f_number_unsigned_t amount, f_filess_t * const filess); @@ -365,8 +394,9 @@ extern "C" { * * 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() */ #ifndef _di_f_filess_resize_ extern f_status_t f_filess_resize(const f_number_unsigned_t length, f_filess_t * const filess); diff --git a/level_0/f_type_array/c/type_array/fll_id.c b/level_0/f_type_array/c/type_array/fll_id.c index f16ed9e..b53d219 100644 --- a/level_0/f_type_array/c/type_array/fll_id.c +++ b/level_0/f_type_array/c/type_array/fll_id.c @@ -7,12 +7,12 @@ extern "C" { #endif #ifndef _di_f_fll_ids_adjust_ - f_status_t f_fll_ids_adjust(const f_number_unsigned_t length, f_fll_ids_t * const ids) { + f_status_t f_fll_ids_adjust(const f_number_unsigned_t length, f_fll_ids_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!ids) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_fll_ids_adjust(length, ids); + return f_memory_array_adjust(length, sizeof(f_fll_id_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_fll_ids_adjust_ @@ -39,98 +39,62 @@ extern "C" { #endif // _di_f_fll_ids_append_all_ #ifndef _di_f_fll_ids_decimate_by_ - f_status_t f_fll_ids_decimate_by(const f_number_unsigned_t amount, f_fll_ids_t * const ids) { + f_status_t f_fll_ids_decimate_by(const f_number_unsigned_t amount, f_fll_ids_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!ids) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; - - if (ids->size - amount > 0) { - return private_f_fll_ids_adjust(ids->size - amount, ids); - } - - return private_f_fll_ids_adjust(0, ids); + return f_memory_array_decimate_by(amount, sizeof(f_fll_id_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_fll_ids_decimate_by_ #ifndef _di_f_fll_ids_decrease_by_ - f_status_t f_fll_ids_decrease_by(const f_number_unsigned_t amount, f_fll_ids_t * const ids) { + f_status_t f_fll_ids_decrease_by(const f_number_unsigned_t amount, f_fll_ids_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!ids) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; - - if (ids->size - amount > 0) { - return private_f_fll_ids_resize(ids->size - amount, ids); - } - - return private_f_fll_ids_resize(0, ids); + return f_memory_array_decrease_by(amount, sizeof(f_fll_id_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_fll_ids_decrease_by_ #ifndef _di_f_fll_ids_increase_ - f_status_t f_fll_ids_increase(const f_number_unsigned_t step, f_fll_ids_t * const ids) { + f_status_t f_fll_ids_increase(const f_number_unsigned_t step, f_fll_ids_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!ids) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (step && ids->used + 1 > ids->size) { - f_number_unsigned_t size = ids->used + step; - - if (size > F_number_t_size_unsigned_d) { - if (ids->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_fll_ids_resize(size, ids); - } - - return F_data_not; + return f_memory_array_increase(step, sizeof(f_fll_id_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_fll_ids_increase_ #ifndef _di_f_fll_ids_increase_by_ - f_status_t f_fll_ids_increase_by(const f_number_unsigned_t amount, f_fll_ids_t * const ids) { + f_status_t f_fll_ids_increase_by(const f_number_unsigned_t amount, f_fll_ids_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!ids) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; - - 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); - } - - return private_f_fll_ids_resize(ids->used + amount, ids); - } - - return F_data_not; + return f_memory_array_increase_by(amount, sizeof(f_fll_id_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_fll_ids_increase_by_ #ifndef _di_f_fll_ids_resize_ - f_status_t f_fll_ids_resize(const f_number_unsigned_t length, f_fll_ids_t * const ids) { + f_status_t f_fll_ids_resize(const f_number_unsigned_t length, f_fll_ids_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!ids) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_fll_ids_resize(length, ids); + return f_memory_array_resize(length, sizeof(f_fll_id_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_fll_ids_resize_ #ifndef _di_f_fll_idss_adjust_ - f_status_t f_fll_idss_adjust(const f_number_unsigned_t length, f_fll_idss_t * const idss) { + f_status_t f_fll_idss_adjust(const f_number_unsigned_t length, f_fll_idss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!idss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_fll_idss_adjust(length, idss); + return private_f_fll_idss_adjust(length, structure); } #endif // _di_f_fll_idss_adjust_ @@ -142,12 +106,8 @@ extern "C" { if (!source.used) return F_data_not; - f_status_t status = F_none; - - if (destination->used + 1 > destination->size) { - status = private_f_fll_idss_resize(destination->used + F_memory_default_allocation_small_d, destination); - if (F_status_is_error(status)) return status; - } + f_status_t status = f_memory_array_increase(F_memory_default_allocation_small_d, sizeof(f_fll_ids_t), (void **) &destination->array, &destination->used, &destination->size); + if (F_status_is_error(status)) return status; status = private_f_fll_ids_append_all(source, &destination->array[destination->used]); if (F_status_is_error(status)) return status; @@ -166,12 +126,8 @@ extern "C" { if (!source.used) return F_data_not; - f_status_t status = F_none; - - if (destination->used + source.used > destination->size) { - status = private_f_fll_idss_resize(destination->used + source.used, destination); - if (F_status_is_error(status)) return status; - } + f_status_t status = f_memory_array_increase_by(source.used, sizeof(f_fll_ids_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->used) { @@ -188,55 +144,47 @@ extern "C" { #endif // _di_f_fll_idss_append_all_ #ifndef _di_f_fll_idss_decimate_by_ - f_status_t f_fll_idss_decimate_by(const f_number_unsigned_t amount, f_fll_idss_t * const idss) { + f_status_t f_fll_idss_decimate_by(const f_number_unsigned_t amount, f_fll_idss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!idss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - if (idss->size - amount > 0) { - return private_f_fll_idss_adjust(idss->size - amount, idss); - } - - return private_f_fll_idss_adjust(0, idss); + return private_f_fll_idss_adjust((structure->size - amount > 0) ? structure->size - amount : 0, structure); } #endif // _di_f_fll_idss_decimate_by_ #ifndef _di_f_fll_idss_decrease_by_ - f_status_t f_fll_idss_decrease_by(const f_number_unsigned_t amount, f_fll_idss_t * const idss) { + f_status_t f_fll_idss_decrease_by(const f_number_unsigned_t amount, f_fll_idss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!idss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - if (idss->size - amount > 0) { - return private_f_fll_idss_resize(idss->size - amount, idss); - } - - return private_f_fll_idss_resize(0, idss); + return private_f_fll_idss_resize((structure->size - amount > 0) ? structure->size - amount : 0, structure); } #endif // _di_f_fll_idss_decrease_by_ #ifndef _di_f_fll_idss_increase_ - f_status_t f_fll_idss_increase(const f_number_unsigned_t step, f_fll_idss_t * const idss) { + f_status_t f_fll_idss_increase(const f_number_unsigned_t step, f_fll_idss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!idss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (step && idss->used + 1 > idss->size) { - f_number_unsigned_t size = idss->used + step; + if (step && structure->used + 1 > structure->size) { + if (structure->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + + f_number_unsigned_t length = structure->used + step; - if (size > F_number_t_size_unsigned_d) { - if (idss->used + 1 > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + if (length > F_number_t_size_unsigned_d) { + if (structure->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - size = F_number_t_size_unsigned_d; + length = F_number_t_size_unsigned_d; } - return private_f_fll_idss_resize(size, idss); + return private_f_fll_idss_resize(length, structure); } return F_data_not; @@ -244,19 +192,21 @@ extern "C" { #endif // _di_f_fll_idss_increase_ #ifndef _di_f_fll_idss_increase_by_ - f_status_t f_fll_idss_increase_by(const f_number_unsigned_t amount, f_fll_idss_t * const idss) { + f_status_t f_fll_idss_increase_by(const f_number_unsigned_t amount, f_fll_idss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!idss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; + if (amount) { + if (structure->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - if (idss->used + amount > idss->size) { - if (idss->used + amount > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + const f_number_unsigned_t length = structure->used + amount; - return private_f_fll_idss_resize(idss->used + amount, idss); + if (length > structure->size) { + if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + + return private_f_fll_idss_resize(structure->used + amount, structure); + } } return F_data_not; @@ -264,12 +214,12 @@ extern "C" { #endif // _di_f_fll_idss_increase_by_ #ifndef _di_f_fll_idss_resize_ - f_status_t f_fll_idss_resize(const f_number_unsigned_t length, f_fll_idss_t * const idss) { + f_status_t f_fll_idss_resize(const f_number_unsigned_t length, f_fll_idss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!idss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_fll_idss_resize(length, idss); + return private_f_fll_idss_resize(length, structure); } #endif // _di_f_fll_idss_resize_ diff --git a/level_0/f_type_array/c/type_array/fll_id.h b/level_0/f_type_array/c/type_array/fll_id.h index 98a9b56..43c07e6 100644 --- a/level_0/f_type_array/c/type_array/fll_id.h +++ b/level_0/f_type_array/c/type_array/fll_id.h @@ -17,22 +17,24 @@ extern "C" { #endif /** - * Resize the string ids array. + * Resize the string fll_ids array. * * @param length * The new size to use. - * @param ids - * The string ids array to resize. + * @param structure + * The string fll_ids array to resize. * * @return * F_none on success. * * 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_array_adjust(). + * + * @see f_memory_array_adjust() */ #ifndef _di_f_fll_ids_adjust_ - extern f_status_t f_fll_ids_adjust(const f_number_unsigned_t length, f_fll_ids_t * const ids); + extern f_status_t f_fll_ids_adjust(const f_number_unsigned_t length, f_fll_ids_t * const structure); #endif // _di_f_fll_ids_adjust_ /** @@ -49,7 +51,9 @@ extern "C" { * * 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(). + * + * @see f_memory_array_increase() */ #ifndef _di_f_fll_ids_append_ extern f_status_t f_fll_ids_append(const f_fll_id_t source, f_fll_ids_t * const destination); @@ -69,14 +73,16 @@ extern "C" { * * 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() */ #ifndef _di_f_fll_ids_append_all_ extern f_status_t f_fll_ids_append_all(const f_fll_ids_t source, f_fll_ids_t * const destination); #endif // _di_f_fll_ids_append_all_ /** - * Resize the string ids array to a smaller size. + * Resize the string fll_ids array to a smaller size. * * This will resize making the array smaller based on (size - given length). * If the given length is too small, then the resize will fail. @@ -84,8 +90,8 @@ extern "C" { * * @param amount * A positive number representing how much to decimate the size by. - * @param ids - * The string ids array to resize. + * @param structure + * The string fll_ids array to resize. * * @return * F_none on success. @@ -93,14 +99,16 @@ extern "C" { * * 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_array_decimate_by(). + * + * @see f_memory_array_decimate_by() */ #ifndef _di_f_fll_ids_decimate_by_ - extern f_status_t f_fll_ids_decimate_by(const f_number_unsigned_t amount, f_fll_ids_t * const ids); + extern f_status_t f_fll_ids_decimate_by(const f_number_unsigned_t amount, f_fll_ids_t * const structure); #endif // _di_f_fll_ids_decimate_by_ /** - * Resize the string ids array to a smaller size. + * Resize the string fll_ids array to a smaller size. * * This will resize making the array smaller based on (size - given length). * If the given length is too small, then the resize will fail. @@ -108,8 +116,8 @@ extern "C" { * * @param amount * A positive number representing how much to decrease the size by. - * @param ids - * The string ids array to resize. + * @param structure + * The string fll_ids array to resize. * * @return * F_none on success. @@ -117,14 +125,16 @@ extern "C" { * * 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_decrease_by(). + * + * @see f_memory_array_decrease_by() */ #ifndef _di_f_fll_ids_decrease_by_ - extern f_status_t f_fll_ids_decrease_by(const f_number_unsigned_t amount, f_fll_ids_t * const ids); + extern f_status_t f_fll_ids_decrease_by(const f_number_unsigned_t amount, f_fll_ids_t * const structure); #endif // _di_f_fll_ids_decrease_by_ /** - * Increase the size of the string ids array, but only if necesary. + * Increase the size of the string fll_ids array, but only if necesary. * * 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. @@ -132,8 +142,8 @@ extern "C" { * @param step * The allocation step to use. * Must be greater than 0. - * @param ids - * The string ids array to resize. + * @param structure + * The string fll_ids array to resize. * * @return * F_none on success. @@ -142,14 +152,16 @@ extern "C" { * F_array_too_large (with error bit) if the new array length is too large. * 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(). + * + * @see f_memory_array_increase() */ #ifndef _di_f_fll_ids_increase_ - extern f_status_t f_fll_ids_increase(const f_number_unsigned_t step, f_fll_ids_t * const ids); + extern f_status_t f_fll_ids_increase(const f_number_unsigned_t step, f_fll_ids_t * const structure); #endif // _di_f_fll_ids_increase_ /** - * Resize the string ids array to a larger size. + * Resize the string fll_ids array 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). @@ -157,8 +169,8 @@ extern "C" { * * @param amount * A positive number representing how much to increase the size by. - * @param ids - * The string ids array to resize. + * @param structure + * The string fll_ids array to resize. * * @return * F_none on success. @@ -167,49 +179,54 @@ extern "C" { * F_array_too_large (with error bit) if the new array length is too large. * 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() */ #ifndef _di_f_fll_ids_increase_by_ - extern f_status_t f_fll_ids_increase_by(const f_number_unsigned_t amount, f_fll_ids_t * const ids); + extern f_status_t f_fll_ids_increase_by(const f_number_unsigned_t amount, f_fll_ids_t * const structure); #endif // _di_f_fll_ids_increase_by_ /** - * Resize the string ids array. + * Resize the string fll_ids array. * * @param length * The new size to use. - * @param ids - * The string ids array to adjust. + * @param structure + * The string fll_ids array to adjust. * * @return * F_none on success. * * 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(). + * + * @see f_memory_array_resize() */ #ifndef _di_f_fll_ids_resize_ - extern f_status_t f_fll_ids_resize(const f_number_unsigned_t length, f_fll_ids_t * const ids); + extern f_status_t f_fll_ids_resize(const f_number_unsigned_t length, f_fll_ids_t * const structure); #endif // _di_f_fll_ids_resize_ /** - * Resize the string idss array. + * Resize the string fll_idss array. * * @param length * The new size to use. - * @param idss - * The string idss array to resize. + * @param structure + * The string fll_idss array to resize. * * @return * F_none on success. * * 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() */ #ifndef _di_f_fll_idss_adjust_ - extern f_status_t f_fll_idss_adjust(const f_number_unsigned_t length, f_fll_idss_t * const idss); + extern f_status_t f_fll_idss_adjust(const f_number_unsigned_t length, f_fll_idss_t * const structure); #endif // _di_f_fll_idss_adjust_ /** @@ -226,7 +243,11 @@ extern "C" { * * 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(). + * Errors (with error bit) from: f_memory_array_increase_by(). + * + * @see f_memory_array_increase() + * @see f_memory_array_increase_by() */ #ifndef _di_f_fll_idss_append_ extern f_status_t f_fll_idss_append(const f_fll_ids_t source, f_fll_idss_t * const destination); @@ -246,14 +267,16 @@ extern "C" { * * 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() */ #ifndef _di_f_fll_idss_append_all_ extern f_status_t f_fll_idss_append_all(const f_fll_idss_t source, f_fll_idss_t * const destination); #endif // _di_f_fll_idss_append_all_ /** - * Resize the string idss array to a smaller size. + * Resize the string fll_idss array to a smaller size. * * This will resize making the array smaller based on (size - given length). * If the given length is too small, then the resize will fail. @@ -261,23 +284,24 @@ extern "C" { * * @param amount * A positive number representing how much to decimate the size by. - * @param idss - * The string idss array to resize. + * @param structure + * The string fll_idss array to resize. * * @return * F_none on success. * * 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() */ #ifndef _di_f_fll_idss_decimate_by_ - extern f_status_t f_fll_idss_decimate_by(const f_number_unsigned_t amount, f_fll_idss_t * const idss); + extern f_status_t f_fll_idss_decimate_by(const f_number_unsigned_t amount, f_fll_idss_t * const structure); #endif // _di_f_fll_idss_decimate_by_ /** - * Resize the string idss array to a smaller size. + * Resize the string fll_idss array to a smaller size. * * This will resize making the array smaller based on (size - given length). * If the given length is too small, then the resize will fail. @@ -285,23 +309,24 @@ extern "C" { * * @param amount * A positive number representing how much to decrease the size by. - * @param idss - * The string idss array to resize. + * @param structure + * The string fll_idss array to resize. * * @return * F_none on success. * * 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() */ #ifndef _di_f_fll_idss_decrease_by_ - extern f_status_t f_fll_idss_decrease_by(const f_number_unsigned_t amount, f_fll_idss_t * const idss); + extern f_status_t f_fll_idss_decrease_by(const f_number_unsigned_t amount, f_fll_idss_t * const structure); #endif // _di_f_fll_idss_decrease_by_ /** - * Increase the size of the string idss array, but only if necessary. + * Increase the size of the string fll_idss array, 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. @@ -309,8 +334,8 @@ extern "C" { * @param step * The allocation step to use. * Must be greater than 0. - * @param idss - * The string idss array to resize. + * @param structure + * The string fll_idss array to resize. * * @return * F_none on success. @@ -319,14 +344,16 @@ extern "C" { * F_array_too_large (with error bit) if the new array length is too large. * 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(). + * + * @see f_memory_array_resize() */ #ifndef _di_f_fll_idss_increase_ - extern f_status_t f_fll_idss_increase(const f_number_unsigned_t step, f_fll_idss_t * const idss); + extern f_status_t f_fll_idss_increase(const f_number_unsigned_t step, f_fll_idss_t * const structure); #endif // _di_f_fll_idss_increase_ /** - * Resize the string idss array to a larger size. + * Resize the string fll_idss array 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). @@ -334,8 +361,8 @@ extern "C" { * * @param amount * A positive number representing how much to increase the size by. - * @param idss - * The string idss array to resize. + * @param structure + * The string fll_idss array to resize. * * @return * F_none on success. @@ -344,30 +371,33 @@ extern "C" { * F_array_too_large (with error bit) if the new array length is too large. * 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(). + * + * @see f_memory_array_resize() */ #ifndef _di_f_fll_idss_increase_by_ - extern f_status_t f_fll_idss_increase_by(const f_number_unsigned_t amount, f_fll_idss_t * const idss); + extern f_status_t f_fll_idss_increase_by(const f_number_unsigned_t amount, f_fll_idss_t * const structure); #endif // _di_f_fll_idss_increase_by_ /** - * Resize the string idss array. + * Resize the string fll_idss array. * * @param length * The new size to use. - * @param idss - * The string idss array to adjust. + * @param structure + * The string fll_idss array to adjust. * * @return * F_none on success. * * 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() */ #ifndef _di_f_fll_idss_resize_ - extern f_status_t f_fll_idss_resize(const f_number_unsigned_t length, f_fll_idss_t * const idss); + extern f_status_t f_fll_idss_resize(const f_number_unsigned_t length, f_fll_idss_t * const structure); #endif // _di_f_fll_idss_resize_ #ifdef __cplusplus diff --git a/level_0/f_type_array/c/type_array/int128.c b/level_0/f_type_array/c/type_array/int128.c index 7444257..6a294bd 100644 --- a/level_0/f_type_array/c/type_array/int128.c +++ b/level_0/f_type_array/c/type_array/int128.c @@ -7,12 +7,12 @@ extern "C" { #endif #ifndef _di_f_int128s_adjust_ - f_status_t f_int128s_adjust(const f_number_unsigned_t length, f_int128s_t * const int128s) { + f_status_t f_int128s_adjust(const f_number_unsigned_t length, f_int128s_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!int128s) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_int128s_adjust(length, int128s); + return f_memory_array_adjust(length, sizeof(int128_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_int128s_adjust_ @@ -39,98 +39,62 @@ extern "C" { #endif // _di_f_int128s_append_all_ #ifndef _di_f_int128s_decimate_by_ - f_status_t f_int128s_decimate_by(const f_number_unsigned_t amount, f_int128s_t * const int128s) { + f_status_t f_int128s_decimate_by(const f_number_unsigned_t amount, f_int128s_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!int128s) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; - - if (int128s->size - amount > 0) { - return private_f_int128s_adjust(int128s->size - amount, int128s); - } - - return private_f_int128s_adjust(0, int128s); + return f_memory_array_decimate_by(amount, sizeof(int128_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_int128s_decimate_by_ #ifndef _di_f_int128s_decrease_by_ - f_status_t f_int128s_decrease_by(const f_number_unsigned_t amount, f_int128s_t * const int128s) { + f_status_t f_int128s_decrease_by(const f_number_unsigned_t amount, f_int128s_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!int128s) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; - - if (int128s->size - amount > 0) { - return private_f_int128s_resize(int128s->size - amount, int128s); - } - - return private_f_int128s_resize(0, int128s); + return f_memory_array_decrease_by(amount, sizeof(int128_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_int128s_decrease_by_ #ifndef _di_f_int128s_increase_ - f_status_t f_int128s_increase(const f_number_unsigned_t step, f_int128s_t * const int128s) { + f_status_t f_int128s_increase(const f_number_unsigned_t step, f_int128s_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!int128s) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (step && int128s->used + 1 > int128s->size) { - f_number_unsigned_t size = int128s->used + step; - - if (size > F_number_t_size_unsigned_d) { - if (int128s->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_int128s_resize(size, int128s); - } - - return F_data_not; + return f_memory_array_increase(step, sizeof(int128_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_int128s_increase_ #ifndef _di_f_int128s_increase_by_ - f_status_t f_int128s_increase_by(const f_number_unsigned_t amount, f_int128s_t * const int128s) { + f_status_t f_int128s_increase_by(const f_number_unsigned_t amount, f_int128s_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!int128s) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; - - if (int128s->used + amount > int128s->size) { - if (int128s->used + amount > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } - - return private_f_int128s_resize(int128s->used + amount, int128s); - } - - return F_data_not; + return f_memory_array_increase_by(amount, sizeof(int128_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_int128s_increase_by_ #ifndef _di_f_int128s_resize_ - f_status_t f_int128s_resize(const f_number_unsigned_t length, f_int128s_t * const int128s) { + f_status_t f_int128s_resize(const f_number_unsigned_t length, f_int128s_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!int128s) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_int128s_resize(length, int128s); + return f_memory_array_resize(length, sizeof(int128_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_int128s_resize_ #ifndef _di_f_int128ss_adjust_ - f_status_t f_int128ss_adjust(const f_number_unsigned_t length, f_int128ss_t * const int128ss) { + f_status_t f_int128ss_adjust(const f_number_unsigned_t length, f_int128ss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!int128ss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_int128ss_adjust(length, int128ss); + return private_f_int128ss_adjust(length, structure); } #endif // _di_f_int128ss_adjust_ @@ -142,12 +106,8 @@ extern "C" { if (!source.used) return F_data_not; - f_status_t status = F_none; - - if (destination->used + 1 > destination->size) { - status = private_f_int128ss_resize(destination->used + F_memory_default_allocation_small_d, destination); - if (F_status_is_error(status)) return status; - } + f_status_t status = f_memory_array_increase(F_memory_default_allocation_small_d, sizeof(f_int128s_t), (void **) &destination->array, &destination->used, &destination->size); + if (F_status_is_error(status)) return status; status = private_f_int128s_append_all(source, &destination->array[destination->used]); if (F_status_is_error(status)) return status; @@ -166,12 +126,8 @@ extern "C" { if (!source.used) return F_data_not; - f_status_t status = F_none; - - if (destination->used + source.used > destination->size) { - status = private_f_int128ss_resize(destination->used + source.used, destination); - if (F_status_is_error(status)) return status; - } + f_status_t status = f_memory_array_increase_by(source.used, sizeof(f_int128s_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->used) { @@ -188,55 +144,47 @@ extern "C" { #endif // _di_f_int128ss_append_all_ #ifndef _di_f_int128ss_decimate_by_ - f_status_t f_int128ss_decimate_by(const f_number_unsigned_t amount, f_int128ss_t * const int128ss) { + f_status_t f_int128ss_decimate_by(const f_number_unsigned_t amount, f_int128ss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!int128ss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - if (int128ss->size - amount > 0) { - return private_f_int128ss_adjust(int128ss->size - amount, int128ss); - } - - return private_f_int128ss_adjust(0, int128ss); + return private_f_int128ss_adjust((structure->size - amount > 0) ? structure->size - amount : 0, structure); } #endif // _di_f_int128ss_decimate_by_ #ifndef _di_f_int128ss_decrease_by_ - f_status_t f_int128ss_decrease_by(const f_number_unsigned_t amount, f_int128ss_t * const int128ss) { + f_status_t f_int128ss_decrease_by(const f_number_unsigned_t amount, f_int128ss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!int128ss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - if (int128ss->size - amount > 0) { - return private_f_int128ss_resize(int128ss->size - amount, int128ss); - } - - return private_f_int128ss_resize(0, int128ss); + return private_f_int128ss_resize((structure->size - amount > 0) ? structure->size - amount : 0, structure); } #endif // _di_f_int128ss_decrease_by_ #ifndef _di_f_int128ss_increase_ - f_status_t f_int128ss_increase(const f_number_unsigned_t step, f_int128ss_t * const int128ss) { + f_status_t f_int128ss_increase(const f_number_unsigned_t step, f_int128ss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!int128ss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (step && int128ss->used + 1 > int128ss->size) { - f_number_unsigned_t size = int128ss->used + step; + if (step && structure->used + 1 > structure->size) { + if (structure->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + + f_number_unsigned_t length = structure->used + step; - if (size > F_number_t_size_unsigned_d) { - if (int128ss->used + 1 > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + if (length > F_number_t_size_unsigned_d) { + if (structure->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - size = F_number_t_size_unsigned_d; + length = F_number_t_size_unsigned_d; } - return private_f_int128ss_resize(size, int128ss); + return private_f_int128ss_resize(length, structure); } return F_data_not; @@ -244,19 +192,21 @@ extern "C" { #endif // _di_f_int128ss_increase_ #ifndef _di_f_int128ss_increase_by_ - f_status_t f_int128ss_increase_by(const f_number_unsigned_t amount, f_int128ss_t * const int128ss) { + f_status_t f_int128ss_increase_by(const f_number_unsigned_t amount, f_int128ss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!int128ss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; + if (amount) { + if (structure->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - if (int128ss->used + amount > int128ss->size) { - if (int128ss->used + amount > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + const f_number_unsigned_t length = structure->used + amount; - return private_f_int128ss_resize(int128ss->used + amount, int128ss); + if (length > structure->size) { + if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + + return private_f_int128ss_resize(structure->used + amount, structure); + } } return F_data_not; @@ -264,12 +214,12 @@ extern "C" { #endif // _di_f_int128ss_increase_by_ #ifndef _di_f_int128ss_resize_ - f_status_t f_int128ss_resize(const f_number_unsigned_t length, f_int128ss_t * const int128ss) { + f_status_t f_int128ss_resize(const f_number_unsigned_t length, f_int128ss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!int128ss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_int128ss_resize(length, int128ss); + return private_f_int128ss_resize(length, structure); } #endif // _di_f_int128ss_resize_ diff --git a/level_0/f_type_array/c/type_array/int128.h b/level_0/f_type_array/c/type_array/int128.h index cbdfb35..3399443 100644 --- a/level_0/f_type_array/c/type_array/int128.h +++ b/level_0/f_type_array/c/type_array/int128.h @@ -17,22 +17,24 @@ extern "C" { #endif /** - * Resize the int128s array. + * Resize the string int128s array. * * @param length * The new size to use. - * @param int128s - * The int128s array to resize. + * @param structure + * The string int128s array to resize. * * @return * F_none on success. * * 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_array_adjust(). + * + * @see f_memory_array_adjust() */ #ifndef _di_f_int128s_adjust_ - extern f_status_t f_int128s_adjust(const f_number_unsigned_t length, f_int128s_t * const int128s); + extern f_status_t f_int128s_adjust(const f_number_unsigned_t length, f_int128s_t * const structure); #endif // _di_f_int128s_adjust_ /** @@ -49,7 +51,9 @@ extern "C" { * * 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(). + * + * @see f_memory_array_increase() */ #ifndef _di_f_int128s_append_ extern f_status_t f_int128s_append(const int128_t source, f_int128s_t * const destination); @@ -69,14 +73,16 @@ extern "C" { * * 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() */ #ifndef _di_f_int128s_append_all_ extern f_status_t f_int128s_append_all(const f_int128s_t source, f_int128s_t * const destination); #endif // _di_f_int128s_append_all_ /** - * Resize the int128s array to a smaller size. + * Resize the string int128s array to a smaller size. * * This will resize making the array smaller based on (size - given length). * If the given length is too small, then the resize will fail. @@ -84,8 +90,8 @@ extern "C" { * * @param amount * A positive number representing how much to decimate the size by. - * @param int128s - * The int128s array to resize. + * @param structure + * The string int128s array to resize. * * @return * F_none on success. @@ -93,14 +99,16 @@ extern "C" { * * 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_array_decimate_by(). + * + * @see f_memory_array_decimate_by() */ #ifndef _di_f_int128s_decimate_by_ - extern f_status_t f_int128s_decimate_by(const f_number_unsigned_t amount, f_int128s_t * const int128s); + extern f_status_t f_int128s_decimate_by(const f_number_unsigned_t amount, f_int128s_t * const structure); #endif // _di_f_int128s_decimate_by_ /** - * Resize the int128s array to a smaller size. + * Resize the string int128s array to a smaller size. * * This will resize making the array smaller based on (size - given length). * If the given length is too small, then the resize will fail. @@ -108,8 +116,8 @@ extern "C" { * * @param amount * A positive number representing how much to decrease the size by. - * @param int128s - * The int128s array to resize. + * @param structure + * The string int128s array to resize. * * @return * F_none on success. @@ -117,14 +125,16 @@ extern "C" { * * 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_decrease_by(). + * + * @see f_memory_array_decrease_by() */ #ifndef _di_f_int128s_decrease_by_ - extern f_status_t f_int128s_decrease_by(const f_number_unsigned_t amount, f_int128s_t * const int128s); + extern f_status_t f_int128s_decrease_by(const f_number_unsigned_t amount, f_int128s_t * const structure); #endif // _di_f_int128s_decrease_by_ /** - * Increase the size of the int128s array, but only if necesary. + * Increase the size of the string int128s array, but only if necesary. * * 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. @@ -132,8 +142,8 @@ extern "C" { * @param step * The allocation step to use. * Must be greater than 0. - * @param int128s - * The int128s array to resize. + * @param structure + * The string int128s array to resize. * * @return * F_none on success. @@ -142,14 +152,16 @@ extern "C" { * F_array_too_large (with error bit) if the new array length is too large. * 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(). + * + * @see f_memory_array_increase() */ #ifndef _di_f_int128s_increase_ - extern f_status_t f_int128s_increase(const f_number_unsigned_t step, f_int128s_t * const int128s); + extern f_status_t f_int128s_increase(const f_number_unsigned_t step, f_int128s_t * const structure); #endif // _di_f_int128s_increase_ /** - * Resize the int128s array to a larger size. + * Resize the string int128s array 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). @@ -157,8 +169,8 @@ extern "C" { * * @param amount * A positive number representing how much to increase the size by. - * @param int128s - * The int128s array to resize. + * @param structure + * The string int128s array to resize. * * @return * F_none on success. @@ -167,53 +179,58 @@ extern "C" { * F_array_too_large (with error bit) if the new array length is too large. * 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() */ #ifndef _di_f_int128s_increase_by_ - extern f_status_t f_int128s_increase_by(const f_number_unsigned_t amount, f_int128s_t * const int128s); + extern f_status_t f_int128s_increase_by(const f_number_unsigned_t amount, f_int128s_t * const structure); #endif // _di_f_int128s_increase_by_ /** - * Resize the int128s array. + * Resize the string int128s array. * * @param length * The new size to use. - * @param int128s - * The int128s array to adjust. + * @param structure + * The string int128s array to adjust. * * @return * F_none on success. * * 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(). + * + * @see f_memory_array_resize() */ #ifndef _di_f_int128s_resize_ - extern f_status_t f_int128s_resize(const f_number_unsigned_t length, f_int128s_t * const int128s); + extern f_status_t f_int128s_resize(const f_number_unsigned_t length, f_int128s_t * const structure); #endif // _di_f_int128s_resize_ /** - * Resize the int128ss array. + * Resize the string int128ss array. * * @param length * The new size to use. - * @param int128ss - * The int128ss array to resize. + * @param structure + * The string int128ss array to resize. * * @return * F_none on success. * * 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() */ #ifndef _di_f_int128ss_adjust_ - extern f_status_t f_int128ss_adjust(const f_number_unsigned_t length, f_int128ss_t * const int128ss); + extern f_status_t f_int128ss_adjust(const f_number_unsigned_t length, f_int128ss_t * const structure); #endif // _di_f_int128ss_adjust_ /** - * Append the single source int128 onto the destination. + * Append the single source int128s onto the destination. * * @param source * The source int128s to append. @@ -226,7 +243,11 @@ extern "C" { * * 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(). + * Errors (with error bit) from: f_memory_array_increase_by(). + * + * @see f_memory_array_increase() + * @see f_memory_array_increase_by() */ #ifndef _di_f_int128ss_append_ extern f_status_t f_int128ss_append(const f_int128s_t source, f_int128ss_t * const destination); @@ -246,14 +267,16 @@ extern "C" { * * 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() */ #ifndef _di_f_int128ss_append_all_ extern f_status_t f_int128ss_append_all(const f_int128ss_t source, f_int128ss_t * const destination); #endif // _di_f_int128ss_append_all_ /** - * Resize the int128ss array to a smaller size. + * Resize the string int128ss array to a smaller size. * * This will resize making the array smaller based on (size - given length). * If the given length is too small, then the resize will fail. @@ -261,23 +284,24 @@ extern "C" { * * @param amount * A positive number representing how much to decimate the size by. - * @param int128ss - * The int128ss array to resize. + * @param structure + * The string int128ss array to resize. * * @return * F_none on success. * * 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() */ #ifndef _di_f_int128ss_decimate_by_ - extern f_status_t f_int128ss_decimate_by(const f_number_unsigned_t amount, f_int128ss_t * const int128ss); + extern f_status_t f_int128ss_decimate_by(const f_number_unsigned_t amount, f_int128ss_t * const structure); #endif // _di_f_int128ss_decimate_by_ /** - * Resize the int128ss array to a smaller size. + * Resize the string int128ss array to a smaller size. * * This will resize making the array smaller based on (size - given length). * If the given length is too small, then the resize will fail. @@ -285,23 +309,24 @@ extern "C" { * * @param amount * A positive number representing how much to decrease the size by. - * @param int128ss - * The int128ss array to resize. + * @param structure + * The string int128ss array to resize. * * @return * F_none on success. * * 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() */ #ifndef _di_f_int128ss_decrease_by_ - extern f_status_t f_int128ss_decrease_by(const f_number_unsigned_t amount, f_int128ss_t * const int128ss); + extern f_status_t f_int128ss_decrease_by(const f_number_unsigned_t amount, f_int128ss_t * const structure); #endif // _di_f_int128ss_decrease_by_ /** - * Increase the size of the int128ss array, but only if necessary. + * Increase the size of the string int128ss array, 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. @@ -309,8 +334,8 @@ extern "C" { * @param step * The allocation step to use. * Must be greater than 0. - * @param int128ss - * The int128ss array to resize. + * @param structure + * The string int128ss array to resize. * * @return * F_none on success. @@ -319,14 +344,16 @@ extern "C" { * F_array_too_large (with error bit) if the new array length is too large. * 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(). + * + * @see f_memory_array_resize() */ #ifndef _di_f_int128ss_increase_ - extern f_status_t f_int128ss_increase(const f_number_unsigned_t step, f_int128ss_t * const int128ss); + extern f_status_t f_int128ss_increase(const f_number_unsigned_t step, f_int128ss_t * const structure); #endif // _di_f_int128ss_increase_ /** - * Resize the int128ss array to a larger size. + * Resize the string int128ss array 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). @@ -334,8 +361,8 @@ extern "C" { * * @param amount * A positive number representing how much to increase the size by. - * @param int128ss - * The int128ss array to resize. + * @param structure + * The string int128ss array to resize. * * @return * F_none on success. @@ -344,30 +371,33 @@ extern "C" { * F_array_too_large (with error bit) if the new array length is too large. * 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(). + * + * @see f_memory_array_resize() */ #ifndef _di_f_int128ss_increase_by_ - extern f_status_t f_int128ss_increase_by(const f_number_unsigned_t amount, f_int128ss_t * const int128ss); + extern f_status_t f_int128ss_increase_by(const f_number_unsigned_t amount, f_int128ss_t * const structure); #endif // _di_f_int128ss_increase_by_ /** - * Resize the int128ss array. + * Resize the string int128ss array. * * @param length * The new size to use. - * @param int128ss - * The int128ss array to adjust. + * @param structure + * The string int128ss array to adjust. * * @return * F_none on success. * * 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() */ #ifndef _di_f_int128ss_resize_ - extern f_status_t f_int128ss_resize(const f_number_unsigned_t length, f_int128ss_t * const int128ss); + extern f_status_t f_int128ss_resize(const f_number_unsigned_t length, f_int128ss_t * const structure); #endif // _di_f_int128ss_resize_ #ifdef __cplusplus diff --git a/level_0/f_type_array/c/type_array/int16.c b/level_0/f_type_array/c/type_array/int16.c index 783b27e..0e5c5ae 100644 --- a/level_0/f_type_array/c/type_array/int16.c +++ b/level_0/f_type_array/c/type_array/int16.c @@ -7,12 +7,12 @@ extern "C" { #endif #ifndef _di_f_int16s_adjust_ - f_status_t f_int16s_adjust(const f_number_unsigned_t length, f_int16s_t * const int16s) { + f_status_t f_int16s_adjust(const f_number_unsigned_t length, f_int16s_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!int16s) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_int16s_adjust(length, int16s); + return f_memory_array_adjust(length, sizeof(int16_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_int16s_adjust_ @@ -39,98 +39,62 @@ extern "C" { #endif // _di_f_int16s_append_all_ #ifndef _di_f_int16s_decimate_by_ - f_status_t f_int16s_decimate_by(const f_number_unsigned_t amount, f_int16s_t * const int16s) { + f_status_t f_int16s_decimate_by(const f_number_unsigned_t amount, f_int16s_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!int16s) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; - - if (int16s->size - amount > 0) { - return private_f_int16s_adjust(int16s->size - amount, int16s); - } - - return private_f_int16s_adjust(0, int16s); + return f_memory_array_decimate_by(amount, sizeof(int16_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_int16s_decimate_by_ #ifndef _di_f_int16s_decrease_by_ - f_status_t f_int16s_decrease_by(const f_number_unsigned_t amount, f_int16s_t * const int16s) { + f_status_t f_int16s_decrease_by(const f_number_unsigned_t amount, f_int16s_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!int16s) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; - - if (int16s->size - amount > 0) { - return private_f_int16s_resize(int16s->size - amount, int16s); - } - - return private_f_int16s_resize(0, int16s); + return f_memory_array_decrease_by(amount, sizeof(int16_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_int16s_decrease_by_ #ifndef _di_f_int16s_increase_ - f_status_t f_int16s_increase(const f_number_unsigned_t step, f_int16s_t * const int16s) { + f_status_t f_int16s_increase(const f_number_unsigned_t step, f_int16s_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!int16s) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (step && int16s->used + 1 > int16s->size) { - f_number_unsigned_t size = int16s->used + step; - - if (size > F_number_t_size_unsigned_d) { - if (int16s->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_int16s_resize(size, int16s); - } - - return F_data_not; + return f_memory_array_increase(step, sizeof(int16_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_int16s_increase_ #ifndef _di_f_int16s_increase_by_ - f_status_t f_int16s_increase_by(const f_number_unsigned_t amount, f_int16s_t * const int16s) { + f_status_t f_int16s_increase_by(const f_number_unsigned_t amount, f_int16s_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!int16s) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; - - if (int16s->used + amount > int16s->size) { - if (int16s->used + amount > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } - - return private_f_int16s_resize(int16s->used + amount, int16s); - } - - return F_data_not; + return f_memory_array_increase_by(amount, sizeof(int16_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_int16s_increase_by_ #ifndef _di_f_int16s_resize_ - f_status_t f_int16s_resize(const f_number_unsigned_t length, f_int16s_t * const int16s) { + f_status_t f_int16s_resize(const f_number_unsigned_t length, f_int16s_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!int16s) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_int16s_resize(length, int16s); + return f_memory_array_resize(length, sizeof(int16_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_int16s_resize_ #ifndef _di_f_int16ss_adjust_ - f_status_t f_int16ss_adjust(const f_number_unsigned_t length, f_int16ss_t * const int16ss) { + f_status_t f_int16ss_adjust(const f_number_unsigned_t length, f_int16ss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!int16ss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_int16ss_adjust(length, int16ss); + return private_f_int16ss_adjust(length, structure); } #endif // _di_f_int16ss_adjust_ @@ -142,12 +106,8 @@ extern "C" { if (!source.used) return F_data_not; - f_status_t status = F_none; - - if (destination->used + 1 > destination->size) { - status = private_f_int16ss_resize(destination->used + F_memory_default_allocation_small_d, destination); - if (F_status_is_error(status)) return status; - } + f_status_t status = f_memory_array_increase(F_memory_default_allocation_small_d, sizeof(f_int16s_t), (void **) &destination->array, &destination->used, &destination->size); + if (F_status_is_error(status)) return status; status = private_f_int16s_append_all(source, &destination->array[destination->used]); if (F_status_is_error(status)) return status; @@ -166,12 +126,8 @@ extern "C" { if (!source.used) return F_data_not; - f_status_t status = F_none; - - if (destination->used + source.used > destination->size) { - status = private_f_int16ss_resize(destination->used + source.used, destination); - if (F_status_is_error(status)) return status; - } + f_status_t status = f_memory_array_increase_by(source.used, sizeof(f_int16s_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->used) { @@ -188,55 +144,47 @@ extern "C" { #endif // _di_f_int16ss_append_all_ #ifndef _di_f_int16ss_decimate_by_ - f_status_t f_int16ss_decimate_by(const f_number_unsigned_t amount, f_int16ss_t * const int16ss) { + f_status_t f_int16ss_decimate_by(const f_number_unsigned_t amount, f_int16ss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!int16ss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - if (int16ss->size - amount > 0) { - return private_f_int16ss_adjust(int16ss->size - amount, int16ss); - } - - return private_f_int16ss_adjust(0, int16ss); + return private_f_int16ss_adjust((structure->size - amount > 0) ? structure->size - amount : 0, structure); } #endif // _di_f_int16ss_decimate_by_ #ifndef _di_f_int16ss_decrease_by_ - f_status_t f_int16ss_decrease_by(const f_number_unsigned_t amount, f_int16ss_t * const int16ss) { + f_status_t f_int16ss_decrease_by(const f_number_unsigned_t amount, f_int16ss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!int16ss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - if (int16ss->size - amount > 0) { - return private_f_int16ss_resize(int16ss->size - amount, int16ss); - } - - return private_f_int16ss_resize(0, int16ss); + return private_f_int16ss_resize((structure->size - amount > 0) ? structure->size - amount : 0, structure); } #endif // _di_f_int16ss_decrease_by_ #ifndef _di_f_int16ss_increase_ - f_status_t f_int16ss_increase(const f_number_unsigned_t step, f_int16ss_t * const int16ss) { + f_status_t f_int16ss_increase(const f_number_unsigned_t step, f_int16ss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!int16ss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (step && int16ss->used + 1 > int16ss->size) { - f_number_unsigned_t size = int16ss->used + step; + if (step && structure->used + 1 > structure->size) { + if (structure->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + + f_number_unsigned_t length = structure->used + step; - if (size > F_number_t_size_unsigned_d) { - if (int16ss->used + 1 > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + if (length > F_number_t_size_unsigned_d) { + if (structure->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - size = F_number_t_size_unsigned_d; + length = F_number_t_size_unsigned_d; } - return private_f_int16ss_resize(size, int16ss); + return private_f_int16ss_resize(length, structure); } return F_data_not; @@ -244,19 +192,21 @@ extern "C" { #endif // _di_f_int16ss_increase_ #ifndef _di_f_int16ss_increase_by_ - f_status_t f_int16ss_increase_by(const f_number_unsigned_t amount, f_int16ss_t * const int16ss) { + f_status_t f_int16ss_increase_by(const f_number_unsigned_t amount, f_int16ss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!int16ss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; + if (amount) { + if (structure->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - if (int16ss->used + amount > int16ss->size) { - if (int16ss->used + amount > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + const f_number_unsigned_t length = structure->used + amount; - return private_f_int16ss_resize(int16ss->used + amount, int16ss); + if (length > structure->size) { + if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + + return private_f_int16ss_resize(structure->used + amount, structure); + } } return F_data_not; @@ -264,12 +214,12 @@ extern "C" { #endif // _di_f_int16ss_increase_by_ #ifndef _di_f_int16ss_resize_ - f_status_t f_int16ss_resize(const f_number_unsigned_t length, f_int16ss_t * const int16ss) { + f_status_t f_int16ss_resize(const f_number_unsigned_t length, f_int16ss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!int16ss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_int16ss_resize(length, int16ss); + return private_f_int16ss_resize(length, structure); } #endif // _di_f_int16ss_resize_ diff --git a/level_0/f_type_array/c/type_array/int16.h b/level_0/f_type_array/c/type_array/int16.h index 481fed6..f7a4086 100644 --- a/level_0/f_type_array/c/type_array/int16.h +++ b/level_0/f_type_array/c/type_array/int16.h @@ -17,22 +17,24 @@ extern "C" { #endif /** - * Resize the int16s array. + * Resize the string int16s array. * * @param length * The new size to use. - * @param int16s - * The int16s array to resize. + * @param structure + * The string int16s array to resize. * * @return * F_none on success. * * 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_array_adjust(). + * + * @see f_memory_array_adjust() */ #ifndef _di_f_int16s_adjust_ - extern f_status_t f_int16s_adjust(const f_number_unsigned_t length, f_int16s_t * const int16s); + extern f_status_t f_int16s_adjust(const f_number_unsigned_t length, f_int16s_t * const structure); #endif // _di_f_int16s_adjust_ /** @@ -49,7 +51,9 @@ extern "C" { * * 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(). + * + * @see f_memory_array_increase() */ #ifndef _di_f_int16s_append_ extern f_status_t f_int16s_append(const int16_t source, f_int16s_t * const destination); @@ -69,14 +73,16 @@ extern "C" { * * 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() */ #ifndef _di_f_int16s_append_all_ extern f_status_t f_int16s_append_all(const f_int16s_t source, f_int16s_t * const destination); #endif // _di_f_int16s_append_all_ /** - * Resize the int16s array to a smaller size. + * Resize the string int16s array to a smaller size. * * This will resize making the array smaller based on (size - given length). * If the given length is too small, then the resize will fail. @@ -84,8 +90,8 @@ extern "C" { * * @param amount * A positive number representing how much to decimate the size by. - * @param int16s - * The int16s array to resize. + * @param structure + * The string int16s array to resize. * * @return * F_none on success. @@ -93,14 +99,16 @@ extern "C" { * * 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_array_decimate_by(). + * + * @see f_memory_array_decimate_by() */ #ifndef _di_f_int16s_decimate_by_ - extern f_status_t f_int16s_decimate_by(const f_number_unsigned_t amount, f_int16s_t * const int16s); + extern f_status_t f_int16s_decimate_by(const f_number_unsigned_t amount, f_int16s_t * const structure); #endif // _di_f_int16s_decimate_by_ /** - * Resize the int16s array to a smaller size. + * Resize the string int16s array to a smaller size. * * This will resize making the array smaller based on (size - given length). * If the given length is too small, then the resize will fail. @@ -108,8 +116,8 @@ extern "C" { * * @param amount * A positive number representing how much to decrease the size by. - * @param int16s - * The int16s array to resize. + * @param structure + * The string int16s array to resize. * * @return * F_none on success. @@ -117,14 +125,16 @@ extern "C" { * * 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_decrease_by(). + * + * @see f_memory_array_decrease_by() */ #ifndef _di_f_int16s_decrease_by_ - extern f_status_t f_int16s_decrease_by(const f_number_unsigned_t amount, f_int16s_t * const int16s); + extern f_status_t f_int16s_decrease_by(const f_number_unsigned_t amount, f_int16s_t * const structure); #endif // _di_f_int16s_decrease_by_ /** - * Increase the size of the int16s array, but only if necesary. + * Increase the size of the string int16s array, but only if necesary. * * 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. @@ -132,8 +142,8 @@ extern "C" { * @param step * The allocation step to use. * Must be greater than 0. - * @param int16s - * The int16s array to resize. + * @param structure + * The string int16s array to resize. * * @return * F_none on success. @@ -142,14 +152,16 @@ extern "C" { * F_array_too_large (with error bit) if the new array length is too large. * 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(). + * + * @see f_memory_array_increase() */ #ifndef _di_f_int16s_increase_ - extern f_status_t f_int16s_increase(const f_number_unsigned_t step, f_int16s_t * const int16s); + extern f_status_t f_int16s_increase(const f_number_unsigned_t step, f_int16s_t * const structure); #endif // _di_f_int16s_increase_ /** - * Resize the int16s array to a larger size. + * Resize the string int16s array 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). @@ -157,8 +169,8 @@ extern "C" { * * @param amount * A positive number representing how much to increase the size by. - * @param int16s - * The int16s array to resize. + * @param structure + * The string int16s array to resize. * * @return * F_none on success. @@ -167,49 +179,54 @@ extern "C" { * F_array_too_large (with error bit) if the new array length is too large. * 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() */ #ifndef _di_f_int16s_increase_by_ - extern f_status_t f_int16s_increase_by(const f_number_unsigned_t amount, f_int16s_t * const int16s); + extern f_status_t f_int16s_increase_by(const f_number_unsigned_t amount, f_int16s_t * const structure); #endif // _di_f_int16s_increase_by_ /** - * Resize the int16s array. + * Resize the string int16s array. * * @param length * The new size to use. - * @param int16s - * The int16s array to adjust. + * @param structure + * The string int16s array to adjust. * * @return * F_none on success. * * 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(). + * + * @see f_memory_array_resize() */ #ifndef _di_f_int16s_resize_ - extern f_status_t f_int16s_resize(const f_number_unsigned_t length, f_int16s_t * const int16s); + extern f_status_t f_int16s_resize(const f_number_unsigned_t length, f_int16s_t * const structure); #endif // _di_f_int16s_resize_ /** - * Resize the int16ss array. + * Resize the string int16ss array. * * @param length * The new size to use. - * @param int16ss - * The int16ss array to resize. + * @param structure + * The string int16ss array to resize. * * @return * F_none on success. * * 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() */ #ifndef _di_f_int16ss_adjust_ - extern f_status_t f_int16ss_adjust(const f_number_unsigned_t length, f_int16ss_t * const int16ss); + extern f_status_t f_int16ss_adjust(const f_number_unsigned_t length, f_int16ss_t * const structure); #endif // _di_f_int16ss_adjust_ /** @@ -226,7 +243,11 @@ extern "C" { * * 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(). + * Errors (with error bit) from: f_memory_array_increase_by(). + * + * @see f_memory_array_increase() + * @see f_memory_array_increase_by() */ #ifndef _di_f_int16ss_append_ extern f_status_t f_int16ss_append(const f_int16s_t source, f_int16ss_t * const destination); @@ -246,14 +267,16 @@ extern "C" { * * 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() */ #ifndef _di_f_int16ss_append_all_ extern f_status_t f_int16ss_append_all(const f_int16ss_t source, f_int16ss_t * const destination); #endif // _di_f_int16ss_append_all_ /** - * Resize the int16ss array to a smaller size. + * Resize the string int16ss array to a smaller size. * * This will resize making the array smaller based on (size - given length). * If the given length is too small, then the resize will fail. @@ -261,24 +284,24 @@ extern "C" { * * @param amount * A positive number representing how much to decimate the size by. - * @param int16ss - * The int16ss array to resize. + * @param structure + * The string int16ss array to resize. * * @return * F_none on success. - * F_data_not if amount is 0. * * 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() */ #ifndef _di_f_int16ss_decimate_by_ - extern f_status_t f_int16ss_decimate_by(const f_number_unsigned_t amount, f_int16ss_t * const int16ss); + extern f_status_t f_int16ss_decimate_by(const f_number_unsigned_t amount, f_int16ss_t * const structure); #endif // _di_f_int16ss_decimate_by_ /** - * Resize the int16ss array to a smaller size. + * Resize the string int16ss array to a smaller size. * * This will resize making the array smaller based on (size - given length). * If the given length is too small, then the resize will fail. @@ -286,24 +309,24 @@ extern "C" { * * @param amount * A positive number representing how much to decrease the size by. - * @param int16ss - * The int16ss array to resize. + * @param structure + * The string int16ss array to resize. * * @return * F_none on success. - * F_data_not if amount is 0. * * 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() */ #ifndef _di_f_int16ss_decrease_by_ - extern f_status_t f_int16ss_decrease_by(const f_number_unsigned_t amount, f_int16ss_t * const int16ss); + extern f_status_t f_int16ss_decrease_by(const f_number_unsigned_t amount, f_int16ss_t * const structure); #endif // _di_f_int16ss_decrease_by_ /** - * Increase the size of the int16ss array, but only if necessary. + * Increase the size of the string int16ss array, 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. @@ -311,8 +334,8 @@ extern "C" { * @param step * The allocation step to use. * Must be greater than 0. - * @param int16ss - * The int16ss array to resize. + * @param structure + * The string int16ss array to resize. * * @return * F_none on success. @@ -321,14 +344,16 @@ extern "C" { * F_array_too_large (with error bit) if the new array length is too large. * 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(). + * + * @see f_memory_array_resize() */ #ifndef _di_f_int16ss_increase_ - extern f_status_t f_int16ss_increase(const f_number_unsigned_t step, f_int16ss_t * const int16ss); + extern f_status_t f_int16ss_increase(const f_number_unsigned_t step, f_int16ss_t * const structure); #endif // _di_f_int16ss_increase_ /** - * Resize the int16ss array to a larger size. + * Resize the string int16ss array 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). @@ -336,8 +361,8 @@ extern "C" { * * @param amount * A positive number representing how much to increase the size by. - * @param int16ss - * The int16ss array to resize. + * @param structure + * The string int16ss array to resize. * * @return * F_none on success. @@ -346,30 +371,33 @@ extern "C" { * F_array_too_large (with error bit) if the new array length is too large. * 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(). + * + * @see f_memory_array_resize() */ #ifndef _di_f_int16ss_increase_by_ - extern f_status_t f_int16ss_increase_by(const f_number_unsigned_t amount, f_int16ss_t * const int16ss); + extern f_status_t f_int16ss_increase_by(const f_number_unsigned_t amount, f_int16ss_t * const structure); #endif // _di_f_int16ss_increase_by_ /** - * Resize the int16ss array. + * Resize the string int16ss array. * * @param length * The new size to use. - * @param int16ss - * The int16ss array to adjust. + * @param structure + * The string int16ss array to adjust. * * @return * F_none on success. * * 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() */ #ifndef _di_f_int16ss_resize_ - extern f_status_t f_int16ss_resize(const f_number_unsigned_t length, f_int16ss_t * const int16ss); + extern f_status_t f_int16ss_resize(const f_number_unsigned_t length, f_int16ss_t * const structure); #endif // _di_f_int16ss_resize_ #ifdef __cplusplus diff --git a/level_0/f_type_array/c/type_array/int32.c b/level_0/f_type_array/c/type_array/int32.c index f51c374..11f8ce5 100644 --- a/level_0/f_type_array/c/type_array/int32.c +++ b/level_0/f_type_array/c/type_array/int32.c @@ -7,12 +7,12 @@ extern "C" { #endif #ifndef _di_f_int32s_adjust_ - f_status_t f_int32s_adjust(const f_number_unsigned_t length, f_int32s_t * const int32s) { + f_status_t f_int32s_adjust(const f_number_unsigned_t length, f_int32s_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!int32s) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_int32s_adjust(length, int32s); + return f_memory_array_adjust(length, sizeof(int32_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_int32s_adjust_ @@ -39,98 +39,62 @@ extern "C" { #endif // _di_f_int32s_append_all_ #ifndef _di_f_int32s_decimate_by_ - f_status_t f_int32s_decimate_by(const f_number_unsigned_t amount, f_int32s_t * const int32s) { + f_status_t f_int32s_decimate_by(const f_number_unsigned_t amount, f_int32s_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!int32s) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; - - if (int32s->size - amount > 0) { - return private_f_int32s_adjust(int32s->size - amount, int32s); - } - - return private_f_int32s_adjust(0, int32s); + return f_memory_array_decimate_by(amount, sizeof(int32_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_int32s_decimate_by_ #ifndef _di_f_int32s_decrease_by_ - f_status_t f_int32s_decrease_by(const f_number_unsigned_t amount, f_int32s_t * const int32s) { + f_status_t f_int32s_decrease_by(const f_number_unsigned_t amount, f_int32s_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!int32s) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; - - if (int32s->size - amount > 0) { - return private_f_int32s_resize(int32s->size - amount, int32s); - } - - return private_f_int32s_resize(0, int32s); + return f_memory_array_decrease_by(amount, sizeof(int32_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_int32s_decrease_by_ #ifndef _di_f_int32s_increase_ - f_status_t f_int32s_increase(const f_number_unsigned_t step, f_int32s_t * const int32s) { + f_status_t f_int32s_increase(const f_number_unsigned_t step, f_int32s_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!int32s) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (step && int32s->used + 1 > int32s->size) { - f_number_unsigned_t size = int32s->used + step; - - if (size > F_number_t_size_unsigned_d) { - if (int32s->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_int32s_resize(size, int32s); - } - - return F_data_not; + return f_memory_array_increase(step, sizeof(int32_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_int32s_increase_ #ifndef _di_f_int32s_increase_by_ - f_status_t f_int32s_increase_by(const f_number_unsigned_t amount, f_int32s_t * const int32s) { + f_status_t f_int32s_increase_by(const f_number_unsigned_t amount, f_int32s_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!int32s) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; - - if (int32s->used + amount > int32s->size) { - if (int32s->used + amount > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } - - return private_f_int32s_resize(int32s->used + amount, int32s); - } - - return F_data_not; + return f_memory_array_increase_by(amount, sizeof(int32_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_int32s_increase_by_ #ifndef _di_f_int32s_resize_ - f_status_t f_int32s_resize(const f_number_unsigned_t length, f_int32s_t * const int32s) { + f_status_t f_int32s_resize(const f_number_unsigned_t length, f_int32s_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!int32s) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_int32s_resize(length, int32s); + return f_memory_array_resize(length, sizeof(int32_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_int32s_resize_ #ifndef _di_f_int32ss_adjust_ - f_status_t f_int32ss_adjust(const f_number_unsigned_t length, f_int32ss_t * const int32ss) { + f_status_t f_int32ss_adjust(const f_number_unsigned_t length, f_int32ss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!int32ss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_int32ss_adjust(length, int32ss); + return private_f_int32ss_adjust(length, structure); } #endif // _di_f_int32ss_adjust_ @@ -142,12 +106,8 @@ extern "C" { if (!source.used) return F_data_not; - f_status_t status = F_none; - - if (destination->used + 1 > destination->size) { - status = private_f_int32ss_resize(destination->used + F_memory_default_allocation_small_d, destination); - if (F_status_is_error(status)) return status; - } + f_status_t status = f_memory_array_increase(F_memory_default_allocation_small_d, sizeof(f_int32s_t), (void **) &destination->array, &destination->used, &destination->size); + if (F_status_is_error(status)) return status; status = private_f_int32s_append_all(source, &destination->array[destination->used]); if (F_status_is_error(status)) return status; @@ -166,12 +126,8 @@ extern "C" { if (!source.used) return F_data_not; - f_status_t status = F_none; - - if (destination->used + source.used > destination->size) { - status = private_f_int32ss_resize(destination->used + source.used, destination); - if (F_status_is_error(status)) return status; - } + f_status_t status = f_memory_array_increase_by(source.used, sizeof(f_int32s_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->used) { @@ -188,55 +144,47 @@ extern "C" { #endif // _di_f_int32ss_append_all_ #ifndef _di_f_int32ss_decimate_by_ - f_status_t f_int32ss_decimate_by(const f_number_unsigned_t amount, f_int32ss_t * const int32ss) { + f_status_t f_int32ss_decimate_by(const f_number_unsigned_t amount, f_int32ss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!int32ss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - if (int32ss->size - amount > 0) { - return private_f_int32ss_adjust(int32ss->size - amount, int32ss); - } - - return private_f_int32ss_adjust(0, int32ss); + return private_f_int32ss_adjust((structure->size - amount > 0) ? structure->size - amount : 0, structure); } #endif // _di_f_int32ss_decimate_by_ #ifndef _di_f_int32ss_decrease_by_ - f_status_t f_int32ss_decrease_by(const f_number_unsigned_t amount, f_int32ss_t * const int32ss) { + f_status_t f_int32ss_decrease_by(const f_number_unsigned_t amount, f_int32ss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!int32ss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - if (int32ss->size - amount > 0) { - return private_f_int32ss_resize(int32ss->size - amount, int32ss); - } - - return private_f_int32ss_resize(0, int32ss); + return private_f_int32ss_resize((structure->size - amount > 0) ? structure->size - amount : 0, structure); } #endif // _di_f_int32ss_decrease_by_ #ifndef _di_f_int32ss_increase_ - f_status_t f_int32ss_increase(const f_number_unsigned_t step, f_int32ss_t * const int32ss) { + f_status_t f_int32ss_increase(const f_number_unsigned_t step, f_int32ss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!int32ss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (step && int32ss->used + 1 > int32ss->size) { - f_number_unsigned_t size = int32ss->used + step; + if (step && structure->used + 1 > structure->size) { + if (structure->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + + f_number_unsigned_t length = structure->used + step; - if (size > F_number_t_size_unsigned_d) { - if (int32ss->used + 1 > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + if (length > F_number_t_size_unsigned_d) { + if (structure->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - size = F_number_t_size_unsigned_d; + length = F_number_t_size_unsigned_d; } - return private_f_int32ss_resize(size, int32ss); + return private_f_int32ss_resize(length, structure); } return F_data_not; @@ -244,19 +192,21 @@ extern "C" { #endif // _di_f_int32ss_increase_ #ifndef _di_f_int32ss_increase_by_ - f_status_t f_int32ss_increase_by(const f_number_unsigned_t amount, f_int32ss_t * const int32ss) { + f_status_t f_int32ss_increase_by(const f_number_unsigned_t amount, f_int32ss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!int32ss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; + if (amount) { + if (structure->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - if (int32ss->used + amount > int32ss->size) { - if (int32ss->used + amount > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + const f_number_unsigned_t length = structure->used + amount; - return private_f_int32ss_resize(int32ss->used + amount, int32ss); + if (length > structure->size) { + if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + + return private_f_int32ss_resize(structure->used + amount, structure); + } } return F_data_not; @@ -264,12 +214,12 @@ extern "C" { #endif // _di_f_int32ss_increase_by_ #ifndef _di_f_int32ss_resize_ - f_status_t f_int32ss_resize(const f_number_unsigned_t length, f_int32ss_t * const int32ss) { + f_status_t f_int32ss_resize(const f_number_unsigned_t length, f_int32ss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!int32ss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_int32ss_resize(length, int32ss); + return private_f_int32ss_resize(length, structure); } #endif // _di_f_int32ss_resize_ diff --git a/level_0/f_type_array/c/type_array/int32.h b/level_0/f_type_array/c/type_array/int32.h index 7773184..9ba6885 100644 --- a/level_0/f_type_array/c/type_array/int32.h +++ b/level_0/f_type_array/c/type_array/int32.h @@ -17,22 +17,24 @@ extern "C" { #endif /** - * Resize the int32s array. + * Resize the string int32s array. * * @param length * The new size to use. - * @param int32s - * The int32s array to resize. + * @param structure + * The string int32s array to resize. * * @return * F_none on success. * * 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_array_adjust(). + * + * @see f_memory_array_adjust() */ #ifndef _di_f_int32s_adjust_ - extern f_status_t f_int32s_adjust(const f_number_unsigned_t length, f_int32s_t * const int32s); + extern f_status_t f_int32s_adjust(const f_number_unsigned_t length, f_int32s_t * const structure); #endif // _di_f_int32s_adjust_ /** @@ -49,7 +51,9 @@ extern "C" { * * 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(). + * + * @see f_memory_array_increase() */ #ifndef _di_f_int32s_append_ extern f_status_t f_int32s_append(const int32_t source, f_int32s_t * const destination); @@ -69,14 +73,16 @@ extern "C" { * * 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() */ #ifndef _di_f_int32s_append_all_ extern f_status_t f_int32s_append_all(const f_int32s_t source, f_int32s_t * const destination); #endif // _di_f_int32s_append_all_ /** - * Resize the int32s array to a smaller size. + * Resize the string int32s array to a smaller size. * * This will resize making the array smaller based on (size - given length). * If the given length is too small, then the resize will fail. @@ -84,8 +90,8 @@ extern "C" { * * @param amount * A positive number representing how much to decimate the size by. - * @param int32s - * The int32s array to resize. + * @param structure + * The string int32s array to resize. * * @return * F_none on success. @@ -93,14 +99,16 @@ extern "C" { * * 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_array_decimate_by(). + * + * @see f_memory_array_decimate_by() */ #ifndef _di_f_int32s_decimate_by_ - extern f_status_t f_int32s_decimate_by(const f_number_unsigned_t amount, f_int32s_t * const int32s); + extern f_status_t f_int32s_decimate_by(const f_number_unsigned_t amount, f_int32s_t * const structure); #endif // _di_f_int32s_decimate_by_ /** - * Resize the int32s array to a smaller size. + * Resize the string int32s array to a smaller size. * * This will resize making the array smaller based on (size - given length). * If the given length is too small, then the resize will fail. @@ -108,22 +116,25 @@ extern "C" { * * @param amount * A positive number representing how much to decrease the size by. - * @param int32s - * The int32s array to resize. + * @param structure + * The string int32s array to resize. * * @return * F_none on success. + * F_data_not if amount is 0. * * 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_decrease_by(). + * + * @see f_memory_array_decrease_by() */ #ifndef _di_f_int32s_decrease_by_ - extern f_status_t f_int32s_decrease_by(const f_number_unsigned_t amount, f_int32s_t * const int32s); + extern f_status_t f_int32s_decrease_by(const f_number_unsigned_t amount, f_int32s_t * const structure); #endif // _di_f_int32s_decrease_by_ /** - * Increase the size of the int32s array, but only if necesary. + * Increase the size of the string int32s array, but only if necesary. * * 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. @@ -131,8 +142,8 @@ extern "C" { * @param step * The allocation step to use. * Must be greater than 0. - * @param int32s - * The int32s array to resize. + * @param structure + * The string int32s array to resize. * * @return * F_none on success. @@ -141,14 +152,16 @@ extern "C" { * F_array_too_large (with error bit) if the new array length is too large. * 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(). + * + * @see f_memory_array_increase() */ #ifndef _di_f_int32s_increase_ - extern f_status_t f_int32s_increase(const f_number_unsigned_t step, f_int32s_t * const int32s); + extern f_status_t f_int32s_increase(const f_number_unsigned_t step, f_int32s_t * const structure); #endif // _di_f_int32s_increase_ /** - * Resize the int32s array to a larger size. + * Resize the string int32s array 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). @@ -156,8 +169,8 @@ extern "C" { * * @param amount * A positive number representing how much to increase the size by. - * @param int32s - * The int32s array to resize. + * @param structure + * The string int32s array to resize. * * @return * F_none on success. @@ -166,49 +179,54 @@ extern "C" { * F_array_too_large (with error bit) if the new array length is too large. * 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() */ #ifndef _di_f_int32s_increase_by_ - extern f_status_t f_int32s_increase_by(const f_number_unsigned_t amount, f_int32s_t * const int32s); + extern f_status_t f_int32s_increase_by(const f_number_unsigned_t amount, f_int32s_t * const structure); #endif // _di_f_int32s_increase_by_ /** - * Resize the int32s array. + * Resize the string int32s array. * * @param length * The new size to use. - * @param int32s - * The int32s array to adjust. + * @param structure + * The string int32s array to adjust. * * @return * F_none on success. * * 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(). + * + * @see f_memory_array_resize() */ #ifndef _di_f_int32s_resize_ - extern f_status_t f_int32s_resize(const f_number_unsigned_t length, f_int32s_t * const int32s); + extern f_status_t f_int32s_resize(const f_number_unsigned_t length, f_int32s_t * const structure); #endif // _di_f_int32s_resize_ /** - * Resize the int32ss array. + * Resize the string int32ss array. * * @param length * The new size to use. - * @param int32ss - * The int32ss array to resize. + * @param structure + * The string int32ss array to resize. * * @return * F_none on success. * * 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() */ #ifndef _di_f_int32ss_adjust_ - extern f_status_t f_int32ss_adjust(const f_number_unsigned_t length, f_int32ss_t * const int32ss); + extern f_status_t f_int32ss_adjust(const f_number_unsigned_t length, f_int32ss_t * const structure); #endif // _di_f_int32ss_adjust_ /** @@ -225,7 +243,11 @@ extern "C" { * * 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(). + * Errors (with error bit) from: f_memory_array_increase_by(). + * + * @see f_memory_array_increase() + * @see f_memory_array_increase_by() */ #ifndef _di_f_int32ss_append_ extern f_status_t f_int32ss_append(const f_int32s_t source, f_int32ss_t * const destination); @@ -245,14 +267,16 @@ extern "C" { * * 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() */ #ifndef _di_f_int32ss_append_all_ extern f_status_t f_int32ss_append_all(const f_int32ss_t source, f_int32ss_t * const destination); #endif // _di_f_int32ss_append_all_ /** - * Resize the int32ss array to a smaller size. + * Resize the string int32ss array to a smaller size. * * This will resize making the array smaller based on (size - given length). * If the given length is too small, then the resize will fail. @@ -260,24 +284,24 @@ extern "C" { * * @param amount * A positive number representing how much to decimate the size by. - * @param int32ss - * The int32ss array to resize. + * @param structure + * The string int32ss array to resize. * * @return * F_none on success. - * F_data_not if amount is 0. * * 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() */ #ifndef _di_f_int32ss_decimate_by_ - extern f_status_t f_int32ss_decimate_by(const f_number_unsigned_t amount, f_int32ss_t * const int32ss); + extern f_status_t f_int32ss_decimate_by(const f_number_unsigned_t amount, f_int32ss_t * const structure); #endif // _di_f_int32ss_decimate_by_ /** - * Resize the int32ss array to a smaller size. + * Resize the string int32ss array to a smaller size. * * This will resize making the array smaller based on (size - given length). * If the given length is too small, then the resize will fail. @@ -285,23 +309,24 @@ extern "C" { * * @param amount * A positive number representing how much to decrease the size by. - * @param int32ss - * The int32ss array to resize. + * @param structure + * The string int32ss array to resize. * * @return * F_none on success. * * 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() */ #ifndef _di_f_int32ss_decrease_by_ - extern f_status_t f_int32ss_decrease_by(const f_number_unsigned_t amount, f_int32ss_t * const int32ss); + extern f_status_t f_int32ss_decrease_by(const f_number_unsigned_t amount, f_int32ss_t * const structure); #endif // _di_f_int32ss_decrease_by_ /** - * Increase the size of the int32ss array, but only if necessary. + * Increase the size of the string int32ss array, 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. @@ -309,8 +334,8 @@ extern "C" { * @param step * The allocation step to use. * Must be greater than 0. - * @param int32ss - * The int32ss array to resize. + * @param structure + * The string int32ss array to resize. * * @return * F_none on success. @@ -319,14 +344,16 @@ extern "C" { * F_array_too_large (with error bit) if the new array length is too large. * 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(). + * + * @see f_memory_array_resize() */ #ifndef _di_f_int32ss_increase_ - extern f_status_t f_int32ss_increase(const f_number_unsigned_t step, f_int32ss_t * const int32ss); + extern f_status_t f_int32ss_increase(const f_number_unsigned_t step, f_int32ss_t * const structure); #endif // _di_f_int32ss_increase_ /** - * Resize the int32ss array to a larger size. + * Resize the string int32ss array 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). @@ -334,8 +361,8 @@ extern "C" { * * @param amount * A positive number representing how much to increase the size by. - * @param int32ss - * The int32ss array to resize. + * @param structure + * The string int32ss array to resize. * * @return * F_none on success. @@ -344,30 +371,33 @@ extern "C" { * F_array_too_large (with error bit) if the new array length is too large. * 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(). + * + * @see f_memory_array_resize() */ #ifndef _di_f_int32ss_increase_by_ - extern f_status_t f_int32ss_increase_by(const f_number_unsigned_t amount, f_int32ss_t * const int32ss); + extern f_status_t f_int32ss_increase_by(const f_number_unsigned_t amount, f_int32ss_t * const structure); #endif // _di_f_int32ss_increase_by_ /** - * Resize the int32ss array. + * Resize the string int32ss array. * * @param length * The new size to use. - * @param int32ss - * The int32ss array to adjust. + * @param structure + * The string int32ss array to adjust. * * @return * F_none on success. * * 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() */ #ifndef _di_f_int32ss_resize_ - extern f_status_t f_int32ss_resize(const f_number_unsigned_t length, f_int32ss_t * const int32ss); + extern f_status_t f_int32ss_resize(const f_number_unsigned_t length, f_int32ss_t * const structure); #endif // _di_f_int32ss_resize_ #ifdef __cplusplus diff --git a/level_0/f_type_array/c/type_array/int64.c b/level_0/f_type_array/c/type_array/int64.c index 94f253b..4d4da94 100644 --- a/level_0/f_type_array/c/type_array/int64.c +++ b/level_0/f_type_array/c/type_array/int64.c @@ -7,12 +7,12 @@ extern "C" { #endif #ifndef _di_f_int64s_adjust_ - f_status_t f_int64s_adjust(const f_number_unsigned_t length, f_int64s_t * const int64s) { + f_status_t f_int64s_adjust(const f_number_unsigned_t length, f_int64s_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!int64s) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_int64s_adjust(length, int64s); + return f_memory_array_adjust(length, sizeof(int64_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_int64s_adjust_ @@ -39,98 +39,62 @@ extern "C" { #endif // _di_f_int64s_append_all_ #ifndef _di_f_int64s_decimate_by_ - f_status_t f_int64s_decimate_by(const f_number_unsigned_t amount, f_int64s_t * const int64s) { + f_status_t f_int64s_decimate_by(const f_number_unsigned_t amount, f_int64s_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!int64s) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; - - if (int64s->size - amount > 0) { - return private_f_int64s_adjust(int64s->size - amount, int64s); - } - - return private_f_int64s_adjust(0, int64s); + return f_memory_array_decimate_by(amount, sizeof(int64_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_int64s_decimate_by_ #ifndef _di_f_int64s_decrease_by_ - f_status_t f_int64s_decrease_by(const f_number_unsigned_t amount, f_int64s_t * const int64s) { + f_status_t f_int64s_decrease_by(const f_number_unsigned_t amount, f_int64s_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!int64s) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; - - if (int64s->size - amount > 0) { - return private_f_int64s_resize(int64s->size - amount, int64s); - } - - return private_f_int64s_resize(0, int64s); + return f_memory_array_decrease_by(amount, sizeof(int64_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_int64s_decrease_by_ #ifndef _di_f_int64s_increase_ - f_status_t f_int64s_increase(const f_number_unsigned_t step, f_int64s_t * const int64s) { + f_status_t f_int64s_increase(const f_number_unsigned_t step, f_int64s_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!int64s) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (step && int64s->used + 1 > int64s->size) { - f_number_unsigned_t size = int64s->used + step; - - if (size > F_number_t_size_unsigned_d) { - if (int64s->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_int64s_resize(size, int64s); - } - - return F_data_not; + return f_memory_array_increase(step, sizeof(int64_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_int64s_increase_ #ifndef _di_f_int64s_increase_by_ - f_status_t f_int64s_increase_by(const f_number_unsigned_t amount, f_int64s_t * const int64s) { + f_status_t f_int64s_increase_by(const f_number_unsigned_t amount, f_int64s_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!int64s) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; - - if (int64s->used + amount > int64s->size) { - if (int64s->used + amount > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } - - return private_f_int64s_resize(int64s->used + amount, int64s); - } - - return F_data_not; + return f_memory_array_increase_by(amount, sizeof(int64_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_int64s_increase_by_ #ifndef _di_f_int64s_resize_ - f_status_t f_int64s_resize(const f_number_unsigned_t length, f_int64s_t * const int64s) { + f_status_t f_int64s_resize(const f_number_unsigned_t length, f_int64s_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!int64s) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_int64s_resize(length, int64s); + return f_memory_array_resize(length, sizeof(int64_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_int64s_resize_ #ifndef _di_f_int64ss_adjust_ - f_status_t f_int64ss_adjust(const f_number_unsigned_t length, f_int64ss_t * const int64ss) { + f_status_t f_int64ss_adjust(const f_number_unsigned_t length, f_int64ss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!int64ss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_int64ss_adjust(length, int64ss); + return private_f_int64ss_adjust(length, structure); } #endif // _di_f_int64ss_adjust_ @@ -142,12 +106,8 @@ extern "C" { if (!source.used) return F_data_not; - f_status_t status = F_none; - - if (destination->used + 1 > destination->size) { - status = private_f_int64ss_resize(destination->used + F_memory_default_allocation_small_d, destination); - if (F_status_is_error(status)) return status; - } + f_status_t status = f_memory_array_increase(F_memory_default_allocation_small_d, sizeof(f_int64s_t), (void **) &destination->array, &destination->used, &destination->size); + if (F_status_is_error(status)) return status; status = private_f_int64s_append_all(source, &destination->array[destination->used]); if (F_status_is_error(status)) return status; @@ -166,12 +126,8 @@ extern "C" { if (!source.used) return F_data_not; - f_status_t status = F_none; - - if (destination->used + source.used > destination->size) { - status = private_f_int64ss_resize(destination->used + source.used, destination); - if (F_status_is_error(status)) return status; - } + f_status_t status = f_memory_array_increase_by(source.used, sizeof(f_int64s_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->used) { @@ -188,55 +144,47 @@ extern "C" { #endif // _di_f_int64ss_append_all_ #ifndef _di_f_int64ss_decimate_by_ - f_status_t f_int64ss_decimate_by(const f_number_unsigned_t amount, f_int64ss_t * const int64ss) { + f_status_t f_int64ss_decimate_by(const f_number_unsigned_t amount, f_int64ss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!int64ss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - if (int64ss->size - amount > 0) { - return private_f_int64ss_adjust(int64ss->size - amount, int64ss); - } - - return private_f_int64ss_adjust(0, int64ss); + return private_f_int64ss_adjust((structure->size - amount > 0) ? structure->size - amount : 0, structure); } #endif // _di_f_int64ss_decimate_by_ #ifndef _di_f_int64ss_decrease_by_ - f_status_t f_int64ss_decrease_by(const f_number_unsigned_t amount, f_int64ss_t * const int64ss) { + f_status_t f_int64ss_decrease_by(const f_number_unsigned_t amount, f_int64ss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!int64ss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - if (int64ss->size - amount > 0) { - return private_f_int64ss_resize(int64ss->size - amount, int64ss); - } - - return private_f_int64ss_resize(0, int64ss); + return private_f_int64ss_resize((structure->size - amount > 0) ? structure->size - amount : 0, structure); } #endif // _di_f_int64ss_decrease_by_ #ifndef _di_f_int64ss_increase_ - f_status_t f_int64ss_increase(const f_number_unsigned_t step, f_int64ss_t * const int64ss) { + f_status_t f_int64ss_increase(const f_number_unsigned_t step, f_int64ss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!int64ss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (step && int64ss->used + 1 > int64ss->size) { - f_number_unsigned_t size = int64ss->used + step; + if (step && structure->used + 1 > structure->size) { + if (structure->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + + f_number_unsigned_t length = structure->used + step; - if (size > F_number_t_size_unsigned_d) { - if (int64ss->used + 1 > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + if (length > F_number_t_size_unsigned_d) { + if (structure->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - size = F_number_t_size_unsigned_d; + length = F_number_t_size_unsigned_d; } - return private_f_int64ss_resize(size, int64ss); + return private_f_int64ss_resize(length, structure); } return F_data_not; @@ -244,19 +192,21 @@ extern "C" { #endif // _di_f_int64ss_increase_ #ifndef _di_f_int64ss_increase_by_ - f_status_t f_int64ss_increase_by(const f_number_unsigned_t amount, f_int64ss_t * const int64ss) { + f_status_t f_int64ss_increase_by(const f_number_unsigned_t amount, f_int64ss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!int64ss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; + if (amount) { + if (structure->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - if (int64ss->used + amount > int64ss->size) { - if (int64ss->used + amount > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + const f_number_unsigned_t length = structure->used + amount; - return private_f_int64ss_resize(int64ss->used + amount, int64ss); + if (length > structure->size) { + if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + + return private_f_int64ss_resize(structure->used + amount, structure); + } } return F_data_not; @@ -264,12 +214,12 @@ extern "C" { #endif // _di_f_int64ss_increase_by_ #ifndef _di_f_int64ss_resize_ - f_status_t f_int64ss_resize(const f_number_unsigned_t length, f_int64ss_t * const int64ss) { + f_status_t f_int64ss_resize(const f_number_unsigned_t length, f_int64ss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!int64ss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_int64ss_resize(length, int64ss); + return private_f_int64ss_resize(length, structure); } #endif // _di_f_int64ss_resize_ diff --git a/level_0/f_type_array/c/type_array/int64.h b/level_0/f_type_array/c/type_array/int64.h index 12d68a9..1ff2bd2 100644 --- a/level_0/f_type_array/c/type_array/int64.h +++ b/level_0/f_type_array/c/type_array/int64.h @@ -17,22 +17,24 @@ extern "C" { #endif /** - * Resize the int64s array. + * Resize the string int64s array. * * @param length * The new size to use. - * @param int64s - * The int64s array to resize. + * @param structure + * The string int64s array to resize. * * @return * F_none on success. * * 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_array_adjust(). + * + * @see f_memory_array_adjust() */ #ifndef _di_f_int64s_adjust_ - extern f_status_t f_int64s_adjust(const f_number_unsigned_t length, f_int64s_t * const int64s); + extern f_status_t f_int64s_adjust(const f_number_unsigned_t length, f_int64s_t * const structure); #endif // _di_f_int64s_adjust_ /** @@ -49,7 +51,9 @@ extern "C" { * * 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(). + * + * @see f_memory_array_increase() */ #ifndef _di_f_int64s_append_ extern f_status_t f_int64s_append(const int64_t source, f_int64s_t * const destination); @@ -69,14 +73,16 @@ extern "C" { * * 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() */ #ifndef _di_f_int64s_append_all_ extern f_status_t f_int64s_append_all(const f_int64s_t source, f_int64s_t * const destination); #endif // _di_f_int64s_append_all_ /** - * Resize the int64s array to a smaller size. + * Resize the string int64s array to a smaller size. * * This will resize making the array smaller based on (size - given length). * If the given length is too small, then the resize will fail. @@ -84,8 +90,8 @@ extern "C" { * * @param amount * A positive number representing how much to decimate the size by. - * @param int64s - * The int64s array to resize. + * @param structure + * The string int64s array to resize. * * @return * F_none on success. @@ -93,14 +99,16 @@ extern "C" { * * 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_array_decimate_by(). + * + * @see f_memory_array_decimate_by() */ #ifndef _di_f_int64s_decimate_by_ - extern f_status_t f_int64s_decimate_by(const f_number_unsigned_t amount, f_int64s_t * const int64s); + extern f_status_t f_int64s_decimate_by(const f_number_unsigned_t amount, f_int64s_t * const structure); #endif // _di_f_int64s_decimate_by_ /** - * Resize the int64s array to a smaller size. + * Resize the string int64s array to a smaller size. * * This will resize making the array smaller based on (size - given length). * If the given length is too small, then the resize will fail. @@ -108,8 +116,8 @@ extern "C" { * * @param amount * A positive number representing how much to decrease the size by. - * @param int64s - * The int64s array to resize. + * @param structure + * The string int64s array to resize. * * @return * F_none on success. @@ -117,14 +125,16 @@ extern "C" { * * 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_decrease_by(). + * + * @see f_memory_array_decrease_by() */ #ifndef _di_f_int64s_decrease_by_ - extern f_status_t f_int64s_decrease_by(const f_number_unsigned_t amount, f_int64s_t * const int64s); + extern f_status_t f_int64s_decrease_by(const f_number_unsigned_t amount, f_int64s_t * const structure); #endif // _di_f_int64s_decrease_by_ /** - * Increase the size of the int64s array, but only if necesary. + * Increase the size of the string int64s array, but only if necesary. * * 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. @@ -132,8 +142,8 @@ extern "C" { * @param step * The allocation step to use. * Must be greater than 0. - * @param int64s - * The int64s array to resize. + * @param structure + * The string int64s array to resize. * * @return * F_none on success. @@ -142,14 +152,16 @@ extern "C" { * F_array_too_large (with error bit) if the new array length is too large. * 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(). + * + * @see f_memory_array_increase() */ #ifndef _di_f_int64s_increase_ - extern f_status_t f_int64s_increase(const f_number_unsigned_t step, f_int64s_t * const int64s); + extern f_status_t f_int64s_increase(const f_number_unsigned_t step, f_int64s_t * const structure); #endif // _di_f_int64s_increase_ /** - * Resize the int64s array to a larger size. + * Resize the string int64s array 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). @@ -157,8 +169,8 @@ extern "C" { * * @param amount * A positive number representing how much to increase the size by. - * @param int64s - * The int64s array to resize. + * @param structure + * The string int64s array to resize. * * @return * F_none on success. @@ -167,49 +179,54 @@ extern "C" { * F_array_too_large (with error bit) if the new array length is too large. * 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() */ #ifndef _di_f_int64s_increase_by_ - extern f_status_t f_int64s_increase_by(const f_number_unsigned_t amount, f_int64s_t * const int64s); + extern f_status_t f_int64s_increase_by(const f_number_unsigned_t amount, f_int64s_t * const structure); #endif // _di_f_int64s_increase_by_ /** - * Resize the int64s array. + * Resize the string int64s array. * * @param length * The new size to use. - * @param int64s - * The int64s array to adjust. + * @param structure + * The string int64s array to adjust. * * @return * F_none on success. * * 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(). + * + * @see f_memory_array_resize() */ #ifndef _di_f_int64s_resize_ - extern f_status_t f_int64s_resize(const f_number_unsigned_t length, f_int64s_t * const int64s); + extern f_status_t f_int64s_resize(const f_number_unsigned_t length, f_int64s_t * const structure); #endif // _di_f_int64s_resize_ /** - * Resize the int64ss array. + * Resize the string int64ss array. * * @param length * The new size to use. - * @param int64ss - * The int64ss array to resize. + * @param structure + * The string int64ss array to resize. * * @return * F_none on success. * * 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() */ #ifndef _di_f_int64ss_adjust_ - extern f_status_t f_int64ss_adjust(const f_number_unsigned_t length, f_int64ss_t * const int64ss); + extern f_status_t f_int64ss_adjust(const f_number_unsigned_t length, f_int64ss_t * const structure); #endif // _di_f_int64ss_adjust_ /** @@ -226,7 +243,11 @@ extern "C" { * * 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(). + * Errors (with error bit) from: f_memory_array_increase_by(). + * + * @see f_memory_array_increase() + * @see f_memory_array_increase_by() */ #ifndef _di_f_int64ss_append_ extern f_status_t f_int64ss_append(const f_int64s_t source, f_int64ss_t * const destination); @@ -246,14 +267,16 @@ extern "C" { * * 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() */ #ifndef _di_f_int64ss_append_all_ extern f_status_t f_int64ss_append_all(const f_int64ss_t source, f_int64ss_t * const destination); #endif // _di_f_int64ss_append_all_ /** - * Resize the int64ss array to a smaller size. + * Resize the string int64ss array to a smaller size. * * This will resize making the array smaller based on (size - given length). * If the given length is too small, then the resize will fail. @@ -261,24 +284,24 @@ extern "C" { * * @param amount * A positive number representing how much to decimate the size by. - * @param int64ss - * The int64ss array to resize. + * @param structure + * The string int64ss array to resize. * * @return * F_none on success. - * F_data_not if amount is 0. * * 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() */ #ifndef _di_f_int64ss_decimate_by_ - extern f_status_t f_int64ss_decimate_by(const f_number_unsigned_t amount, f_int64ss_t * const int64ss); + extern f_status_t f_int64ss_decimate_by(const f_number_unsigned_t amount, f_int64ss_t * const structure); #endif // _di_f_int64ss_decimate_by_ /** - * Resize the int64ss array to a smaller size. + * Resize the string int64ss array to a smaller size. * * This will resize making the array smaller based on (size - given length). * If the given length is too small, then the resize will fail. @@ -286,24 +309,24 @@ extern "C" { * * @param amount * A positive number representing how much to decrease the size by. - * @param int64ss - * The int64ss array to resize. + * @param structure + * The string int64ss array to resize. * * @return * F_none on success. - * F_data_not if amount is 0. * * 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() */ #ifndef _di_f_int64ss_decrease_by_ - extern f_status_t f_int64ss_decrease_by(const f_number_unsigned_t amount, f_int64ss_t * const int64ss); + extern f_status_t f_int64ss_decrease_by(const f_number_unsigned_t amount, f_int64ss_t * const structure); #endif // _di_f_int64ss_decrease_by_ /** - * Increase the size of the int64ss array, but only if necessary. + * Increase the size of the string int64ss array, 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. @@ -311,8 +334,8 @@ extern "C" { * @param step * The allocation step to use. * Must be greater than 0. - * @param int64ss - * The int64ss array to resize. + * @param structure + * The string int64ss array to resize. * * @return * F_none on success. @@ -321,14 +344,16 @@ extern "C" { * F_array_too_large (with error bit) if the new array length is too large. * 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(). + * + * @see f_memory_array_resize() */ #ifndef _di_f_int64ss_increase_ - extern f_status_t f_int64ss_increase(const f_number_unsigned_t step, f_int64ss_t * const int64ss); + extern f_status_t f_int64ss_increase(const f_number_unsigned_t step, f_int64ss_t * const structure); #endif // _di_f_int64ss_increase_ /** - * Resize the int64ss array to a larger size. + * Resize the string int64ss array 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). @@ -336,8 +361,8 @@ extern "C" { * * @param amount * A positive number representing how much to increase the size by. - * @param int64ss - * The int64ss array to resize. + * @param structure + * The string int64ss array to resize. * * @return * F_none on success. @@ -346,30 +371,33 @@ extern "C" { * F_array_too_large (with error bit) if the new array length is too large. * 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(). + * + * @see f_memory_array_resize() */ #ifndef _di_f_int64ss_increase_by_ - extern f_status_t f_int64ss_increase_by(const f_number_unsigned_t amount, f_int64ss_t * const int64ss); + extern f_status_t f_int64ss_increase_by(const f_number_unsigned_t amount, f_int64ss_t * const structure); #endif // _di_f_int64ss_increase_by_ /** - * Resize the int64ss array. + * Resize the string int64ss array. * * @param length * The new size to use. - * @param int64ss - * The int64ss array to adjust. + * @param structure + * The string int64ss array to adjust. * * @return * F_none on success. * * 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() */ #ifndef _di_f_int64ss_resize_ - extern f_status_t f_int64ss_resize(const f_number_unsigned_t length, f_int64ss_t * const int64ss); + extern f_status_t f_int64ss_resize(const f_number_unsigned_t length, f_int64ss_t * const structure); #endif // _di_f_int64ss_resize_ #ifdef __cplusplus diff --git a/level_0/f_type_array/c/type_array/int8.c b/level_0/f_type_array/c/type_array/int8.c index 5fb81b0..a74320f 100644 --- a/level_0/f_type_array/c/type_array/int8.c +++ b/level_0/f_type_array/c/type_array/int8.c @@ -7,12 +7,12 @@ extern "C" { #endif #ifndef _di_f_int8s_adjust_ - f_status_t f_int8s_adjust(const f_number_unsigned_t length, f_int8s_t * const int8s) { + f_status_t f_int8s_adjust(const f_number_unsigned_t length, f_int8s_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!int8s) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_int8s_adjust(length, int8s); + return f_memory_array_adjust(length, sizeof(int8_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_int8s_adjust_ @@ -39,98 +39,62 @@ extern "C" { #endif // _di_f_int8s_append_all_ #ifndef _di_f_int8s_decimate_by_ - f_status_t f_int8s_decimate_by(const f_number_unsigned_t amount, f_int8s_t * const int8s) { + f_status_t f_int8s_decimate_by(const f_number_unsigned_t amount, f_int8s_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!int8s) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; - - if (int8s->size - amount > 0) { - return private_f_int8s_adjust(int8s->size - amount, int8s); - } - - return private_f_int8s_adjust(0, int8s); + return f_memory_array_decimate_by(amount, sizeof(int8_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_int8s_decimate_by_ #ifndef _di_f_int8s_decrease_by_ - f_status_t f_int8s_decrease_by(const f_number_unsigned_t amount, f_int8s_t * const int8s) { + f_status_t f_int8s_decrease_by(const f_number_unsigned_t amount, f_int8s_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!int8s) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; - - if (int8s->size - amount > 0) { - return private_f_int8s_resize(int8s->size - amount, int8s); - } - - return private_f_int8s_resize(0, int8s); + return f_memory_array_decrease_by(amount, sizeof(int8_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_int8s_decrease_by_ #ifndef _di_f_int8s_increase_ - f_status_t f_int8s_increase(const f_number_unsigned_t step, f_int8s_t * const int8s) { + f_status_t f_int8s_increase(const f_number_unsigned_t step, f_int8s_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!int8s) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (step && int8s->used + 1 > int8s->size) { - f_number_unsigned_t size = int8s->used + step; - - if (size > F_number_t_size_unsigned_d) { - if (int8s->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_int8s_resize(size, int8s); - } - - return F_data_not; + return f_memory_array_increase(step, sizeof(int8_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_int8s_increase_ #ifndef _di_f_int8s_increase_by_ - f_status_t f_int8s_increase_by(const f_number_unsigned_t amount, f_int8s_t * const int8s) { + f_status_t f_int8s_increase_by(const f_number_unsigned_t amount, f_int8s_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!int8s) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; - - if (int8s->used + amount > int8s->size) { - if (int8s->used + amount > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } - - return private_f_int8s_resize(int8s->used + amount, int8s); - } - - return F_data_not; + return f_memory_array_increase_by(amount, sizeof(int8_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_int8s_increase_by_ #ifndef _di_f_int8s_resize_ - f_status_t f_int8s_resize(const f_number_unsigned_t length, f_int8s_t * const int8s) { + f_status_t f_int8s_resize(const f_number_unsigned_t length, f_int8s_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!int8s) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_int8s_resize(length, int8s); + return f_memory_array_resize(length, sizeof(int8_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_int8s_resize_ #ifndef _di_f_int8ss_adjust_ - f_status_t f_int8ss_adjust(const f_number_unsigned_t length, f_int8ss_t * const int8ss) { + f_status_t f_int8ss_adjust(const f_number_unsigned_t length, f_int8ss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!int8ss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_int8ss_adjust(length, int8ss); + return private_f_int8ss_adjust(length, structure); } #endif // _di_f_int8ss_adjust_ @@ -142,12 +106,8 @@ extern "C" { if (!source.used) return F_data_not; - f_status_t status = F_none; - - if (destination->used + 1 > destination->size) { - status = private_f_int8ss_resize(destination->used + F_memory_default_allocation_small_d, destination); - if (F_status_is_error(status)) return status; - } + f_status_t status = f_memory_array_increase(F_memory_default_allocation_small_d, sizeof(f_int8s_t), (void **) &destination->array, &destination->used, &destination->size); + if (F_status_is_error(status)) return status; status = private_f_int8s_append_all(source, &destination->array[destination->used]); if (F_status_is_error(status)) return status; @@ -166,12 +126,8 @@ extern "C" { if (!source.used) return F_data_not; - f_status_t status = F_none; - - if (destination->used + source.used > destination->size) { - status = private_f_int8ss_resize(destination->used + source.used, destination); - if (F_status_is_error(status)) return status; - } + f_status_t status = f_memory_array_increase_by(source.used, sizeof(f_int8s_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->used) { @@ -188,55 +144,47 @@ extern "C" { #endif // _di_f_int8ss_append_all_ #ifndef _di_f_int8ss_decimate_by_ - f_status_t f_int8ss_decimate_by(const f_number_unsigned_t amount, f_int8ss_t * const int8ss) { + f_status_t f_int8ss_decimate_by(const f_number_unsigned_t amount, f_int8ss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!int8ss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - if (int8ss->size - amount > 0) { - return private_f_int8ss_adjust(int8ss->size - amount, int8ss); - } - - return private_f_int8ss_adjust(0, int8ss); + return private_f_int8ss_adjust((structure->size - amount > 0) ? structure->size - amount : 0, structure); } #endif // _di_f_int8ss_decimate_by_ #ifndef _di_f_int8ss_decrease_by_ - f_status_t f_int8ss_decrease_by(const f_number_unsigned_t amount, f_int8ss_t * const int8ss) { + f_status_t f_int8ss_decrease_by(const f_number_unsigned_t amount, f_int8ss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!int8ss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - if (int8ss->size - amount > 0) { - return private_f_int8ss_resize(int8ss->size - amount, int8ss); - } - - return private_f_int8ss_resize(0, int8ss); + return private_f_int8ss_resize((structure->size - amount > 0) ? structure->size - amount : 0, structure); } #endif // _di_f_int8ss_decrease_by_ #ifndef _di_f_int8ss_increase_ - f_status_t f_int8ss_increase(const f_number_unsigned_t step, f_int8ss_t * const int8ss) { + f_status_t f_int8ss_increase(const f_number_unsigned_t step, f_int8ss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!int8ss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (step && int8ss->used + 1 > int8ss->size) { - f_number_unsigned_t size = int8ss->used + step; + if (step && structure->used + 1 > structure->size) { + if (structure->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + + f_number_unsigned_t length = structure->used + step; - if (size > F_number_t_size_unsigned_d) { - if (int8ss->used + 1 > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + if (length > F_number_t_size_unsigned_d) { + if (structure->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - size = F_number_t_size_unsigned_d; + length = F_number_t_size_unsigned_d; } - return private_f_int8ss_resize(size, int8ss); + return private_f_int8ss_resize(length, structure); } return F_data_not; @@ -244,19 +192,21 @@ extern "C" { #endif // _di_f_int8ss_increase_ #ifndef _di_f_int8ss_increase_by_ - f_status_t f_int8ss_increase_by(const f_number_unsigned_t amount, f_int8ss_t * const int8ss) { + f_status_t f_int8ss_increase_by(const f_number_unsigned_t amount, f_int8ss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!int8ss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; + if (amount) { + if (structure->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - if (int8ss->used + amount > int8ss->size) { - if (int8ss->used + amount > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + const f_number_unsigned_t length = structure->used + amount; - return private_f_int8ss_resize(int8ss->used + amount, int8ss); + if (length > structure->size) { + if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + + return private_f_int8ss_resize(structure->used + amount, structure); + } } return F_data_not; @@ -264,12 +214,12 @@ extern "C" { #endif // _di_f_int8ss_increase_by_ #ifndef _di_f_int8ss_resize_ - f_status_t f_int8ss_resize(const f_number_unsigned_t length, f_int8ss_t * const int8ss) { + f_status_t f_int8ss_resize(const f_number_unsigned_t length, f_int8ss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!int8ss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_int8ss_resize(length, int8ss); + return private_f_int8ss_resize(length, structure); } #endif // _di_f_int8ss_resize_ diff --git a/level_0/f_type_array/c/type_array/int8.h b/level_0/f_type_array/c/type_array/int8.h index 3718b65..067ce13 100644 --- a/level_0/f_type_array/c/type_array/int8.h +++ b/level_0/f_type_array/c/type_array/int8.h @@ -17,22 +17,24 @@ extern "C" { #endif /** - * Resize the int8s array. + * Resize the string int8s array. * * @param length * The new size to use. - * @param int8s - * The int8s array to resize. + * @param structure + * The string int8s array to resize. * * @return * F_none on success. * * 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_array_adjust(). + * + * @see f_memory_array_adjust() */ #ifndef _di_f_int8s_adjust_ - extern f_status_t f_int8s_adjust(const f_number_unsigned_t length, f_int8s_t * const int8s); + extern f_status_t f_int8s_adjust(const f_number_unsigned_t length, f_int8s_t * const structure); #endif // _di_f_int8s_adjust_ /** @@ -49,7 +51,9 @@ extern "C" { * * 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(). + * + * @see f_memory_array_increase() */ #ifndef _di_f_int8s_append_ extern f_status_t f_int8s_append(const int8_t source, f_int8s_t * const destination); @@ -69,14 +73,16 @@ extern "C" { * * 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() */ #ifndef _di_f_int8s_append_all_ extern f_status_t f_int8s_append_all(const f_int8s_t source, f_int8s_t * const destination); #endif // _di_f_int8s_append_all_ /** - * Resize the int8s array to a smaller size. + * Resize the string int8s array to a smaller size. * * This will resize making the array smaller based on (size - given length). * If the given length is too small, then the resize will fail. @@ -84,8 +90,8 @@ extern "C" { * * @param amount * A positive number representing how much to decimate the size by. - * @param int8s - * The int8s array to resize. + * @param structure + * The string int8s array to resize. * * @return * F_none on success. @@ -93,14 +99,16 @@ extern "C" { * * 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_array_decimate_by(). + * + * @see f_memory_array_decimate_by() */ #ifndef _di_f_int8s_decimate_by_ - extern f_status_t f_int8s_decimate_by(const f_number_unsigned_t amount, f_int8s_t * const int8s); + extern f_status_t f_int8s_decimate_by(const f_number_unsigned_t amount, f_int8s_t * const structure); #endif // _di_f_int8s_decimate_by_ /** - * Resize the int8s array to a smaller size. + * Resize the string int8s array to a smaller size. * * This will resize making the array smaller based on (size - given length). * If the given length is too small, then the resize will fail. @@ -108,8 +116,8 @@ extern "C" { * * @param amount * A positive number representing how much to decrease the size by. - * @param int8s - * The int8s array to resize. + * @param structure + * The string int8s array to resize. * * @return * F_none on success. @@ -117,14 +125,16 @@ extern "C" { * * 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_decrease_by(). + * + * @see f_memory_array_decrease_by() */ #ifndef _di_f_int8s_decrease_by_ - extern f_status_t f_int8s_decrease_by(const f_number_unsigned_t amount, f_int8s_t * const int8s); + extern f_status_t f_int8s_decrease_by(const f_number_unsigned_t amount, f_int8s_t * const structure); #endif // _di_f_int8s_decrease_by_ /** - * Increase the size of the int8s array, but only if necesary. + * Increase the size of the string int8s array, but only if necesary. * * 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. @@ -132,8 +142,8 @@ extern "C" { * @param step * The allocation step to use. * Must be greater than 0. - * @param int8s - * The int8s array to resize. + * @param structure + * The string int8s array to resize. * * @return * F_none on success. @@ -142,14 +152,16 @@ extern "C" { * F_array_too_large (with error bit) if the new array length is too large. * 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(). + * + * @see f_memory_array_increase() */ #ifndef _di_f_int8s_increase_ - extern f_status_t f_int8s_increase(const f_number_unsigned_t step, f_int8s_t * const int8s); + extern f_status_t f_int8s_increase(const f_number_unsigned_t step, f_int8s_t * const structure); #endif // _di_f_int8s_increase_ /** - * Resize the int8s array to a larger size. + * Resize the string int8s array 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). @@ -157,8 +169,8 @@ extern "C" { * * @param amount * A positive number representing how much to increase the size by. - * @param int8s - * The int8s array to resize. + * @param structure + * The string int8s array to resize. * * @return * F_none on success. @@ -167,49 +179,54 @@ extern "C" { * F_array_too_large (with error bit) if the new array length is too large. * 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() */ #ifndef _di_f_int8s_increase_by_ - extern f_status_t f_int8s_increase_by(const f_number_unsigned_t amount, f_int8s_t * const int8s); + extern f_status_t f_int8s_increase_by(const f_number_unsigned_t amount, f_int8s_t * const structure); #endif // _di_f_int8s_increase_by_ /** - * Resize the int8s array. + * Resize the string int8s array. * * @param length * The new size to use. - * @param int8s - * The int8s array to adjust. + * @param structure + * The string int8s array to adjust. * * @return * F_none on success. * * 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(). + * + * @see f_memory_array_resize() */ #ifndef _di_f_int8s_resize_ - extern f_status_t f_int8s_resize(const f_number_unsigned_t length, f_int8s_t * const int8s); + extern f_status_t f_int8s_resize(const f_number_unsigned_t length, f_int8s_t * const structure); #endif // _di_f_int8s_resize_ /** - * Resize the int8ss array. + * Resize the string int8ss array. * * @param length * The new size to use. - * @param int8ss - * The int8ss array to resize. + * @param structure + * The string int8ss array to resize. * * @return * F_none on success. * * 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() */ #ifndef _di_f_int8ss_adjust_ - extern f_status_t f_int8ss_adjust(const f_number_unsigned_t length, f_int8ss_t * const int8ss); + extern f_status_t f_int8ss_adjust(const f_number_unsigned_t length, f_int8ss_t * const structure); #endif // _di_f_int8ss_adjust_ /** @@ -226,7 +243,11 @@ extern "C" { * * 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(). + * Errors (with error bit) from: f_memory_array_increase_by(). + * + * @see f_memory_array_increase() + * @see f_memory_array_increase_by() */ #ifndef _di_f_int8ss_append_ extern f_status_t f_int8ss_append(const f_int8s_t source, f_int8ss_t * const destination); @@ -246,14 +267,16 @@ extern "C" { * * 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() */ #ifndef _di_f_int8ss_append_all_ extern f_status_t f_int8ss_append_all(const f_int8ss_t source, f_int8ss_t * const destination); #endif // _di_f_int8ss_append_all_ /** - * Resize the int8ss array to a smaller size. + * Resize the string int8ss array to a smaller size. * * This will resize making the array smaller based on (size - given length). * If the given length is too small, then the resize will fail. @@ -261,24 +284,24 @@ extern "C" { * * @param amount * A positive number representing how much to decimate the size by. - * @param int8ss - * The int8ss array to resize. + * @param structure + * The string int8ss array to resize. * * @return * F_none on success. - * F_data_not if amount is 0. * * 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() */ #ifndef _di_f_int8ss_decimate_by_ - extern f_status_t f_int8ss_decimate_by(const f_number_unsigned_t amount, f_int8ss_t * const int8ss); + extern f_status_t f_int8ss_decimate_by(const f_number_unsigned_t amount, f_int8ss_t * const structure); #endif // _di_f_int8ss_decimate_by_ /** - * Resize the int8ss array to a smaller size. + * Resize the string int8ss array to a smaller size. * * This will resize making the array smaller based on (size - given length). * If the given length is too small, then the resize will fail. @@ -286,24 +309,24 @@ extern "C" { * * @param amount * A positive number representing how much to decrease the size by. - * @param int8ss - * The int8ss array to resize. + * @param structure + * The string int8ss array to resize. * * @return * F_none on success. - * F_data_not if amount is 0. * * 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() */ #ifndef _di_f_int8ss_decrease_by_ - extern f_status_t f_int8ss_decrease_by(const f_number_unsigned_t amount, f_int8ss_t * const int8ss); + extern f_status_t f_int8ss_decrease_by(const f_number_unsigned_t amount, f_int8ss_t * const structure); #endif // _di_f_int8ss_decrease_by_ /** - * Increase the size of the int8ss array, but only if necessary. + * Increase the size of the string int8ss array, 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. @@ -311,8 +334,8 @@ extern "C" { * @param step * The allocation step to use. * Must be greater than 0. - * @param int8ss - * The int8ss array to resize. + * @param structure + * The string int8ss array to resize. * * @return * F_none on success. @@ -321,14 +344,16 @@ extern "C" { * F_array_too_large (with error bit) if the new array length is too large. * 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(). + * + * @see f_memory_array_resize() */ #ifndef _di_f_int8ss_increase_ - extern f_status_t f_int8ss_increase(const f_number_unsigned_t step, f_int8ss_t * const int8ss); + extern f_status_t f_int8ss_increase(const f_number_unsigned_t step, f_int8ss_t * const structure); #endif // _di_f_int8ss_increase_ /** - * Resize the int8ss array to a larger size. + * Resize the string int8ss array 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). @@ -336,8 +361,8 @@ extern "C" { * * @param amount * A positive number representing how much to increase the size by. - * @param int8ss - * The int8ss array to resize. + * @param structure + * The string int8ss array to resize. * * @return * F_none on success. @@ -346,30 +371,33 @@ extern "C" { * F_array_too_large (with error bit) if the new array length is too large. * 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(). + * + * @see f_memory_array_resize() */ #ifndef _di_f_int8ss_increase_by_ - extern f_status_t f_int8ss_increase_by(const f_number_unsigned_t amount, f_int8ss_t * const int8ss); + extern f_status_t f_int8ss_increase_by(const f_number_unsigned_t amount, f_int8ss_t * const structure); #endif // _di_f_int8ss_increase_by_ /** - * Resize the int8ss array. + * Resize the string int8ss array. * * @param length * The new size to use. - * @param int8ss - * The int8ss array to adjust. + * @param structure + * The string int8ss array to adjust. * * @return * F_none on success. * * 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() */ #ifndef _di_f_int8ss_resize_ - extern f_status_t f_int8ss_resize(const f_number_unsigned_t length, f_int8ss_t * const int8ss); + extern f_status_t f_int8ss_resize(const f_number_unsigned_t length, f_int8ss_t * const structure); #endif // _di_f_int8ss_resize_ #ifdef __cplusplus diff --git a/level_0/f_type_array/c/type_array/number_unsigned.c b/level_0/f_type_array/c/type_array/number_unsigned.c index e0a773f..c2cb885 100644 --- a/level_0/f_type_array/c/type_array/number_unsigned.c +++ b/level_0/f_type_array/c/type_array/number_unsigned.c @@ -7,12 +7,12 @@ extern "C" { #endif #ifndef _di_f_number_unsigneds_adjust_ - f_status_t f_number_unsigneds_adjust(const f_number_unsigned_t length, f_number_unsigneds_t * const lengths) { + f_status_t f_number_unsigneds_adjust(const f_number_unsigned_t length, f_number_unsigneds_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!lengths) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_number_unsigneds_adjust(length, lengths); + return f_memory_array_adjust(length, sizeof(f_number_unsigned_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_number_unsigneds_adjust_ @@ -22,14 +22,7 @@ extern "C" { if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (destination->used + 1 > destination->size) { - const f_status_t status = private_f_number_unsigneds_resize(destination->used + F_memory_default_allocation_small_d, destination); - if (F_status_is_error(status)) return status; - } - - destination->array[destination->used++] = source; - - return F_none; + return private_f_number_unsigneds_append(source, destination); } #endif // _di_f_number_unsigneds_append_ @@ -46,98 +39,62 @@ extern "C" { #endif // _di_f_number_unsigneds_append_all_ #ifndef _di_f_number_unsigneds_decimate_by_ - f_status_t f_number_unsigneds_decimate_by(const f_number_unsigned_t amount, f_number_unsigneds_t * const lengths) { + f_status_t f_number_unsigneds_decimate_by(const f_number_unsigned_t amount, f_number_unsigneds_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!lengths) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; - - if (lengths->size - amount > 0) { - return private_f_number_unsigneds_adjust(lengths->size - amount, lengths); - } - - return private_f_number_unsigneds_adjust(0, lengths); + return f_memory_array_decimate_by(amount, sizeof(f_number_unsigned_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_number_unsigneds_decimate_by_ #ifndef _di_f_number_unsigneds_decrease_by_ - f_status_t f_number_unsigneds_decrease_by(const f_number_unsigned_t amount, f_number_unsigneds_t * const lengths) { + f_status_t f_number_unsigneds_decrease_by(const f_number_unsigned_t amount, f_number_unsigneds_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!lengths) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; - - if (lengths->size - amount > 0) { - return private_f_number_unsigneds_resize(lengths->size - amount, lengths); - } - - return private_f_number_unsigneds_resize(0, lengths); + return f_memory_array_decrease_by(amount, sizeof(f_number_unsigned_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_number_unsigneds_decrease_by_ #ifndef _di_f_number_unsigneds_increase_ - f_status_t f_number_unsigneds_increase(const f_number_unsigned_t step, f_number_unsigneds_t * const lengths) { + f_status_t f_number_unsigneds_increase(const f_number_unsigned_t step, f_number_unsigneds_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!lengths) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (step && lengths->used + 1 > lengths->size) { - f_number_unsigned_t size = lengths->used + step; - - if (size > F_number_t_size_unsigned_d) { - if (lengths->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_number_unsigneds_resize(size, lengths); - } - - return F_data_not; + return f_memory_array_increase(step, sizeof(f_number_unsigned_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_number_unsigneds_increase_ #ifndef _di_f_number_unsigneds_increase_by_ - f_status_t f_number_unsigneds_increase_by(const f_number_unsigned_t amount, f_number_unsigneds_t * const lengths) { + f_status_t f_number_unsigneds_increase_by(const f_number_unsigned_t amount, f_number_unsigneds_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!lengths) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; - - if (lengths->used + amount > lengths->size) { - if (lengths->used + amount > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } - - return private_f_number_unsigneds_resize(lengths->used + amount, lengths); - } - - return F_data_not; + return f_memory_array_increase_by(amount, sizeof(f_number_unsigned_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_number_unsigneds_increase_by_ #ifndef _di_f_number_unsigneds_resize_ - f_status_t f_number_unsigneds_resize(const f_number_unsigned_t length, f_number_unsigneds_t * const lengths) { + f_status_t f_number_unsigneds_resize(const f_number_unsigned_t length, f_number_unsigneds_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!lengths) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_number_unsigneds_resize(length, lengths); + return f_memory_array_resize(length, sizeof(f_number_unsigned_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_number_unsigneds_resize_ #ifndef _di_f_number_unsignedss_adjust_ - f_status_t f_number_unsignedss_adjust(const f_number_unsigned_t length, f_number_unsignedss_t * const lengthss) { + f_status_t f_number_unsignedss_adjust(const f_number_unsigned_t length, f_number_unsignedss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!lengthss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_number_unsignedss_adjust(length, lengthss); + return private_f_number_unsignedss_adjust(length, structure); } #endif // _di_f_number_unsignedss_adjust_ @@ -149,12 +106,8 @@ extern "C" { if (!source.used) return F_data_not; - f_status_t status = F_none; - - if (destination->used + 1 > destination->size) { - status = private_f_number_unsignedss_resize(destination->used + F_memory_default_allocation_small_d, destination); - if (F_status_is_error(status)) return status; - } + f_status_t status = f_memory_array_increase(F_memory_default_allocation_small_d, sizeof(f_number_unsigneds_t), (void **) &destination->array, &destination->used, &destination->size); + if (F_status_is_error(status)) return status; status = private_f_number_unsigneds_append_all(source, &destination->array[destination->used]); if (F_status_is_error(status)) return status; @@ -173,12 +126,8 @@ extern "C" { if (!source.used) return F_data_not; - f_status_t status = F_none; - - if (destination->used + source.used > destination->size) { - status = private_f_number_unsignedss_resize(destination->used + source.used, destination); - if (F_status_is_error(status)) return status; - } + f_status_t status = f_memory_array_increase_by(source.used, sizeof(f_number_unsigneds_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->used) { @@ -195,55 +144,47 @@ extern "C" { #endif // _di_f_number_unsignedss_append_all_ #ifndef _di_f_number_unsignedss_decimate_by_ - f_status_t f_number_unsignedss_decimate_by(const f_number_unsigned_t amount, f_number_unsignedss_t * const lengthss) { + f_status_t f_number_unsignedss_decimate_by(const f_number_unsigned_t amount, f_number_unsignedss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!lengthss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - if (lengthss->size - amount > 0) { - return private_f_number_unsignedss_adjust(lengthss->size - amount, lengthss); - } - - return private_f_number_unsignedss_adjust(0, lengthss); + return private_f_number_unsignedss_adjust((structure->size - amount > 0) ? structure->size - amount : 0, structure); } #endif // _di_f_number_unsignedss_decimate_by_ #ifndef _di_f_number_unsignedss_decrease_by_ - f_status_t f_number_unsignedss_decrease_by(const f_number_unsigned_t amount, f_number_unsignedss_t * const lengthss) { + f_status_t f_number_unsignedss_decrease_by(const f_number_unsigned_t amount, f_number_unsignedss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!lengthss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - if (lengthss->size - amount > 0) { - return private_f_number_unsignedss_resize(lengthss->size - amount, lengthss); - } - - return private_f_number_unsignedss_resize(0, lengthss); + return private_f_number_unsignedss_resize((structure->size - amount > 0) ? structure->size - amount : 0, structure); } #endif // _di_f_number_unsignedss_decrease_by_ #ifndef _di_f_number_unsignedss_increase_ - f_status_t f_number_unsignedss_increase(const f_number_unsigned_t step, f_number_unsignedss_t * const lengthss) { + f_status_t f_number_unsignedss_increase(const f_number_unsigned_t step, f_number_unsignedss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!lengthss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (step && lengthss->used + 1 > lengthss->size) { - f_number_unsigned_t size = lengthss->used + step; + if (step && structure->used + 1 > structure->size) { + if (structure->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - if (size > F_number_t_size_unsigned_d) { - if (lengthss->used + 1 > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + f_number_unsigned_t length = structure->used + step; - size = F_number_t_size_unsigned_d; + if (length > F_number_t_size_unsigned_d) { + if (structure->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + + length = F_number_t_size_unsigned_d; } - return private_f_number_unsignedss_resize(size, lengthss); + return private_f_number_unsignedss_resize(length, structure); } return F_data_not; @@ -251,19 +192,21 @@ extern "C" { #endif // _di_f_number_unsignedss_increase_ #ifndef _di_f_number_unsignedss_increase_by_ - f_status_t f_number_unsignedss_increase_by(const f_number_unsigned_t amount, f_number_unsignedss_t * const lengthss) { + f_status_t f_number_unsignedss_increase_by(const f_number_unsigned_t amount, f_number_unsignedss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!lengthss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; + if (amount) { + if (structure->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - if (lengthss->used + amount > lengthss->size) { - if (lengthss->used + amount > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + const f_number_unsigned_t length = structure->used + amount; - return private_f_number_unsignedss_resize(lengthss->used + amount, lengthss); + if (length > structure->size) { + if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + + return private_f_number_unsignedss_resize(structure->used + amount, structure); + } } return F_data_not; @@ -271,12 +214,12 @@ extern "C" { #endif // _di_f_number_unsignedss_increase_by_ #ifndef _di_f_number_unsignedss_resize_ - f_status_t f_number_unsignedss_resize(const f_number_unsigned_t length, f_number_unsignedss_t * const lengthss) { + f_status_t f_number_unsignedss_resize(const f_number_unsigned_t length, f_number_unsignedss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!lengthss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_number_unsignedss_resize(length, lengthss); + return private_f_number_unsignedss_resize(length, structure); } #endif // _di_f_number_unsignedss_resize_ diff --git a/level_0/f_type_array/c/type_array/number_unsigned.h b/level_0/f_type_array/c/type_array/number_unsigned.h index a9696b9..f74e72a 100644 --- a/level_0/f_type_array/c/type_array/number_unsigned.h +++ b/level_0/f_type_array/c/type_array/number_unsigned.h @@ -17,31 +17,33 @@ extern "C" { #endif /** - * Resize the string lengths array. + * Resize the string number_unsigneds array. * * @param length * The new size to use. - * @param lengths - * The string lengths array to resize. + * @param structure + * The string number_unsigneds array to resize. * * @return * F_none on success. * * 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_array_adjust(). + * + * @see f_memory_array_adjust() */ #ifndef _di_f_number_unsigneds_adjust_ - extern f_status_t f_number_unsigneds_adjust(const f_number_unsigned_t length, f_number_unsigneds_t * const lengths); + extern f_status_t f_number_unsigneds_adjust(const f_number_unsigned_t length, f_number_unsigneds_t * const structure); #endif // _di_f_number_unsigneds_adjust_ /** - * Append the single source length onto the destination. + * Append the single source number_unsigned onto the destination. * * @param source - * The source length to append. + * The source number_unsigned to append. * @param destination - * The destination lengths the source is appended onto. + * The destination number_unsigneds the source is appended onto. * * @return * F_none on success. @@ -49,19 +51,21 @@ extern "C" { * * 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(). + * + * @see f_memory_array_increase() */ #ifndef _di_f_number_unsigneds_append_ extern f_status_t f_number_unsigneds_append(const f_number_unsigned_t source, f_number_unsigneds_t * const destination); #endif // _di_f_number_unsigneds_append_ /** - * Append the source lengths onto the destination. + * Append the source number_unsigneds onto the destination. * * @param source - * The source lengths to append. + * The source number_unsigneds to append. * @param destination - * The destination lengths the source is appended onto. + * The destination number_unsigneds the source is appended onto. * * @return * F_none on success. @@ -69,14 +73,16 @@ extern "C" { * * 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() */ #ifndef _di_f_number_unsigneds_append_all_ extern f_status_t f_number_unsigneds_append_all(const f_number_unsigneds_t source, f_number_unsigneds_t * const destination); #endif // _di_f_number_unsigneds_append_all_ /** - * Resize the string lengths array to a smaller size. + * Resize the string number_unsigneds array to a smaller size. * * This will resize making the array smaller based on (size - given length). * If the given length is too small, then the resize will fail. @@ -84,22 +90,25 @@ extern "C" { * * @param amount * A positive number representing how much to decimate the size by. - * @param lengths - * The string lengths array to resize. + * @param structure + * The string number_unsigneds array to resize. * * @return * F_none on success. + * F_data_not if amount is 0. * * 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_array_decimate_by(). + * + * @see f_memory_array_decimate_by() */ #ifndef _di_f_number_unsigneds_decimate_by_ - extern f_status_t f_number_unsigneds_decimate_by(const f_number_unsigned_t amount, f_number_unsigneds_t * const lengths); + extern f_status_t f_number_unsigneds_decimate_by(const f_number_unsigned_t amount, f_number_unsigneds_t * const structure); #endif // _di_f_number_unsigneds_decimate_by_ /** - * Resize the string lengths array to a smaller size. + * Resize the string number_unsigneds array to a smaller size. * * This will resize making the array smaller based on (size - given length). * If the given length is too small, then the resize will fail. @@ -107,22 +116,25 @@ extern "C" { * * @param amount * A positive number representing how much to decrease the size by. - * @param lengths - * The string lengths array to resize. + * @param structure + * The string number_unsigneds array to resize. * * @return * F_none on success. + * F_data_not if amount is 0. * * 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_decrease_by(). + * + * @see f_memory_array_decrease_by() */ #ifndef _di_f_number_unsigneds_decrease_by_ - extern f_status_t f_number_unsigneds_decrease_by(const f_number_unsigned_t amount, f_number_unsigneds_t * const lengths); + extern f_status_t f_number_unsigneds_decrease_by(const f_number_unsigned_t amount, f_number_unsigneds_t * const structure); #endif // _di_f_number_unsigneds_decrease_by_ /** - * Increase the size of the string lengths array, but only if necesary. + * Increase the size of the string number_unsigneds array, but only if necesary. * * 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. @@ -130,8 +142,8 @@ extern "C" { * @param step * The allocation step to use. * Must be greater than 0. - * @param lengths - * The string lengths array to resize. + * @param structure + * The string number_unsigneds array to resize. * * @return * F_none on success. @@ -140,14 +152,16 @@ extern "C" { * F_array_too_large (with error bit) if the new array length is too large. * 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(). + * + * @see f_memory_array_increase() */ #ifndef _di_f_number_unsigneds_increase_ - extern f_status_t f_number_unsigneds_increase(const f_number_unsigned_t step, f_number_unsigneds_t * const lengths); + extern f_status_t f_number_unsigneds_increase(const f_number_unsigned_t step, f_number_unsigneds_t * const structure); #endif // _di_f_number_unsigneds_increase_ /** - * Resize the string lengths array to a larger size. + * Resize the string number_unsigneds array 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). @@ -155,8 +169,8 @@ extern "C" { * * @param amount * A positive number representing how much to increase the size by. - * @param lengths - * The string lengths array to resize. + * @param structure + * The string number_unsigneds array to resize. * * @return * F_none on success. @@ -165,56 +179,61 @@ extern "C" { * F_array_too_large (with error bit) if the new array length is too large. * 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() */ #ifndef _di_f_number_unsigneds_increase_by_ - extern f_status_t f_number_unsigneds_increase_by(const f_number_unsigned_t amount, f_number_unsigneds_t * const lengths); + extern f_status_t f_number_unsigneds_increase_by(const f_number_unsigned_t amount, f_number_unsigneds_t * const structure); #endif // _di_f_number_unsigneds_increase_by_ /** - * Resize the string lengths array. + * Resize the string number_unsigneds array. * * @param length * The new size to use. - * @param lengths - * The string lengths array to adjust. + * @param structure + * The string number_unsigneds array to adjust. * * @return * F_none on success. * * 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(). + * + * @see f_memory_array_resize() */ #ifndef _di_f_number_unsigneds_resize_ - extern f_status_t f_number_unsigneds_resize(const f_number_unsigned_t length, f_number_unsigneds_t * const lengths); + extern f_status_t f_number_unsigneds_resize(const f_number_unsigned_t length, f_number_unsigneds_t * const structure); #endif // _di_f_number_unsigneds_resize_ /** - * Resize the string lengthss array. + * Resize the string number_unsignedss array. * * @param length * The new size to use. - * @param lengthss - * The string lengthss array to resize. + * @param structure + * The string number_unsignedss array to resize. * * @return * F_none on success. * * 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() */ #ifndef _di_f_number_unsignedss_adjust_ - extern f_status_t f_number_unsignedss_adjust(const f_number_unsigned_t length, f_number_unsignedss_t * const lengthss); + extern f_status_t f_number_unsignedss_adjust(const f_number_unsigned_t length, f_number_unsignedss_t * const structure); #endif // _di_f_number_unsignedss_adjust_ /** - * Append the single source lengths onto the destination. + * Append the single source number_unsigneds onto the destination. * * @param source - * The source lengths to append. + * The source number_unsigneds to append. * @param destination * The destination ranges the source is appended onto. * @@ -224,17 +243,21 @@ extern "C" { * * 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(). + * Errors (with error bit) from: f_memory_array_increase_by(). + * + * @see f_memory_array_increase() + * @see f_memory_array_increase_by() */ #ifndef _di_f_number_unsignedss_append_ extern f_status_t f_number_unsignedss_append(const f_number_unsigneds_t source, f_number_unsignedss_t * const destination); #endif // _di_f_number_unsignedss_append_ /** - * Append the source lengthss onto the destination. + * Append the source number_unsignedss onto the destination. * * @param source - * The source lengthss to append. + * The source number_unsignedss to append. * @param destination * The destination ranges the source is appended onto. * @@ -244,14 +267,16 @@ extern "C" { * * 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() */ #ifndef _di_f_number_unsignedss_append_all_ extern f_status_t f_number_unsignedss_append_all(const f_number_unsignedss_t source, f_number_unsignedss_t * const destination); #endif // _di_f_number_unsignedss_append_all_ /** - * Resize the string lengthss array to a smaller size. + * Resize the string number_unsignedss array to a smaller size. * * This will resize making the array smaller based on (size - given length). * If the given length is too small, then the resize will fail. @@ -259,24 +284,24 @@ extern "C" { * * @param amount * A positive number representing how much to decimate the size by. - * @param lengthss - * The string lengthss array to resize. + * @param structure + * The string number_unsignedss array to resize. * * @return * F_none on success. - * F_data_not if amount is 0. * * 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() */ #ifndef _di_f_number_unsignedss_decimate_by_ - extern f_status_t f_number_unsignedss_decimate_by(const f_number_unsigned_t amount, f_number_unsignedss_t * const lengthss); + extern f_status_t f_number_unsignedss_decimate_by(const f_number_unsigned_t amount, f_number_unsignedss_t * const structure); #endif // _di_f_number_unsignedss_decimate_by_ /** - * Resize the string lengthss array to a smaller size. + * Resize the string number_unsignedss array to a smaller size. * * This will resize making the array smaller based on (size - given length). * If the given length is too small, then the resize will fail. @@ -284,24 +309,24 @@ extern "C" { * * @param amount * A positive number representing how much to decrease the size by. - * @param lengthss - * The string lengthss array to resize. + * @param structure + * The string number_unsignedss array to resize. * * @return * F_none on success. - * F_data_not if amount is 0. * * 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() */ #ifndef _di_f_number_unsignedss_decrease_by_ - extern f_status_t f_number_unsignedss_decrease_by(const f_number_unsigned_t amount, f_number_unsignedss_t * const lengthss); + extern f_status_t f_number_unsignedss_decrease_by(const f_number_unsigned_t amount, f_number_unsignedss_t * const structure); #endif // _di_f_number_unsignedss_decrease_by_ /** - * Increase the size of the string lengthss array, but only if necessary. + * Increase the size of the string number_unsignedss array, 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. @@ -309,8 +334,8 @@ extern "C" { * @param step * The allocation step to use. * Must be greater than 0. - * @param lengthss - * The string lengthss array to resize. + * @param structure + * The string number_unsignedss array to resize. * * @return * F_none on success. @@ -319,14 +344,16 @@ extern "C" { * F_array_too_large (with error bit) if the new array length is too large. * 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(). + * + * @see f_memory_array_resize() */ #ifndef _di_f_number_unsignedss_increase_ - extern f_status_t f_number_unsignedss_increase(const f_number_unsigned_t step, f_number_unsignedss_t * const lengthss); + extern f_status_t f_number_unsignedss_increase(const f_number_unsigned_t step, f_number_unsignedss_t * const structure); #endif // _di_f_number_unsignedss_increase_ /** - * Resize the string lengthss array to a larger size. + * Resize the string number_unsignedss array 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). @@ -334,8 +361,8 @@ extern "C" { * * @param amount * A positive number representing how much to increase the size by. - * @param lengthss - * The string lengthss array to resize. + * @param structure + * The string number_unsignedss array to resize. * * @return * F_none on success. @@ -344,30 +371,33 @@ extern "C" { * F_array_too_large (with error bit) if the new array length is too large. * 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(). + * + * @see f_memory_array_resize() */ #ifndef _di_f_number_unsignedss_increase_by_ - extern f_status_t f_number_unsignedss_increase_by(const f_number_unsigned_t amount, f_number_unsignedss_t * const lengthss); + extern f_status_t f_number_unsignedss_increase_by(const f_number_unsigned_t amount, f_number_unsignedss_t * const structure); #endif // _di_f_number_unsignedss_increase_by_ /** - * Resize the string lengthss array. + * Resize the string number_unsignedss array. * * @param length * The new size to use. - * @param lengthss - * The string lengthss array to adjust. + * @param structure + * The string number_unsignedss array to adjust. * * @return * F_none on success. * * 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() */ #ifndef _di_f_number_unsignedss_resize_ - extern f_status_t f_number_unsignedss_resize(const f_number_unsigned_t length, f_number_unsignedss_t * const lengthss); + extern f_status_t f_number_unsignedss_resize(const f_number_unsigned_t length, f_number_unsignedss_t * const structure); #endif // _di_f_number_unsignedss_resize_ #ifdef __cplusplus 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 023534d..75580b7 100644 --- a/level_0/f_type_array/c/type_array/poll.c +++ b/level_0/f_type_array/c/type_array/poll.c @@ -8,12 +8,12 @@ extern "C" { #endif #ifndef _di_f_polls_adjust_ - f_status_t f_polls_adjust(const f_number_unsigned_t length, f_polls_t * const polls) { + f_status_t f_polls_adjust(const f_number_unsigned_t length, f_polls_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!polls) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_polls_adjust(length, polls); + return f_memory_array_adjust(length, sizeof(f_poll_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_polls_adjust_ @@ -40,94 +40,62 @@ extern "C" { #endif // _di_f_polls_append_all_ #ifndef _di_f_polls_decimate_by_ - f_status_t f_polls_decimate_by(const f_number_unsigned_t amount, f_polls_t * const polls) { + f_status_t f_polls_decimate_by(const f_number_unsigned_t amount, f_polls_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!polls) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; - if (polls->size - amount > 0) return private_f_polls_adjust(polls->size - amount, polls); - - return private_f_polls_adjust(0, polls); + return f_memory_array_decimate_by(amount, sizeof(f_poll_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_polls_decimate_by_ #ifndef _di_f_polls_decrease_by_ - f_status_t f_polls_decrease_by(const f_number_unsigned_t amount, f_polls_t * const polls) { + f_status_t f_polls_decrease_by(const f_number_unsigned_t amount, f_polls_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!polls) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; - if (polls->size - amount > 0) return private_f_polls_resize(polls->size - amount, polls); - - return private_f_polls_resize(0, polls); + return f_memory_array_decrease_by(amount, sizeof(f_poll_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_polls_decrease_by_ #ifndef _di_f_polls_increase_ - f_status_t f_polls_increase(const f_number_unsigned_t step, f_polls_t * const polls) { + f_status_t f_polls_increase(const f_number_unsigned_t step, f_polls_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!polls) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #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) { - if (polls->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_polls_resize(size, polls); - } - - return F_data_not; + return f_memory_array_increase(step, sizeof(f_poll_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_polls_increase_ #ifndef _di_f_polls_increase_by_ - f_status_t f_polls_increase_by(const f_number_unsigned_t amount, f_polls_t * const polls) { + f_status_t f_polls_increase_by(const f_number_unsigned_t amount, f_polls_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!polls) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (amount) { - if (polls->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - - const f_number_unsigned_t length = polls->used + amount; - - 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; + return f_memory_array_increase_by(amount, sizeof(f_poll_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_polls_increase_by_ #ifndef _di_f_polls_resize_ - f_status_t f_polls_resize(const f_number_unsigned_t length, f_polls_t * const polls) { + f_status_t f_polls_resize(const f_number_unsigned_t length, f_polls_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!polls) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_polls_resize(length, polls); + return f_memory_array_resize(length, sizeof(f_poll_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_polls_resize_ #ifndef _di_f_pollss_adjust_ - f_status_t f_pollss_adjust(const f_number_unsigned_t length, f_pollss_t * const pollss) { + f_status_t f_pollss_adjust(const f_number_unsigned_t length, f_pollss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!pollss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_pollss_adjust(length, pollss); + return private_f_pollss_adjust(length, structure); } #endif // _di_f_pollss_adjust_ @@ -139,12 +107,8 @@ extern "C" { if (!source.used) return F_data_not; - f_status_t status = F_none; - - if (destination->used + 1 > destination->size) { - status = private_f_pollss_resize(destination->used + F_memory_default_allocation_small_d, destination); - if (F_status_is_error(status)) return status; - } + f_status_t status = f_memory_array_increase(F_memory_default_allocation_small_d, sizeof(f_polls_t), (void **) &destination->array, &destination->used, &destination->size); + if (F_status_is_error(status)) return status; status = private_f_polls_append_all(source, &destination->array[destination->used]); if (F_status_is_error(status)) return status; @@ -163,12 +127,8 @@ extern "C" { if (!source.used) return F_data_not; - f_status_t status = F_none; - - if (destination->used + source.used > destination->size) { - status = private_f_pollss_resize(destination->used + source.used, destination); - if (F_status_is_error(status)) return status; - } + f_status_t status = f_memory_array_increase_by(source.used, sizeof(f_polls_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->used) { @@ -185,49 +145,47 @@ extern "C" { #endif // _di_f_pollss_append_all_ #ifndef _di_f_pollss_decimate_by_ - f_status_t f_pollss_decimate_by(const f_number_unsigned_t amount, f_pollss_t * const pollss) { + f_status_t f_pollss_decimate_by(const f_number_unsigned_t amount, f_pollss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!pollss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - if (pollss->size - amount > 0) return private_f_pollss_adjust(pollss->size - amount, pollss); - return private_f_pollss_adjust(0, pollss); + return private_f_pollss_adjust((structure->size - amount > 0) ? structure->size - amount : 0, structure); } #endif // _di_f_pollss_decimate_by_ #ifndef _di_f_pollss_decrease_by_ - f_status_t f_pollss_decrease_by(const f_number_unsigned_t amount, f_pollss_t * const pollss) { + f_status_t f_pollss_decrease_by(const f_number_unsigned_t amount, f_pollss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!pollss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - if (pollss->size - amount > 0) return private_f_pollss_resize(pollss->size - amount, pollss); - return private_f_pollss_resize(0, pollss); + return private_f_pollss_resize((structure->size - amount > 0) ? structure->size - amount : 0, structure); } #endif // _di_f_pollss_decrease_by_ #ifndef _di_f_pollss_increase_ - f_status_t f_pollss_increase(const f_number_unsigned_t step, f_pollss_t * const pollss) { + f_status_t f_pollss_increase(const f_number_unsigned_t step, f_pollss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!pollss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #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); + if (step && structure->used + 1 > structure->size) { + if (structure->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - f_number_unsigned_t size = pollss->used + step; + f_number_unsigned_t length = structure->used + step; - if (size > F_number_t_size_unsigned_d) { - if (pollss->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + if (length > F_number_t_size_unsigned_d) { + if (structure->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - size = F_number_t_size_unsigned_d; + length = F_number_t_size_unsigned_d; } - return private_f_pollss_resize(size, pollss); + return private_f_pollss_resize(length, structure); } return F_data_not; @@ -235,20 +193,20 @@ extern "C" { #endif // _di_f_pollss_increase_ #ifndef _di_f_pollss_increase_by_ - f_status_t f_pollss_increase_by(const f_number_unsigned_t amount, f_pollss_t * const pollss) { + f_status_t f_pollss_increase_by(const f_number_unsigned_t amount, f_pollss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!pollss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (amount) { - if (pollss->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + if (structure->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - const f_number_unsigned_t length = pollss->used + amount; + const f_number_unsigned_t length = structure->used + amount; - if (length > pollss->size) { + if (length > structure->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 private_f_pollss_resize(structure->used + amount, structure); } } @@ -257,12 +215,12 @@ extern "C" { #endif // _di_f_pollss_increase_by_ #ifndef _di_f_pollss_resize_ - f_status_t f_pollss_resize(const f_number_unsigned_t length, f_pollss_t * const pollss) { + f_status_t f_pollss_resize(const f_number_unsigned_t length, f_pollss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!pollss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_pollss_resize(length, pollss); + return private_f_pollss_resize(length, structure); } #endif // _di_f_pollss_resize_ diff --git a/level_0/f_type_array/c/type_array/poll.h b/level_0/f_type_array/c/type_array/poll.h index 964cc02..29d36c9 100644 --- a/level_0/f_type_array/c/type_array/poll.h +++ b/level_0/f_type_array/c/type_array/poll.h @@ -21,7 +21,7 @@ extern "C" { * * @param length * The new size to use. - * @param polls + * @param structure * The string polls array to resize. * * @return @@ -29,10 +29,12 @@ extern "C" { * * 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_array_adjust(). + * + * @see f_memory_array_adjust() */ #ifndef _di_f_polls_adjust_ - extern f_status_t f_polls_adjust(const f_number_unsigned_t length, f_polls_t * const polls); + extern f_status_t f_polls_adjust(const f_number_unsigned_t length, f_polls_t * const structure); #endif // _di_f_polls_adjust_ /** @@ -49,7 +51,9 @@ extern "C" { * * 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(). + * + * @see f_memory_array_increase() */ #ifndef _di_f_polls_append_ extern f_status_t f_polls_append(const f_poll_t source, f_polls_t * const destination); @@ -69,7 +73,9 @@ extern "C" { * * 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() */ #ifndef _di_f_polls_append_all_ extern f_status_t f_polls_append_all(const f_polls_t source, f_polls_t * const destination); @@ -84,7 +90,7 @@ extern "C" { * * @param amount * A positive number representing how much to decimate the size by. - * @param polls + * @param structure * The string polls array to resize. * * @return @@ -93,10 +99,12 @@ extern "C" { * * 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_array_decimate_by(). + * + * @see f_memory_array_decimate_by() */ #ifndef _di_f_polls_decimate_by_ - extern f_status_t f_polls_decimate_by(const f_number_unsigned_t amount, f_polls_t * const polls); + extern f_status_t f_polls_decimate_by(const f_number_unsigned_t amount, f_polls_t * const structure); #endif // _di_f_polls_decimate_by_ /** @@ -108,7 +116,7 @@ extern "C" { * * @param amount * A positive number representing how much to decrease the size by. - * @param polls + * @param structure * The string polls array to resize. * * @return @@ -117,10 +125,12 @@ extern "C" { * * 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_decrease_by(). + * + * @see f_memory_array_decrease_by() */ #ifndef _di_f_polls_decrease_by_ - extern f_status_t f_polls_decrease_by(const f_number_unsigned_t amount, f_polls_t * const polls); + extern f_status_t f_polls_decrease_by(const f_number_unsigned_t amount, f_polls_t * const structure); #endif // _di_f_polls_decrease_by_ /** @@ -132,7 +142,7 @@ extern "C" { * @param step * The allocation step to use. * Must be greater than 0. - * @param polls + * @param structure * The string polls array to resize. * * @return @@ -142,10 +152,12 @@ extern "C" { * F_array_too_large (with error bit) if the new array length is too large. * 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(). + * + * @see f_memory_array_increase() */ #ifndef _di_f_polls_increase_ - extern f_status_t f_polls_increase(const f_number_unsigned_t step, f_polls_t * const polls); + extern f_status_t f_polls_increase(const f_number_unsigned_t step, f_polls_t * const structure); #endif // _di_f_polls_increase_ /** @@ -157,7 +169,7 @@ extern "C" { * * @param amount * A positive number representing how much to increase the size by. - * @param polls + * @param structure * The string polls array to resize. * * @return @@ -167,10 +179,12 @@ extern "C" { * F_array_too_large (with error bit) if the new array length is too large. * 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() */ #ifndef _di_f_polls_increase_by_ - extern f_status_t f_polls_increase_by(const f_number_unsigned_t amount, f_polls_t * const polls); + extern f_status_t f_polls_increase_by(const f_number_unsigned_t amount, f_polls_t * const structure); #endif // _di_f_polls_increase_by_ /** @@ -178,7 +192,7 @@ extern "C" { * * @param length * The new size to use. - * @param polls + * @param structure * The string polls array to adjust. * * @return @@ -186,10 +200,12 @@ extern "C" { * * 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(). + * + * @see f_memory_array_resize() */ #ifndef _di_f_polls_resize_ - extern f_status_t f_polls_resize(const f_number_unsigned_t length, f_polls_t * const polls); + extern f_status_t f_polls_resize(const f_number_unsigned_t length, f_polls_t * const structure); #endif // _di_f_polls_resize_ /** @@ -197,7 +213,7 @@ extern "C" { * * @param length * The new size to use. - * @param pollss + * @param structure * The string pollss array to resize. * * @return @@ -205,11 +221,12 @@ extern "C" { * * 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() */ #ifndef _di_f_pollss_adjust_ - extern f_status_t f_pollss_adjust(const f_number_unsigned_t length, f_pollss_t * const pollss); + extern f_status_t f_pollss_adjust(const f_number_unsigned_t length, f_pollss_t * const structure); #endif // _di_f_pollss_adjust_ /** @@ -226,7 +243,11 @@ extern "C" { * * 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(). + * Errors (with error bit) from: f_memory_array_increase_by(). + * + * @see f_memory_array_increase() + * @see f_memory_array_increase_by() */ #ifndef _di_f_pollss_append_ extern f_status_t f_pollss_append(const f_polls_t source, f_pollss_t * const destination); @@ -246,7 +267,9 @@ extern "C" { * * 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() */ #ifndef _di_f_pollss_append_all_ extern f_status_t f_pollss_append_all(const f_pollss_t source, f_pollss_t * const destination); @@ -261,20 +284,20 @@ extern "C" { * * @param amount * A positive number representing how much to decimate the size by. - * @param pollss + * @param structure * The string pollss array to resize. * * @return * F_none on success. - * F_data_not if amount is 0. * * 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() */ #ifndef _di_f_pollss_decimate_by_ - extern f_status_t f_pollss_decimate_by(const f_number_unsigned_t amount, f_pollss_t * const pollss); + extern f_status_t f_pollss_decimate_by(const f_number_unsigned_t amount, f_pollss_t * const structure); #endif // _di_f_pollss_decimate_by_ /** @@ -286,20 +309,20 @@ extern "C" { * * @param amount * A positive number representing how much to decrease the size by. - * @param pollss + * @param structure * The string pollss array to resize. * * @return * F_none on success. - * F_data_not if amount is 0. * * 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() */ #ifndef _di_f_pollss_decrease_by_ - extern f_status_t f_pollss_decrease_by(const f_number_unsigned_t amount, f_pollss_t * const pollss); + extern f_status_t f_pollss_decrease_by(const f_number_unsigned_t amount, f_pollss_t * const structure); #endif // _di_f_pollss_decrease_by_ /** @@ -311,7 +334,7 @@ extern "C" { * @param step * The allocation step to use. * Must be greater than 0. - * @param pollss + * @param structure * The string pollss array to resize. * * @return @@ -321,10 +344,12 @@ extern "C" { * F_array_too_large (with error bit) if the new array length is too large. * 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(). + * + * @see f_memory_array_resize() */ #ifndef _di_f_pollss_increase_ - extern f_status_t f_pollss_increase(const f_number_unsigned_t step, f_pollss_t * const pollss); + extern f_status_t f_pollss_increase(const f_number_unsigned_t step, f_pollss_t * const structure); #endif // _di_f_pollss_increase_ /** @@ -336,7 +361,7 @@ extern "C" { * * @param amount * A positive number representing how much to increase the size by. - * @param pollss + * @param structure * The string pollss array to resize. * * @return @@ -346,10 +371,12 @@ extern "C" { * F_array_too_large (with error bit) if the new array length is too large. * 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(). + * + * @see f_memory_array_resize() */ #ifndef _di_f_pollss_increase_by_ - extern f_status_t f_pollss_increase_by(const f_number_unsigned_t amount, f_pollss_t * const pollss); + extern f_status_t f_pollss_increase_by(const f_number_unsigned_t amount, f_pollss_t * const structure); #endif // _di_f_pollss_increase_by_ /** @@ -357,7 +384,7 @@ extern "C" { * * @param length * The new size to use. - * @param pollss + * @param structure * The string pollss array to adjust. * * @return @@ -365,11 +392,12 @@ extern "C" { * * 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() */ #ifndef _di_f_pollss_resize_ - extern f_status_t f_pollss_resize(const f_number_unsigned_t length, f_pollss_t * const pollss); + extern f_status_t f_pollss_resize(const f_number_unsigned_t length, f_pollss_t * const structure); #endif // _di_f_pollss_resize_ #ifdef __cplusplus diff --git a/level_0/f_type_array/c/type_array/private-cell.c b/level_0/f_type_array/c/type_array/private-cell.c index b581a8c..d1209b5 100644 --- a/level_0/f_type_array/c/type_array/private-cell.c +++ b/level_0/f_type_array/c/type_array/private-cell.c @@ -5,32 +5,15 @@ extern "C" { #endif -#if !defined(_di_f_cells_adjust_) || !defined(_di_f_cells_decimate_by_) - f_status_t private_f_cells_adjust(const f_number_unsigned_t length, f_cells_t * const cells) { - - const f_status_t status = f_memory_adjust(cells->size, length, sizeof(f_cell_t), (void **) & cells->array); - if (F_status_is_error(status)) return status; - - cells->size = length; - - if (cells->used > cells->size) { - cells->used = length; - } - - return F_none; - } -#endif // !defined(_di_f_cells_adjust_) || !defined(_di_f_cells_decimate_by_) - #if !defined(_di_f_cells_append_) || !defined(_di_f_cellss_append_) extern f_status_t private_f_cells_append(const f_cell_t source, f_cells_t * const destination) { - if (destination->used + 1 > destination->size) { - const f_status_t status = private_f_cells_resize(destination->used + F_memory_default_allocation_small_d, destination); + { + const f_status_t status = f_memory_array_increase(F_memory_default_allocation_small_d, sizeof(f_cell_t), (void **) &destination->array, &destination->used, &destination->size); if (F_status_is_error(status)) return status; } - destination->array[destination->used].row = source.row; - destination->array[destination->used++].column = source.column; + destination->array[destination->used++] = source; return F_none; } @@ -39,8 +22,8 @@ extern "C" { #if !defined(_di_f_cells_append_) || !defined(_di_f_cells_append_all_) || !defined(_di_f_cellss_append_all_) extern f_status_t private_f_cells_append_all(const f_cells_t source, f_cells_t * const destination) { - if (destination->used + source.used > destination->size) { - const f_status_t status = private_f_cells_resize(destination->used + source.used, destination); + { + const f_status_t status = f_memory_array_increase_by(source.used, sizeof(f_cell_t), (void **) &destination->array, &destination->used, &destination->size); if (F_status_is_error(status)) return status; } @@ -54,73 +37,33 @@ extern "C" { } #endif // !defined(_di_f_cells_append_) || !defined(_di_f_cells_append_all_) || !defined(_di_f_cellss_append_all_) -#if !defined(_di_f_cells_resize_) || !defined(_di_f_cells_append_) || !defined(_di_f_cells_decrease_by_) || !defined(_di_f_cellss_append_) - f_status_t private_f_cells_resize(const f_number_unsigned_t length, f_cells_t * const cells) { - - const f_status_t status = f_memory_resize(cells->size, length, sizeof(f_cell_t), (void **) & cells->array); - if (F_status_is_error(status)) return status; - - cells->size = length; - - if (cells->used > cells->size) { - cells->used = length; - } - - return F_none; - } -#endif // !defined(_di_f_cells_resize_) || !defined(_di_f_cells_append_) || !defined(_di_f_cells_decrease_by_) || !defined(_di_f_cellss_append_) - #if !defined(_di_f_cellss_adjust_) || !defined(_di_f_cellss_decimate_by_) - f_status_t private_f_cellss_adjust(const f_number_unsigned_t length, f_cellss_t * const cellss) { + f_status_t private_f_cellss_adjust(const f_number_unsigned_t length, f_cellss_t * const structure) { f_status_t status = F_none; - for (f_number_unsigned_t i = length; i < cellss->size; ++i) { + for (f_number_unsigned_t i = length; i < structure->size; ++i) { - status = f_memory_destroy(cellss->array[i].size, sizeof(f_cells_t), (void **) & cellss->array[i].array); + status = f_memory_array_adjust(0, sizeof(f_cell_t), (void **) &structure->array[i].array, &structure->array[i].used, &structure->array[i].size); if (F_status_is_error(status)) return status; - - cellss->array[i].size = 0; - cellss->array[i].used = 0; } // for - status = f_memory_adjust(cellss->size, length, sizeof(f_cells_t), (void **) & cellss->array); - if (F_status_is_error(status)) return status; - - cellss->size = length; - - if (cellss->used > cellss->size) { - cellss->used = length; - } - - return F_none; + return f_memory_array_adjust(length, sizeof(f_cells_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // !defined(_di_f_cellss_adjust_) || !defined(_di_f_cellss_decimate_by_) #if !defined(_di_f_cellss_decrease_by_) || !defined(_di_f_cellss_increase_) || !defined(_di_f_cellss_increase_by_) || !defined(_di_f_cellss_resize_) - f_status_t private_f_cellss_resize(const f_number_unsigned_t length, f_cellss_t * const cellss) { + f_status_t private_f_cellss_resize(const f_number_unsigned_t length, f_cellss_t * const structure) { f_status_t status = F_none; - for (f_number_unsigned_t i = length; i < cellss->size; ++i) { + for (f_number_unsigned_t i = length; i < structure->size; ++i) { - status = f_memory_delete(cellss->array[i].size, sizeof(f_cells_t), (void **) & cellss->array[i].array); + status = f_memory_array_resize(0, sizeof(f_cell_t), (void **) &structure->array[i].array, &structure->array[i].used, &structure->array[i].size); if (F_status_is_error(status)) return status; - - cellss->array[i].size = 0; - cellss->array[i].used = 0; } // for - status = f_memory_resize(cellss->size, length, sizeof(f_cells_t), (void **) & cellss->array); - if (F_status_is_error(status)) return status; - - cellss->size = length; - - if (cellss->used > cellss->size) { - cellss->used = length; - } - - return F_none; + return f_memory_array_resize(length, sizeof(f_cells_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // !defined(_di_f_cellss_decrease_by_) || !defined(_di_f_cellss_increase_) || !defined(_di_f_cellss_increase_by_) || !defined(_di_f_cellss_resize_) diff --git a/level_0/f_type_array/c/type_array/private-cell.h b/level_0/f_type_array/c/type_array/private-cell.h index 466d75b..fd15506 100644 --- a/level_0/f_type_array/c/type_array/private-cell.h +++ b/level_0/f_type_array/c/type_array/private-cell.h @@ -16,29 +16,6 @@ extern "C" { #endif /** - * Private implementation for resizing the cells array. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The length to adjust to. - * @param cells - * The cells array to adjust. - * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + 1 <= size). - * - * Errors (with error bit) from: f_memory_adjust(). - * - * @see f_cells_adjust() - * @see f_cells_decimate_by() - */ -#if !defined(_di_f_cells_adjust_) || !defined(_di_f_cells_decimate_by_) - extern f_status_t private_f_cells_adjust(const f_number_unsigned_t length, f_cells_t * const cells) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_cells_adjust_) || !defined(_di_f_cells_decimate_by_) - -/** * Private implementation for appending the cell array. * * Intended to be shared to each of the different implementation variations. @@ -51,9 +28,10 @@ extern "C" { * @return * F_none on success. * - * Errors (with error bit) from: f_memory_resize(). + * Errors (with error bit) from: f_memory_array_increase(). + * + * @see f_memory_array_increase() * - * @see f_memory_resize() * @see f_cells_append() * @see f_cellss_append() */ @@ -74,9 +52,10 @@ extern "C" { * @return * F_none on success. * - * 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_cells_append_all() * @see f_cellss_append() * @see f_cellss_append_all() @@ -86,38 +65,13 @@ extern "C" { #endif // !defined(_di_f_cells_append_) || !defined(_di_f_cells_append_all_) || !defined(_di_f_cellss_append_all_) /** - * Private implementation for resizing the cells array. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The length to adjust to. - * @param cells - * The cells array to adjust. - * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + 1 <= size). - * - * Errors (with error bit) from: f_memory_resize(). - * - * @see f_cells_resize() - * @see f_cells_append() - * @see f_cells_decrease_by() - * @see f_cellss_append() - */ -#if !defined(_di_f_cells_resize_) || !defined(_di_f_cells_append_) || !defined(_di_f_cells_decrease_by_) || !defined(_di_f_cellss_append_) - extern f_status_t private_f_cells_resize(const f_number_unsigned_t length, f_cells_t * const cells) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_cells_resize_) || !defined(_di_f_cells_append_) || !defined(_di_f_cells_decrease_by_) || !defined(_di_f_cellss_append_) - -/** * Private implementation for resizing the cellss array. * * Intended to be shared to each of the different implementation variations. * * @param length * The length to adjust to. - * @param cellss + * @param structure * The cellss array to adjust. * * @return @@ -128,14 +82,15 @@ 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_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_cellss_adjust() * @see f_cellss_decimate_by() */ #if !defined(_di_f_cellss_adjust_) || !defined(_di_f_cellss_decimate_by_) - extern f_status_t private_f_cellss_adjust(const f_number_unsigned_t length, f_cellss_t * const cellss) F_attribute_visibility_internal_d; + extern f_status_t private_f_cellss_adjust(const f_number_unsigned_t length, f_cellss_t * const structure) F_attribute_visibility_internal_d; #endif // !defined(_di_f_cellss_adjust_) || !defined(_di_f_cellss_decimate_by_) /** @@ -145,7 +100,7 @@ extern "C" { * * @param length * The length to resize to. - * @param cellss + * @param structure * The cellss array to resize. * * @return @@ -156,8 +111,9 @@ 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_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_cellss_decrease_by() * @see f_cellss_increase() @@ -165,7 +121,7 @@ extern "C" { * @see f_cellss_resize() */ #if !defined(_di_f_cellss_decrease_by_) || !defined(_di_f_cellss_increase_) || !defined(_di_f_cellss_increase_by_) || !defined(_di_f_cellss_resize_) - extern f_status_t private_f_cellss_resize(const f_number_unsigned_t length, f_cellss_t * const cellss) F_attribute_visibility_internal_d; + extern f_status_t private_f_cellss_resize(const f_number_unsigned_t length, f_cellss_t * const structure) F_attribute_visibility_internal_d; #endif // !defined(_di_f_cellss_decrease_by_) || !defined(_di_f_cellss_increase_) || !defined(_di_f_cellss_increase_by_) || !defined(_di_f_cellss_resize_) #ifdef __cplusplus diff --git a/level_0/f_type_array/c/type_array/private-file.c b/level_0/f_type_array/c/type_array/private-file.c index ecc5b3b..5aacf0c 100644 --- a/level_0/f_type_array/c/type_array/private-file.c +++ b/level_0/f_type_array/c/type_array/private-file.c @@ -6,27 +6,11 @@ extern "C" { #endif -#if !defined(_di_f_files_adjust_) || !defined(_di_f_files_decimate_by_) - f_status_t private_f_files_adjust(const f_number_unsigned_t length, f_files_t * const files) { - - const f_status_t status = f_memory_adjust(files->size, length, sizeof(f_file_t), (void **) & files->array); - if (F_status_is_error(status)) return status; - - files->size = length; - - if (files->used > files->size) { - files->used = length; - } - - return F_none; - } -#endif // !defined(_di_f_files_adjust_) || !defined(_di_f_files_decimate_by_) - #if !defined(_di_f_files_append_) || !defined(_di_f_filess_append_) extern f_status_t private_f_files_append(const f_file_t source, f_files_t * const destination) { - if (destination->used + 1 > destination->size) { - const f_status_t status = private_f_files_resize(destination->used + F_memory_default_allocation_small_d, destination); + { + const f_status_t status = f_memory_array_increase(F_memory_default_allocation_small_d, sizeof(f_file_t), (void **) &destination->array, &destination->used, &destination->size); if (F_status_is_error(status)) return status; } @@ -39,8 +23,8 @@ extern "C" { #if !defined(_di_f_files_append_) || !defined(_di_f_files_append_all_) || !defined(_di_f_filess_append_all_) extern f_status_t private_f_files_append_all(const f_files_t source, f_files_t * const destination) { - if (destination->used + source.used > destination->size) { - const f_status_t status = private_f_files_resize(destination->used + source.used, destination); + { + const f_status_t status = f_memory_array_increase_by(source.used, sizeof(f_file_t), (void **) &destination->array, &destination->used, &destination->size); if (F_status_is_error(status)) return status; } @@ -52,73 +36,33 @@ extern "C" { } #endif // !defined(_di_f_files_append_) || !defined(_di_f_files_append_all_) || !defined(_di_f_filess_append_all_) -#if !defined(_di_f_files_append_) || !defined(_di_f_files_append_all_) || !defined(_di_f_files_decrease_by_) || !defined(_di_f_files_increase_) || !defined(_di_f_files_increase_by_) || !defined(_di_f_files_resize_) || !defined(_di_f_filess_append_) || !defined(_di_f_filess_append_all_) - f_status_t private_f_files_resize(const f_number_unsigned_t length, f_files_t * const files) { - - const f_status_t status = f_memory_resize(files->size, length, sizeof(f_file_t), (void **) & files->array); - if (F_status_is_error(status)) return status; - - files->size = length; - - if (files->used > files->size) { - files->used = length; - } - - return F_none; - } -#endif // !defined(_di_f_files_append_) || !defined(_di_f_files_append_all_) || !defined(_di_f_files_decrease_by_) || !defined(_di_f_files_increase_) || !defined(_di_f_files_increase_by_) || !defined(_di_f_files_resize_) || !defined(_di_f_filess_append_) || !defined(_di_f_filess_append_all_) - #if !defined(_di_f_filess_adjust_) || !defined(_di_f_filess_decimate_by_) - f_status_t private_f_filess_adjust(const f_number_unsigned_t length, f_filess_t * const filess) { + f_status_t private_f_filess_adjust(const f_number_unsigned_t length, f_filess_t * const structure) { f_status_t status = F_none; - for (f_number_unsigned_t i = length; i < filess->size; ++i) { + for (f_number_unsigned_t i = length; i < structure->size; ++i) { - status = f_memory_destroy(filess->array[i].size, sizeof(f_files_t), (void **) & filess->array[i].array); + status = f_memory_array_adjust(0, sizeof(f_file_t), (void **) &structure->array[i].array, &structure->array[i].used, &structure->array[i].size); if (F_status_is_error(status)) return status; - - filess->array[i].size = 0; - filess->array[i].used = 0; } // for - status = f_memory_adjust(filess->size, length, sizeof(f_files_t), (void **) & filess->array); - if (F_status_is_error(status)) return status; - - filess->size = length; - - if (filess->used > filess->size) { - filess->used = length; - } - - return F_none; + return f_memory_array_adjust(length, sizeof(f_files_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // !defined(_di_f_filess_adjust_) || !defined(_di_f_filess_decimate_by_) #if !defined(_di_f_filess_decrease_by_) || !defined(_di_f_filess_increase_) || !defined(_di_f_filess_increase_by_) || !defined(_di_f_filess_resize_) - f_status_t private_f_filess_resize(const f_number_unsigned_t length, f_filess_t * const filess) { + f_status_t private_f_filess_resize(const f_number_unsigned_t length, f_filess_t * const structure) { f_status_t status = F_none; - for (f_number_unsigned_t i = length; i < filess->size; ++i) { + for (f_number_unsigned_t i = length; i < structure->size; ++i) { - status = f_memory_delete(filess->array[i].size, sizeof(f_files_t), (void **) & filess->array[i].array); + status = f_memory_array_resize(0, sizeof(f_file_t), (void **) &structure->array[i].array, &structure->array[i].used, &structure->array[i].size); if (F_status_is_error(status)) return status; - - filess->array[i].size = 0; - filess->array[i].used = 0; } // for - status = f_memory_resize(filess->size, length, sizeof(f_files_t), (void **) & filess->array); - if (F_status_is_error(status)) return status; - - filess->size = length; - - if (filess->used > filess->size) { - filess->used = length; - } - - return F_none; + return f_memory_array_resize(length, sizeof(f_files_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // !defined(_di_f_filess_decrease_by_) || !defined(_di_f_filess_increase_) || !defined(_di_f_filess_increase_by_) || !defined(_di_f_filess_resize_) diff --git a/level_0/f_type_array/c/type_array/private-file.h b/level_0/f_type_array/c/type_array/private-file.h index b932053..a9fcf2f 100644 --- a/level_0/f_type_array/c/type_array/private-file.h +++ b/level_0/f_type_array/c/type_array/private-file.h @@ -22,20 +22,22 @@ extern "C" { * * @param length * The length to adjust to. - * @param files + * @param structure * The files array to adjust. * * @return * F_none on success. * F_data_not on success, but there is no reason to increase size (used + 1 <= size). * - * Errors (with error bit) from: f_memory_adjust(). + * Errors (with error bit) from: f_memory_array_increase(). + * + * @see f_memory_array_increase() * * @see f_files_adjust() * @see f_files_decimate_by() */ #if !defined(_di_f_files_adjust_) || !defined(_di_f_files_decimate_by_) - extern f_status_t private_f_files_adjust(const f_number_unsigned_t length, f_files_t * const files) F_attribute_visibility_internal_d; + extern f_status_t private_f_files_adjust(const f_number_unsigned_t length, f_files_t * const structure) F_attribute_visibility_internal_d; #endif // !defined(_di_f_files_adjust_) || !defined(_di_f_files_decimate_by_) /** @@ -51,9 +53,10 @@ extern "C" { * @return * F_none on success. * - * Errors (with error bit) from: f_memory_resize(). + * Errors (with error bit) from: f_memory_array_increase(). + * + * @see f_memory_array_increase() * - * @see f_memory_resize() * @see f_files_append() * @see f_filess_append() */ @@ -92,7 +95,7 @@ extern "C" { * * @param length * The length to adjust to. - * @param files + * @param structure * The files array to adjust. * * @return @@ -112,7 +115,7 @@ extern "C" { * */ #if !defined(_di_f_files_append_) || !defined(_di_f_files_append_all_) || !defined(_di_f_files_decrease_by_) || !defined(_di_f_files_increase_) || !defined(_di_f_files_increase_by_) || !defined(_di_f_files_resize_) || !defined(_di_f_filess_append_) || !defined(_di_f_filess_append_all_) - extern f_status_t private_f_files_resize(const f_number_unsigned_t length, f_files_t * const files) F_attribute_visibility_internal_d; + extern f_status_t private_f_files_resize(const f_number_unsigned_t length, f_files_t * const structure) F_attribute_visibility_internal_d; #endif // !defined(_di_f_files_append_) || !defined(_di_f_files_append_all_) || !defined(_di_f_files_decrease_by_) || !defined(_di_f_files_increase_) || !defined(_di_f_files_increase_by_) || !defined(_di_f_files_resize_) || !defined(_di_f_filess_append_) || !defined(_di_f_filess_append_all_) /** @@ -122,7 +125,7 @@ extern "C" { * * @param length * The length to adjust to. - * @param filess + * @param structure * The filess array to adjust. * * @return @@ -140,7 +143,7 @@ extern "C" { * @see f_filess_decimate_by() */ #if !defined(_di_f_filess_adjust_) || !defined(_di_f_filess_decimate_by_) - extern f_status_t private_f_filess_adjust(const f_number_unsigned_t length, f_filess_t * const filess) F_attribute_visibility_internal_d; + extern f_status_t private_f_filess_adjust(const f_number_unsigned_t length, f_filess_t * const structure) F_attribute_visibility_internal_d; #endif // !defined(_di_f_filess_adjust_) || !defined(_di_f_filess_decimate_by_) /** @@ -150,7 +153,7 @@ extern "C" { * * @param length * The length to resize to. - * @param filess + * @param structure * The filess array to resize. * * @return @@ -170,7 +173,7 @@ extern "C" { * @see f_filess_resize() */ #if !defined(_di_f_filess_decrease_by_) || !defined(_di_f_filess_increase_) || !defined(_di_f_filess_increase_by_) || !defined(_di_f_filess_resize_) - extern f_status_t private_f_filess_resize(const f_number_unsigned_t length, f_filess_t * const filess) F_attribute_visibility_internal_d; + extern f_status_t private_f_filess_resize(const f_number_unsigned_t length, f_filess_t * const structure) F_attribute_visibility_internal_d; #endif // !defined(_di_f_filess_decrease_by_) || !defined(_di_f_filess_increase_) || !defined(_di_f_filess_increase_by_) || !defined(_di_f_filess_resize_) #ifdef __cplusplus diff --git a/level_0/f_type_array/c/type_array/private-fll_id.c b/level_0/f_type_array/c/type_array/private-fll_id.c index 54467a0..0590c08 100644 --- a/level_0/f_type_array/c/type_array/private-fll_id.c +++ b/level_0/f_type_array/c/type_array/private-fll_id.c @@ -5,27 +5,11 @@ extern "C" { #endif -#if !defined(_di_f_fll_ids_adjust_) || !defined(_di_f_fll_ids_decimate_by_) - f_status_t private_f_fll_ids_adjust(const f_number_unsigned_t length, f_fll_ids_t * const ids) { - - const f_status_t status = f_memory_adjust(ids->size, length, sizeof(f_fll_id_t), (void **) & ids->array); - if (F_status_is_error(status)) return status; - - ids->size = length; - - if (ids->used > ids->size) { - ids->used = length; - } - - return F_none; - } -#endif // !defined(_di_f_fll_ids_adjust_) || !defined(_di_f_fll_ids_decimate_by_) - #if !defined(_di_f_fll_ids_append_) || !defined(_di_f_fll_idss_append_) extern f_status_t private_f_fll_ids_append(const f_fll_id_t source, f_fll_ids_t * const destination) { - if (destination->used + 1 > destination->size) { - const f_status_t status = private_f_fll_ids_resize(destination->used + F_memory_default_allocation_small_d, destination); + { + const f_status_t status = f_memory_array_increase(F_memory_default_allocation_small_d, sizeof(f_fll_id_t), (void **) &destination->array, &destination->used, &destination->size); if (F_status_is_error(status)) return status; } @@ -41,8 +25,8 @@ extern "C" { #if !defined(_di_f_fll_ids_append_) || !defined(_di_f_fll_ids_append_all_) || !defined(_di_f_fll_idss_append_all_) extern f_status_t private_f_fll_ids_append_all(const f_fll_ids_t source, f_fll_ids_t * const destination) { - if (destination->used + source.used > destination->size) { - const f_status_t status = private_f_fll_ids_resize(destination->used + source.used, destination); + { + const f_status_t status = f_memory_array_increase_by(source.used, sizeof(f_fll_id_t), (void **) &destination->array, &destination->used, &destination->size); if (F_status_is_error(status)) return status; } @@ -58,73 +42,33 @@ extern "C" { } #endif // !defined(_di_f_fll_ids_append_) || !defined(_di_f_fll_ids_append_all_) || !defined(_di_f_fll_idss_append_all_) -#if !defined(_di_f_fll_ids_resize_) || !defined(_di_f_fll_ids_append_) || !defined(_di_f_fll_ids_decrease_by_) || !defined(_di_f_fll_idss_append_) - f_status_t private_f_fll_ids_resize(const f_number_unsigned_t length, f_fll_ids_t * const ids) { - - const f_status_t status = f_memory_resize(ids->size, length, sizeof(f_fll_id_t), (void **) & ids->array); - if (F_status_is_error(status)) return status; - - ids->size = length; - - if (ids->used > ids->size) { - ids->used = length; - } - - return F_none; - } -#endif // !defined(_di_f_fll_ids_resize_) || !defined(_di_f_fll_ids_append_) || !defined(_di_f_fll_ids_decrease_by_) || !defined(_di_f_fll_idss_append_) - #if !defined(_di_f_fll_idss_adjust_) || !defined(_di_f_fll_idss_decimate_by_) - f_status_t private_f_fll_idss_adjust(const f_number_unsigned_t length, f_fll_idss_t * const idss) { + f_status_t private_f_fll_idss_adjust(const f_number_unsigned_t length, f_fll_idss_t * const structure) { f_status_t status = F_none; - for (f_number_unsigned_t i = length; i < idss->size; ++i) { + for (f_number_unsigned_t i = length; i < structure->size; ++i) { - status = f_memory_destroy(idss->array[i].size, sizeof(f_fll_ids_t), (void **) & idss->array[i].array); + status = f_memory_array_adjust(0, sizeof(f_fll_id_t), (void **) &structure->array[i].array, &structure->array[i].used, &structure->array[i].size); if (F_status_is_error(status)) return status; - - idss->array[i].size = 0; - idss->array[i].used = 0; } // for - status = f_memory_adjust(idss->size, length, sizeof(f_fll_ids_t), (void **) & idss->array); - if (F_status_is_error(status)) return status; - - idss->size = length; - - if (idss->used > idss->size) { - idss->used = length; - } - - return F_none; + return f_memory_array_adjust(length, sizeof(f_fll_ids_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // !defined(_di_f_fll_idss_adjust_) || !defined(_di_f_fll_idss_decimate_by_) #if !defined(_di_f_fll_idss_decrease_by_) || !defined(_di_f_fll_idss_increase_) || !defined(_di_f_fll_idss_increase_by_) || !defined(_di_f_fll_idss_resize_) - f_status_t private_f_fll_idss_resize(const f_number_unsigned_t length, f_fll_idss_t * const idss) { + f_status_t private_f_fll_idss_resize(const f_number_unsigned_t length, f_fll_idss_t * const structure) { f_status_t status = F_none; - for (f_number_unsigned_t i = length; i < idss->size; ++i) { + for (f_number_unsigned_t i = length; i < structure->size; ++i) { - status = f_memory_delete(idss->array[i].size, sizeof(f_fll_ids_t), (void **) & idss->array[i].array); + status = f_memory_array_resize(0, sizeof(f_fll_id_t), (void **) &structure->array[i].array, &structure->array[i].used, &structure->array[i].size); if (F_status_is_error(status)) return status; - - idss->array[i].size = 0; - idss->array[i].used = 0; } // for - status = f_memory_resize(idss->size, length, sizeof(f_fll_ids_t), (void **) & idss->array); - if (F_status_is_error(status)) return status; - - idss->size = length; - - if (idss->used > idss->size) { - idss->used = length; - } - - return F_none; + return f_memory_array_resize(length, sizeof(f_fll_ids_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // !defined(_di_f_fll_idss_decrease_by_) || !defined(_di_f_fll_idss_increase_) || !defined(_di_f_fll_idss_increase_by_) || !defined(_di_f_fll_idss_resize_) diff --git a/level_0/f_type_array/c/type_array/private-fll_id.h b/level_0/f_type_array/c/type_array/private-fll_id.h index 940fabd..37f8aee 100644 --- a/level_0/f_type_array/c/type_array/private-fll_id.h +++ b/level_0/f_type_array/c/type_array/private-fll_id.h @@ -16,29 +16,6 @@ extern "C" { #endif /** - * Private implementation for resizing the fll_ids array. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The length to adjust to. - * @param fll_ids - * The fll_ids array to adjust. - * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + 1 <= size). - * - * Errors (with error bit) from: f_memory_adjust(). - * - * @see f_fll_ids_adjust() - * @see f_fll_ids_decimate_by() - */ -#if !defined(_di_f_fll_ids_adjust_) || !defined(_di_f_fll_ids_decimate_by_) - extern f_status_t private_f_fll_ids_adjust(const f_number_unsigned_t length, f_fll_ids_t * const fll_ids) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_fll_ids_adjust_) || !defined(_di_f_fll_ids_decimate_by_) - -/** * Private implementation for appending the fll_id array. * * Intended to be shared to each of the different implementation variations. @@ -51,9 +28,10 @@ extern "C" { * @return * F_none on success. * - * Errors (with error bit) from: f_memory_resize(). + * Errors (with error bit) from: f_memory_array_increase(). + * + * @see f_memory_array_increase() * - * @see f_memory_resize() * @see f_fll_ids_append() * @see f_fll_idss_append() */ @@ -74,9 +52,10 @@ extern "C" { * @return * F_none on success. * - * 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_fll_ids_append_all() * @see f_fll_idss_append() * @see f_fll_idss_append_all() @@ -86,38 +65,13 @@ extern "C" { #endif // !defined(_di_f_fll_ids_append_) || !defined(_di_f_fll_ids_append_all_) || !defined(_di_f_fll_idss_append_all_) /** - * Private implementation for resizing the fll_ids array. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The length to adjust to. - * @param fll_ids - * The fll_ids array to adjust. - * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + 1 <= size). - * - * Errors (with error bit) from: f_memory_resize(). - * - * @see f_fll_ids_resize() - * @see f_fll_ids_append() - * @see f_fll_ids_decrease_by() - * @see f_fll_idss_append() - */ -#if !defined(_di_f_fll_ids_resize_) || !defined(_di_f_fll_ids_append_) || !defined(_di_f_fll_ids_decrease_by_) || !defined(_di_f_fll_idss_append_) - extern f_status_t private_f_fll_ids_resize(const f_number_unsigned_t length, f_fll_ids_t * const fll_ids) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_fll_ids_resize_) || !defined(_di_f_fll_ids_append_) || !defined(_di_f_fll_ids_decrease_by_) || !defined(_di_f_fll_idss_append_) - -/** * Private implementation for resizing the fll_idss array. * * Intended to be shared to each of the different implementation variations. * * @param length * The length to adjust to. - * @param fll_idss + * @param structure * The fll_idss array to adjust. * * @return @@ -128,14 +82,15 @@ 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_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_fll_idss_adjust() * @see f_fll_idss_decimate_by() */ #if !defined(_di_f_fll_idss_adjust_) || !defined(_di_f_fll_idss_decimate_by_) - extern f_status_t private_f_fll_idss_adjust(const f_number_unsigned_t length, f_fll_idss_t * const fll_idss) F_attribute_visibility_internal_d; + extern f_status_t private_f_fll_idss_adjust(const f_number_unsigned_t length, f_fll_idss_t * const structure) F_attribute_visibility_internal_d; #endif // !defined(_di_f_fll_idss_adjust_) || !defined(_di_f_fll_idss_decimate_by_) /** @@ -145,7 +100,7 @@ extern "C" { * * @param length * The length to resize to. - * @param fll_idss + * @param structure * The fll_idss array to resize. * * @return @@ -156,8 +111,9 @@ 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_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_fll_idss_decrease_by() * @see f_fll_idss_increase() @@ -165,7 +121,7 @@ extern "C" { * @see f_fll_idss_resize() */ #if !defined(_di_f_fll_idss_decrease_by_) || !defined(_di_f_fll_idss_increase_) || !defined(_di_f_fll_idss_increase_by_) || !defined(_di_f_fll_idss_resize_) - extern f_status_t private_f_fll_idss_resize(const f_number_unsigned_t length, f_fll_idss_t * const fll_idss) F_attribute_visibility_internal_d; + extern f_status_t private_f_fll_idss_resize(const f_number_unsigned_t length, f_fll_idss_t * const structure) F_attribute_visibility_internal_d; #endif // !defined(_di_f_fll_idss_decrease_by_) || !defined(_di_f_fll_idss_increase_) || !defined(_di_f_fll_idss_increase_by_) || !defined(_di_f_fll_idss_resize_) #ifdef __cplusplus diff --git a/level_0/f_type_array/c/type_array/private-int128.c b/level_0/f_type_array/c/type_array/private-int128.c index 9b3757d..599c93b 100644 --- a/level_0/f_type_array/c/type_array/private-int128.c +++ b/level_0/f_type_array/c/type_array/private-int128.c @@ -5,27 +5,11 @@ extern "C" { #endif -#if !defined(_di_f_int128s_adjust_) || !defined(_di_f_int128s_decimate_by_) - f_status_t private_f_int128s_adjust(const f_number_unsigned_t length, f_int128s_t * const int128s) { - - const f_status_t status = f_memory_adjust(int128s->size, length, sizeof(f_int128s_t), (void **) & int128s->array); - if (F_status_is_error(status)) return status; - - int128s->size = length; - - if (int128s->used > int128s->size) { - int128s->used = length; - } - - return F_none; - } -#endif // !defined(_di_f_int128s_adjust_) || !defined(_di_f_int128s_decimate_by_) - #if !defined(_di_f_int128s_append_) || !defined(_di_f_int128ss_append_) extern f_status_t private_f_int128s_append(const int128_t source, f_int128s_t * const destination) { - if (destination->used + 1 > destination->size) { - const f_status_t status = private_f_int128s_resize(destination->used + F_memory_default_allocation_small_d, destination); + { + const f_status_t status = f_memory_array_increase(F_memory_default_allocation_small_d, sizeof(int128_t), (void **) &destination->array, &destination->used, &destination->size); if (F_status_is_error(status)) return status; } @@ -38,8 +22,8 @@ extern "C" { #if !defined(_di_f_int128s_append_) || !defined(_di_f_int128s_append_all_) || !defined(_di_f_int128ss_append_all_) extern f_status_t private_f_int128s_append_all(const f_int128s_t source, f_int128s_t * const destination) { - if (destination->used + source.used > destination->size) { - const f_status_t status = private_f_int128s_resize(destination->used + source.used, destination); + { + const f_status_t status = f_memory_array_increase_by(source.used, sizeof(int128_t), (void **) &destination->array, &destination->used, &destination->size); if (F_status_is_error(status)) return status; } @@ -51,73 +35,33 @@ extern "C" { } #endif // !defined(_di_f_int128s_append_) || !defined(_di_f_int128s_append_all_) || !defined(_di_f_int128ss_append_all_) -#if !defined(_di_f_int128s_resize_) || !defined(_di_f_int128s_append_) || !defined(_di_f_int128s_decrease_by_) || !defined(_di_f_int128ss_append_) - f_status_t private_f_int128s_resize(const f_number_unsigned_t length, f_int128s_t * const int128s) { - - const f_status_t status = f_memory_resize(int128s->size, length, sizeof(f_int128s_t), (void **) & int128s->array); - if (F_status_is_error(status)) return status; - - int128s->size = length; - - if (int128s->used > int128s->size) { - int128s->used = length; - } - - return F_none; - } -#endif // !defined(_di_f_int128s_resize_) || !defined(_di_f_int128s_append_) || !defined(_di_f_int128s_decrease_by_) || !defined(_di_f_int128ss_append_) - #if !defined(_di_f_int128ss_adjust_) || !defined(_di_f_int128ss_decimate_by_) - f_status_t private_f_int128ss_adjust(const f_number_unsigned_t length, f_int128ss_t * const int128ss) { + f_status_t private_f_int128ss_adjust(const f_number_unsigned_t length, f_int128ss_t * const structure) { f_status_t status = F_none; - for (f_number_unsigned_t i = length; i < int128ss->size; ++i) { + for (f_number_unsigned_t i = length; i < structure->size; ++i) { - status = f_memory_destroy(int128ss->array[i].size, sizeof(f_int128s_t), (void **) & int128ss->array[i].array); + status = f_memory_array_adjust(0, sizeof(int128_t), (void **) &structure->array[i].array, &structure->array[i].used, &structure->array[i].size); if (F_status_is_error(status)) return status; - - int128ss->array[i].size = 0; - int128ss->array[i].used = 0; } // for - status = f_memory_adjust(int128ss->size, length, sizeof(f_int128s_t), (void **) & int128ss->array); - if (F_status_is_error(status)) return status; - - int128ss->size = length; - - if (int128ss->used > int128ss->size) { - int128ss->used = length; - } - - return F_none; + return f_memory_array_adjust(length, sizeof(f_int128s_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // !defined(_di_f_int128ss_adjust_) || !defined(_di_f_int128ss_decimate_by_) #if !defined(_di_f_int128ss_decrease_by_) || !defined(_di_f_int128ss_increase_) || !defined(_di_f_int128ss_increase_by_) || !defined(_di_f_int128ss_resize_) - f_status_t private_f_int128ss_resize(const f_number_unsigned_t length, f_int128ss_t * const int128ss) { + f_status_t private_f_int128ss_resize(const f_number_unsigned_t length, f_int128ss_t * const structure) { f_status_t status = F_none; - for (f_number_unsigned_t i = length; i < int128ss->size; ++i) { + for (f_number_unsigned_t i = length; i < structure->size; ++i) { - status = f_memory_delete(int128ss->array[i].size, sizeof(f_int128s_t), (void **) & int128ss->array[i].array); + status = f_memory_array_resize(0, sizeof(int128_t), (void **) &structure->array[i].array, &structure->array[i].used, &structure->array[i].size); if (F_status_is_error(status)) return status; - - int128ss->array[i].size = 0; - int128ss->array[i].used = 0; } // for - status = f_memory_resize(int128ss->size, length, sizeof(f_int128s_t), (void **) & int128ss->array); - if (F_status_is_error(status)) return status; - - int128ss->size = length; - - if (int128ss->used > int128ss->size) { - int128ss->used = length; - } - - return F_none; + return f_memory_array_resize(length, sizeof(f_int128s_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // !defined(_di_f_int128ss_decrease_by_) || !defined(_di_f_int128ss_increase_) || !defined(_di_f_int128ss_increase_by_) || !defined(_di_f_int128ss_resize_) diff --git a/level_0/f_type_array/c/type_array/private-int128.h b/level_0/f_type_array/c/type_array/private-int128.h index fec9812..d8cbb71 100644 --- a/level_0/f_type_array/c/type_array/private-int128.h +++ b/level_0/f_type_array/c/type_array/private-int128.h @@ -16,29 +16,6 @@ extern "C" { #endif /** - * Private implementation for resizing the int128s array. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The length to adjust to. - * @param int128s - * The int128s array to adjust. - * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + 1 <= size). - * - * Errors (with error bit) from: f_memory_adjust(). - * - * @see f_int128s_adjust() - * @see f_int128s_decimate_by() - */ -#if !defined(_di_f_int128s_adjust_) || !defined(_di_f_int128s_decimate_by_) - extern f_status_t private_f_int128s_adjust(const f_number_unsigned_t length, f_int128s_t * const int128s) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_int128s_adjust_) || !defined(_di_f_int128s_decimate_by_) - -/** * Private implementation for appending the int128 array. * * Intended to be shared to each of the different implementation variations. @@ -51,9 +28,10 @@ extern "C" { * @return * F_none on success. * - * Errors (with error bit) from: f_memory_resize(). + * Errors (with error bit) from: f_memory_array_increase(). + * + * @see f_memory_array_increase() * - * @see f_memory_resize() * @see f_int128s_append() * @see f_int128ss_append() */ @@ -74,9 +52,10 @@ extern "C" { * @return * F_none on success. * - * 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_int128s_append_all() * @see f_int128ss_append() * @see f_int128ss_append_all() @@ -86,38 +65,13 @@ extern "C" { #endif // !defined(_di_f_int128s_append_) || !defined(_di_f_int128s_append_all_) || !defined(_di_f_int128ss_append_all_) /** - * Private implementation for resizing the int128s array. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The length to adjust to. - * @param int128s - * The int128s array to adjust. - * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + 1 <= size). - * - * Errors (with error bit) from: f_memory_resize(). - * - * @see f_int128s_resize() - * @see f_int128s_append() - * @see f_int128s_decrease_by() - * @see f_int128ss_append() - */ -#if !defined(_di_f_int128s_resize_) || !defined(_di_f_int128s_append_) || !defined(_di_f_int128s_decrease_by_) || !defined(_di_f_int128ss_append_) - extern f_status_t private_f_int128s_resize(const f_number_unsigned_t length, f_int128s_t * const int128s) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_int128s_resize_) || !defined(_di_f_int128s_append_) || !defined(_di_f_int128s_decrease_by_) || !defined(_di_f_int128ss_append_) - -/** * Private implementation for resizing the int128ss array. * * Intended to be shared to each of the different implementation variations. * * @param length * The length to adjust to. - * @param int128ss + * @param structure * The int128ss array to adjust. * * @return @@ -128,14 +82,15 @@ 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_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_int128ss_adjust() * @see f_int128ss_decimate_by() */ #if !defined(_di_f_int128ss_adjust_) || !defined(_di_f_int128ss_decimate_by_) - extern f_status_t private_f_int128ss_adjust(const f_number_unsigned_t length, f_int128ss_t * const int128ss) F_attribute_visibility_internal_d; + extern f_status_t private_f_int128ss_adjust(const f_number_unsigned_t length, f_int128ss_t * const structure) F_attribute_visibility_internal_d; #endif // !defined(_di_f_int128ss_adjust_) || !defined(_di_f_int128ss_decimate_by_) /** @@ -145,7 +100,7 @@ extern "C" { * * @param length * The length to resize to. - * @param int128ss + * @param structure * The int128ss array to resize. * * @return @@ -156,8 +111,9 @@ 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_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_int128ss_decrease_by() * @see f_int128ss_increase() @@ -165,7 +121,7 @@ extern "C" { * @see f_int128ss_resize() */ #if !defined(_di_f_int128ss_decrease_by_) || !defined(_di_f_int128ss_increase_) || !defined(_di_f_int128ss_increase_by_) || !defined(_di_f_int128ss_resize_) - extern f_status_t private_f_int128ss_resize(const f_number_unsigned_t length, f_int128ss_t * const int128ss) F_attribute_visibility_internal_d; + extern f_status_t private_f_int128ss_resize(const f_number_unsigned_t length, f_int128ss_t * const structure) F_attribute_visibility_internal_d; #endif // !defined(_di_f_int128ss_decrease_by_) || !defined(_di_f_int128ss_increase_) || !defined(_di_f_int128ss_increase_by_) || !defined(_di_f_int128ss_resize_) #ifdef __cplusplus diff --git a/level_0/f_type_array/c/type_array/private-int16.c b/level_0/f_type_array/c/type_array/private-int16.c index 30b626c..1364456 100644 --- a/level_0/f_type_array/c/type_array/private-int16.c +++ b/level_0/f_type_array/c/type_array/private-int16.c @@ -5,27 +5,11 @@ extern "C" { #endif -#if !defined(_di_f_int16s_adjust_) || !defined(_di_f_int16s_decimate_by_) - f_status_t private_f_int16s_adjust(const f_number_unsigned_t length, f_int16s_t * const int16s) { - - const f_status_t status = f_memory_adjust(int16s->size, length, sizeof(int16_t), (void **) & int16s->array); - if (F_status_is_error(status)) return status; - - int16s->size = length; - - if (int16s->used > int16s->size) { - int16s->used = length; - } - - return F_none; - } -#endif // !defined(_di_f_int16s_adjust_) || !defined(_di_f_int16s_decimate_by_) - #if !defined(_di_f_int16s_append_) || !defined(_di_f_int16ss_append_) extern f_status_t private_f_int16s_append(const int16_t source, f_int16s_t * const destination) { - if (destination->used + 1 > destination->size) { - const f_status_t status = private_f_int16s_resize(destination->used + F_memory_default_allocation_small_d, destination); + { + const f_status_t status = f_memory_array_increase(F_memory_default_allocation_small_d, sizeof(int16_t), (void **) &destination->array, &destination->used, &destination->size); if (F_status_is_error(status)) return status; } @@ -38,8 +22,8 @@ extern "C" { #if !defined(_di_f_int16s_append_) || !defined(_di_f_int16s_append_all_) || !defined(_di_f_int16ss_append_all_) extern f_status_t private_f_int16s_append_all(const f_int16s_t source, f_int16s_t * const destination) { - if (destination->used + source.used > destination->size) { - const f_status_t status = private_f_int16s_resize(destination->used + source.used, destination); + { + const f_status_t status = f_memory_array_increase_by(source.used, sizeof(int16_t), (void **) &destination->array, &destination->used, &destination->size); if (F_status_is_error(status)) return status; } @@ -51,73 +35,33 @@ extern "C" { } #endif // !defined(_di_f_int16s_append_) || !defined(_di_f_int16s_append_all_) || !defined(_di_f_int16ss_append_all_) -#if !defined(_di_f_int16s_resize_) || !defined(_di_f_int16s_append_) || !defined(_di_f_int16s_decrease_by_) || !defined(_di_f_int16ss_append_) - f_status_t private_f_int16s_resize(const f_number_unsigned_t length, f_int16s_t * const int16s) { - - const f_status_t status = f_memory_resize(int16s->size, length, sizeof(int16_t), (void **) & int16s->array); - if (F_status_is_error(status)) return status; - - int16s->size = length; - - if (int16s->used > int16s->size) { - int16s->used = length; - } - - return F_none; - } -#endif // !defined(_di_f_int16s_resize_) || !defined(_di_f_int16s_append_) || !defined(_di_f_int16s_decrease_by_) || !defined(_di_f_int16ss_append_) - #if !defined(_di_f_int16ss_adjust_) || !defined(_di_f_int16ss_decimate_by_) - f_status_t private_f_int16ss_adjust(const f_number_unsigned_t length, f_int16ss_t * const int16ss) { + f_status_t private_f_int16ss_adjust(const f_number_unsigned_t length, f_int16ss_t * const structure) { f_status_t status = F_none; - for (f_number_unsigned_t i = length; i < int16ss->size; ++i) { + for (f_number_unsigned_t i = length; i < structure->size; ++i) { - status = f_memory_destroy(int16ss->array[i].size, sizeof(f_int16s_t), (void **) & int16ss->array[i].array); + status = f_memory_array_adjust(0, sizeof(int16_t), (void **) &structure->array[i].array, &structure->array[i].used, &structure->array[i].size); if (F_status_is_error(status)) return status; - - int16ss->array[i].size = 0; - int16ss->array[i].used = 0; } // for - status = f_memory_adjust(int16ss->size, length, sizeof(f_int16s_t), (void **) & int16ss->array); - if (F_status_is_error(status)) return status; - - int16ss->size = length; - - if (int16ss->used > int16ss->size) { - int16ss->used = length; - } - - return F_none; + return f_memory_array_adjust(length, sizeof(f_int16s_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // !defined(_di_f_int16ss_adjust_) || !defined(_di_f_int16ss_decimate_by_) #if !defined(_di_f_int16ss_decrease_by_) || !defined(_di_f_int16ss_increase_) || !defined(_di_f_int16ss_increase_by_) || !defined(_di_f_int16ss_resize_) - f_status_t private_f_int16ss_resize(const f_number_unsigned_t length, f_int16ss_t * const int16ss) { + f_status_t private_f_int16ss_resize(const f_number_unsigned_t length, f_int16ss_t * const structure) { f_status_t status = F_none; - for (f_number_unsigned_t i = length; i < int16ss->size; ++i) { + for (f_number_unsigned_t i = length; i < structure->size; ++i) { - status = f_memory_delete(int16ss->array[i].size, sizeof(f_int16s_t), (void **) & int16ss->array[i].array); + status = f_memory_array_resize(0, sizeof(int16_t), (void **) &structure->array[i].array, &structure->array[i].used, &structure->array[i].size); if (F_status_is_error(status)) return status; - - int16ss->array[i].size = 0; - int16ss->array[i].used = 0; } // for - status = f_memory_resize(int16ss->size, length, sizeof(f_int16s_t), (void **) & int16ss->array); - if (F_status_is_error(status)) return status; - - int16ss->size = length; - - if (int16ss->used > int16ss->size) { - int16ss->used = length; - } - - return F_none; + return f_memory_array_resize(length, sizeof(f_int16s_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // !defined(_di_f_int16ss_decrease_by_) || !defined(_di_f_int16ss_increase_) || !defined(_di_f_int16ss_increase_by_) || !defined(_di_f_int16ss_resize_) diff --git a/level_0/f_type_array/c/type_array/private-int16.h b/level_0/f_type_array/c/type_array/private-int16.h index 1758e83..fb499c0 100644 --- a/level_0/f_type_array/c/type_array/private-int16.h +++ b/level_0/f_type_array/c/type_array/private-int16.h @@ -16,29 +16,6 @@ extern "C" { #endif /** - * Private implementation for resizing the int16s array. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The length to adjust to. - * @param int16s - * The int16s array to adjust. - * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + 1 <= size). - * - * Errors (with error bit) from: f_memory_adjust(). - * - * @see f_int16s_adjust() - * @see f_int16s_decimate_by() - */ -#if !defined(_di_f_int16s_adjust_) || !defined(_di_f_int16s_decimate_by_) - extern f_status_t private_f_int16s_adjust(const f_number_unsigned_t length, f_int16s_t * const int16s) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_int16s_adjust_) || !defined(_di_f_int16s_decimate_by_) - -/** * Private implementation for appending the int16 array. * * Intended to be shared to each of the different implementation variations. @@ -51,9 +28,10 @@ extern "C" { * @return * F_none on success. * - * Errors (with error bit) from: f_memory_resize(). + * Errors (with error bit) from: f_memory_array_increase(). + * + * @see f_memory_array_increase() * - * @see f_memory_resize() * @see f_int16s_append() * @see f_int16ss_append() */ @@ -74,9 +52,10 @@ extern "C" { * @return * F_none on success. * - * 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_int16s_append_all() * @see f_int16ss_append() * @see f_int16ss_append_all() @@ -86,38 +65,13 @@ extern "C" { #endif // !defined(_di_f_int16s_append_) || !defined(_di_f_int16s_append_all_) || !defined(_di_f_int16ss_append_all_) /** - * Private implementation for resizing the int16s array. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The length to adjust to. - * @param int16s - * The int16s array to adjust. - * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + 1 <= size). - * - * Errors (with error bit) from: f_memory_resize(). - * - * @see f_int16s_resize() - * @see f_int16s_append() - * @see f_int16s_decrease_by() - * @see f_int16ss_append() - */ -#if !defined(_di_f_int16s_resize_) || !defined(_di_f_int16s_append_) || !defined(_di_f_int16s_decrease_by_) || !defined(_di_f_int16ss_append_) - extern f_status_t private_f_int16s_resize(const f_number_unsigned_t length, f_int16s_t * const int16s) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_int16s_resize_) || !defined(_di_f_int16s_append_) || !defined(_di_f_int16s_decrease_by_) || !defined(_di_f_int16ss_append_) - -/** * Private implementation for resizing the int16ss array. * * Intended to be shared to each of the different implementation variations. * * @param length * The length to adjust to. - * @param int16ss + * @param structure * The int16ss array to adjust. * * @return @@ -128,14 +82,15 @@ 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_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_int16ss_adjust() * @see f_int16ss_decimate_by() */ #if !defined(_di_f_int16ss_adjust_) || !defined(_di_f_int16ss_decimate_by_) - extern f_status_t private_f_int16ss_adjust(const f_number_unsigned_t length, f_int16ss_t * const int16ss) F_attribute_visibility_internal_d; + extern f_status_t private_f_int16ss_adjust(const f_number_unsigned_t length, f_int16ss_t * const structure) F_attribute_visibility_internal_d; #endif // !defined(_di_f_int16ss_adjust_) || !defined(_di_f_int16ss_decimate_by_) /** @@ -145,7 +100,7 @@ extern "C" { * * @param length * The length to resize to. - * @param int16ss + * @param structure * The int16ss array to resize. * * @return @@ -156,8 +111,9 @@ 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_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_int16ss_decrease_by() * @see f_int16ss_increase() @@ -165,7 +121,7 @@ extern "C" { * @see f_int16ss_resize() */ #if !defined(_di_f_int16ss_decrease_by_) || !defined(_di_f_int16ss_increase_) || !defined(_di_f_int16ss_increase_by_) || !defined(_di_f_int16ss_resize_) - extern f_status_t private_f_int16ss_resize(const f_number_unsigned_t length, f_int16ss_t * const int16ss) F_attribute_visibility_internal_d; + extern f_status_t private_f_int16ss_resize(const f_number_unsigned_t length, f_int16ss_t * const structure) F_attribute_visibility_internal_d; #endif // !defined(_di_f_int16ss_decrease_by_) || !defined(_di_f_int16ss_increase_) || !defined(_di_f_int16ss_increase_by_) || !defined(_di_f_int16ss_resize_) #ifdef __cplusplus diff --git a/level_0/f_type_array/c/type_array/private-int32.c b/level_0/f_type_array/c/type_array/private-int32.c index 9810e52..d3598d7 100644 --- a/level_0/f_type_array/c/type_array/private-int32.c +++ b/level_0/f_type_array/c/type_array/private-int32.c @@ -5,27 +5,11 @@ extern "C" { #endif -#if !defined(_di_f_int32s_adjust_) || !defined(_di_f_int32s_decimate_by_) - f_status_t private_f_int32s_adjust(const f_number_unsigned_t length, f_int32s_t * const int32s) { - - const f_status_t status = f_memory_adjust(int32s->size, length, sizeof(int32_t), (void **) & int32s->array); - if (F_status_is_error(status)) return status; - - int32s->size = length; - - if (int32s->used > int32s->size) { - int32s->used = length; - } - - return F_none; - } -#endif // !defined(_di_f_int32s_adjust_) || !defined(_di_f_int32s_decimate_by_) - #if !defined(_di_f_int32s_append_) || !defined(_di_f_int32ss_append_) extern f_status_t private_f_int32s_append(const int32_t source, f_int32s_t * const destination) { - if (destination->used + 1 > destination->size) { - const f_status_t status = private_f_int32s_resize(destination->used + F_memory_default_allocation_small_d, destination); + { + const f_status_t status = f_memory_array_increase(F_memory_default_allocation_small_d, sizeof(int32_t), (void **) &destination->array, &destination->used, &destination->size); if (F_status_is_error(status)) return status; } @@ -38,8 +22,8 @@ extern "C" { #if !defined(_di_f_int32s_append_) || !defined(_di_f_int32s_append_all_) || !defined(_di_f_int32ss_append_all_) extern f_status_t private_f_int32s_append_all(const f_int32s_t source, f_int32s_t * const destination) { - if (destination->used + source.used > destination->size) { - const f_status_t status = private_f_int32s_resize(destination->used + source.used, destination); + { + const f_status_t status = f_memory_array_increase_by(source.used, sizeof(int32_t), (void **) &destination->array, &destination->used, &destination->size); if (F_status_is_error(status)) return status; } @@ -51,73 +35,33 @@ extern "C" { } #endif // !defined(_di_f_int32s_append_) || !defined(_di_f_int32s_append_all_) || !defined(_di_f_int32ss_append_all_) -#if !defined(_di_f_int32s_resize_) || !defined(_di_f_int32s_append_) || !defined(_di_f_int32s_decrease_by_) || !defined(_di_f_int32ss_append_) - f_status_t private_f_int32s_resize(const f_number_unsigned_t length, f_int32s_t * const int32s) { - - const f_status_t status = f_memory_resize(int32s->size, length, sizeof(int32_t), (void **) & int32s->array); - if (F_status_is_error(status)) return status; - - int32s->size = length; - - if (int32s->used > int32s->size) { - int32s->used = length; - } - - return F_none; - } -#endif // !defined(_di_f_int32s_resize_) || !defined(_di_f_int32s_append_) || !defined(_di_f_int32s_decrease_by_) || !defined(_di_f_int32ss_append_) - #if !defined(_di_f_int32ss_adjust_) || !defined(_di_f_int32ss_decimate_by_) - f_status_t private_f_int32ss_adjust(const f_number_unsigned_t length, f_int32ss_t * const int32ss) { + f_status_t private_f_int32ss_adjust(const f_number_unsigned_t length, f_int32ss_t * const structure) { f_status_t status = F_none; - for (f_number_unsigned_t i = length; i < int32ss->size; ++i) { + for (f_number_unsigned_t i = length; i < structure->size; ++i) { - status = f_memory_destroy(int32ss->array[i].size, sizeof(f_int32s_t), (void **) & int32ss->array[i].array); + status = f_memory_array_adjust(0, sizeof(int32_t), (void **) &structure->array[i].array, &structure->array[i].used, &structure->array[i].size); if (F_status_is_error(status)) return status; - - int32ss->array[i].size = 0; - int32ss->array[i].used = 0; } // for - status = f_memory_adjust(int32ss->size, length, sizeof(f_int32s_t), (void **) & int32ss->array); - if (F_status_is_error(status)) return status; - - int32ss->size = length; - - if (int32ss->used > int32ss->size) { - int32ss->used = length; - } - - return F_none; + return f_memory_array_adjust(length, sizeof(f_int32s_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // !defined(_di_f_int32ss_adjust_) || !defined(_di_f_int32ss_decimate_by_) #if !defined(_di_f_int32ss_decrease_by_) || !defined(_di_f_int32ss_increase_) || !defined(_di_f_int32ss_increase_by_) || !defined(_di_f_int32ss_resize_) - f_status_t private_f_int32ss_resize(const f_number_unsigned_t length, f_int32ss_t * const int32ss) { + f_status_t private_f_int32ss_resize(const f_number_unsigned_t length, f_int32ss_t * const structure) { f_status_t status = F_none; - for (f_number_unsigned_t i = length; i < int32ss->size; ++i) { + for (f_number_unsigned_t i = length; i < structure->size; ++i) { - status = f_memory_delete(int32ss->array[i].size, sizeof(f_int32s_t), (void **) & int32ss->array[i].array); + status = f_memory_array_resize(0, sizeof(int32_t), (void **) &structure->array[i].array, &structure->array[i].used, &structure->array[i].size); if (F_status_is_error(status)) return status; - - int32ss->array[i].size = 0; - int32ss->array[i].used = 0; } // for - status = f_memory_resize(int32ss->size, length, sizeof(f_int32s_t), (void **) & int32ss->array); - if (F_status_is_error(status)) return status; - - int32ss->size = length; - - if (int32ss->used > int32ss->size) { - int32ss->used = length; - } - - return F_none; + return f_memory_array_resize(length, sizeof(f_int32s_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // !defined(_di_f_int32ss_decrease_by_) || !defined(_di_f_int32ss_increase_) || !defined(_di_f_int32ss_increase_by_) || !defined(_di_f_int32ss_resize_) diff --git a/level_0/f_type_array/c/type_array/private-int32.h b/level_0/f_type_array/c/type_array/private-int32.h index 3352d2a..83309a4 100644 --- a/level_0/f_type_array/c/type_array/private-int32.h +++ b/level_0/f_type_array/c/type_array/private-int32.h @@ -16,29 +16,6 @@ extern "C" { #endif /** - * Private implementation for resizing the int32s array. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The length to adjust to. - * @param int32s - * The int32s array to adjust. - * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + 1 <= size). - * - * Errors (with error bit) from: f_memory_adjust(). - * - * @see f_int32s_adjust() - * @see f_int32s_decimate_by() - */ -#if !defined(_di_f_int32s_adjust_) || !defined(_di_f_int32s_decimate_by_) - extern f_status_t private_f_int32s_adjust(const f_number_unsigned_t length, f_int32s_t * const int32s) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_int32s_adjust_) || !defined(_di_f_int32s_decimate_by_) - -/** * Private implementation for appending the int32 array. * * Intended to be shared to each of the different implementation variations. @@ -51,9 +28,10 @@ extern "C" { * @return * F_none on success. * - * Errors (with error bit) from: f_memory_resize(). + * Errors (with error bit) from: f_memory_array_increase(). + * + * @see f_memory_array_increase() * - * @see f_memory_resize() * @see f_int32s_append() * @see f_int32ss_append() */ @@ -74,9 +52,10 @@ extern "C" { * @return * F_none on success. * - * 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_int32s_append_all() * @see f_int32ss_append() * @see f_int32ss_append_all() @@ -86,38 +65,13 @@ extern "C" { #endif // !defined(_di_f_int32s_append_) || !defined(_di_f_int32s_append_all_) || !defined(_di_f_int32ss_append_all_) /** - * Private implementation for resizing the int32s array. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The length to adjust to. - * @param int32s - * The int32s array to adjust. - * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + 1 <= size). - * - * Errors (with error bit) from: f_memory_resize(). - * - * @see f_int32s_resize() - * @see f_int32s_append() - * @see f_int32s_decrease_by() - * @see f_int32ss_append() - */ -#if !defined(_di_f_int32s_resize_) || !defined(_di_f_int32s_append_) || !defined(_di_f_int32s_decrease_by_) || !defined(_di_f_int32ss_append_) - extern f_status_t private_f_int32s_resize(const f_number_unsigned_t length, f_int32s_t * const int32s) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_int32s_resize_) || !defined(_di_f_int32s_append_) || !defined(_di_f_int32s_decrease_by_) || !defined(_di_f_int32ss_append_) - -/** * Private implementation for resizing the int32ss array. * * Intended to be shared to each of the different implementation variations. * * @param length * The length to adjust to. - * @param int32ss + * @param structure * The int32ss array to adjust. * * @return @@ -128,14 +82,15 @@ 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_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_int32ss_adjust() * @see f_int32ss_decimate_by() */ #if !defined(_di_f_int32ss_adjust_) || !defined(_di_f_int32ss_decimate_by_) - extern f_status_t private_f_int32ss_adjust(const f_number_unsigned_t length, f_int32ss_t * const int32ss) F_attribute_visibility_internal_d; + extern f_status_t private_f_int32ss_adjust(const f_number_unsigned_t length, f_int32ss_t * const structure) F_attribute_visibility_internal_d; #endif // !defined(_di_f_int32ss_adjust_) || !defined(_di_f_int32ss_decimate_by_) /** @@ -145,7 +100,7 @@ extern "C" { * * @param length * The length to resize to. - * @param int32ss + * @param structure * The int32ss array to resize. * * @return @@ -156,8 +111,9 @@ 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_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_int32ss_decrease_by() * @see f_int32ss_increase() @@ -165,7 +121,7 @@ extern "C" { * @see f_int32ss_resize() */ #if !defined(_di_f_int32ss_decrease_by_) || !defined(_di_f_int32ss_increase_) || !defined(_di_f_int32ss_increase_by_) || !defined(_di_f_int32ss_resize_) - extern f_status_t private_f_int32ss_resize(const f_number_unsigned_t length, f_int32ss_t * const int32ss) F_attribute_visibility_internal_d; + extern f_status_t private_f_int32ss_resize(const f_number_unsigned_t length, f_int32ss_t * const structure) F_attribute_visibility_internal_d; #endif // !defined(_di_f_int32ss_decrease_by_) || !defined(_di_f_int32ss_increase_) || !defined(_di_f_int32ss_increase_by_) || !defined(_di_f_int32ss_resize_) #ifdef __cplusplus diff --git a/level_0/f_type_array/c/type_array/private-int64.c b/level_0/f_type_array/c/type_array/private-int64.c index 32a8c56..ea6cd7f 100644 --- a/level_0/f_type_array/c/type_array/private-int64.c +++ b/level_0/f_type_array/c/type_array/private-int64.c @@ -5,27 +5,11 @@ extern "C" { #endif -#if !defined(_di_f_int64s_adjust_) || !defined(_di_f_int64s_decimate_by_) - f_status_t private_f_int64s_adjust(const f_number_unsigned_t length, f_int64s_t * const int64s) { - - const f_status_t status = f_memory_adjust(int64s->size, length, sizeof(int64_t), (void **) & int64s->array); - if (F_status_is_error(status)) return status; - - int64s->size = length; - - if (int64s->used > int64s->size) { - int64s->used = length; - } - - return F_none; - } -#endif // !defined(_di_f_int64s_adjust_) || !defined(_di_f_int64s_decimate_by_) - #if !defined(_di_f_int64s_append_) || !defined(_di_f_int64ss_append_) extern f_status_t private_f_int64s_append(const int64_t source, f_int64s_t * const destination) { - if (destination->used + 1 > destination->size) { - const f_status_t status = private_f_int64s_resize(destination->used + F_memory_default_allocation_small_d, destination); + { + const f_status_t status = f_memory_array_increase(F_memory_default_allocation_small_d, sizeof(int64_t), (void **) &destination->array, &destination->used, &destination->size); if (F_status_is_error(status)) return status; } @@ -38,8 +22,8 @@ extern "C" { #if !defined(_di_f_int64s_append_) || !defined(_di_f_int64s_append_all_) || !defined(_di_f_int64ss_append_all_) extern f_status_t private_f_int64s_append_all(const f_int64s_t source, f_int64s_t * const destination) { - if (destination->used + source.used > destination->size) { - const f_status_t status = private_f_int64s_resize(destination->used + source.used, destination); + { + const f_status_t status = f_memory_array_increase_by(source.used, sizeof(int64_t), (void **) &destination->array, &destination->used, &destination->size); if (F_status_is_error(status)) return status; } @@ -51,73 +35,33 @@ extern "C" { } #endif // !defined(_di_f_int64s_append_) || !defined(_di_f_int64s_append_all_) || !defined(_di_f_int64ss_append_all_) -#if !defined(_di_f_int64s_resize_) || !defined(_di_f_int64s_append_) || !defined(_di_f_int64s_decrease_by_) || !defined(_di_f_int64ss_append_) - f_status_t private_f_int64s_resize(const f_number_unsigned_t length, f_int64s_t * const int64s) { - - const f_status_t status = f_memory_resize(int64s->size, length, sizeof(int64_t), (void **) & int64s->array); - if (F_status_is_error(status)) return status; - - int64s->size = length; - - if (int64s->used > int64s->size) { - int64s->used = length; - } - - return F_none; - } -#endif // !defined(_di_f_int64s_resize_) || !defined(_di_f_int64s_append_) || !defined(_di_f_int64s_decrease_by_) || !defined(_di_f_int64ss_append_) - #if !defined(_di_f_int64ss_adjust_) || !defined(_di_f_int64ss_decimate_by_) - f_status_t private_f_int64ss_adjust(const f_number_unsigned_t length, f_int64ss_t * const int64ss) { + f_status_t private_f_int64ss_adjust(const f_number_unsigned_t length, f_int64ss_t * const structure) { f_status_t status = F_none; - for (f_number_unsigned_t i = length; i < int64ss->size; ++i) { + for (f_number_unsigned_t i = length; i < structure->size; ++i) { - status = f_memory_destroy(int64ss->array[i].size, sizeof(f_int64s_t), (void **) & int64ss->array[i].array); + status = f_memory_array_adjust(0, sizeof(int64_t), (void **) &structure->array[i].array, &structure->array[i].used, &structure->array[i].size); if (F_status_is_error(status)) return status; - - int64ss->array[i].size = 0; - int64ss->array[i].used = 0; } // for - status = f_memory_adjust(int64ss->size, length, sizeof(f_int64s_t), (void **) & int64ss->array); - if (F_status_is_error(status)) return status; - - int64ss->size = length; - - if (int64ss->used > int64ss->size) { - int64ss->used = length; - } - - return F_none; + return f_memory_array_adjust(length, sizeof(f_int64s_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // !defined(_di_f_int64ss_adjust_) || !defined(_di_f_int64ss_decimate_by_) #if !defined(_di_f_int64ss_decrease_by_) || !defined(_di_f_int64ss_increase_) || !defined(_di_f_int64ss_increase_by_) || !defined(_di_f_int64ss_resize_) - f_status_t private_f_int64ss_resize(const f_number_unsigned_t length, f_int64ss_t * const int64ss) { + f_status_t private_f_int64ss_resize(const f_number_unsigned_t length, f_int64ss_t * const structure) { f_status_t status = F_none; - for (f_number_unsigned_t i = length; i < int64ss->size; ++i) { + for (f_number_unsigned_t i = length; i < structure->size; ++i) { - status = f_memory_delete(int64ss->array[i].size, sizeof(f_int64s_t), (void **) & int64ss->array[i].array); + status = f_memory_array_resize(0, sizeof(int64_t), (void **) &structure->array[i].array, &structure->array[i].used, &structure->array[i].size); if (F_status_is_error(status)) return status; - - int64ss->array[i].size = 0; - int64ss->array[i].used = 0; } // for - status = f_memory_resize(int64ss->size, length, sizeof(f_int64s_t), (void **) & int64ss->array); - if (F_status_is_error(status)) return status; - - int64ss->size = length; - - if (int64ss->used > int64ss->size) { - int64ss->used = length; - } - - return F_none; + return f_memory_array_resize(length, sizeof(f_int64s_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // !defined(_di_f_int64ss_decrease_by_) || !defined(_di_f_int64ss_increase_) || !defined(_di_f_int64ss_increase_by_) || !defined(_di_f_int64ss_resize_) diff --git a/level_0/f_type_array/c/type_array/private-int64.h b/level_0/f_type_array/c/type_array/private-int64.h index f9df012..6a91436 100644 --- a/level_0/f_type_array/c/type_array/private-int64.h +++ b/level_0/f_type_array/c/type_array/private-int64.h @@ -16,29 +16,6 @@ extern "C" { #endif /** - * Private implementation for resizing the int64s array. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The length to adjust to. - * @param int64s - * The int64s array to adjust. - * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + 1 <= size). - * - * Errors (with error bit) from: f_memory_adjust(). - * - * @see f_int64s_adjust() - * @see f_int64s_decimate_by() - */ -#if !defined(_di_f_int64s_adjust_) || !defined(_di_f_int64s_decimate_by_) - extern f_status_t private_f_int64s_adjust(const f_number_unsigned_t length, f_int64s_t * const int64s) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_int64s_adjust_) || !defined(_di_f_int64s_decimate_by_) - -/** * Private implementation for appending the int64 array. * * Intended to be shared to each of the different implementation variations. @@ -51,9 +28,10 @@ extern "C" { * @return * F_none on success. * - * Errors (with error bit) from: f_memory_resize(). + * Errors (with error bit) from: f_memory_array_increase(). + * + * @see f_memory_array_increase() * - * @see f_memory_resize() * @see f_int64s_append() * @see f_int64ss_append() */ @@ -74,9 +52,10 @@ extern "C" { * @return * F_none on success. * - * 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_int64s_append_all() * @see f_int64ss_append() * @see f_int64ss_append_all() @@ -86,38 +65,13 @@ extern "C" { #endif // !defined(_di_f_int64s_append_) || !defined(_di_f_int64s_append_all_) || !defined(_di_f_int64ss_append_all_) /** - * Private implementation for resizing the int64s array. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The length to adjust to. - * @param int64s - * The int64s array to adjust. - * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + 1 <= size). - * - * Errors (with error bit) from: f_memory_resize(). - * - * @see f_int64s_resize() - * @see f_int64s_append() - * @see f_int64s_decrease_by() - * @see f_int64ss_append() - */ -#if !defined(_di_f_int64s_resize_) || !defined(_di_f_int64s_append_) || !defined(_di_f_int64s_decrease_by_) || !defined(_di_f_int64ss_append_) - extern f_status_t private_f_int64s_resize(const f_number_unsigned_t length, f_int64s_t * const int64s) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_int64s_resize_) || !defined(_di_f_int64s_append_) || !defined(_di_f_int64s_decrease_by_) || !defined(_di_f_int64ss_append_) - -/** * Private implementation for resizing the int64ss array. * * Intended to be shared to each of the different implementation variations. * * @param length * The length to adjust to. - * @param int64ss + * @param structure * The int64ss array to adjust. * * @return @@ -128,14 +82,15 @@ 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_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_int64ss_adjust() * @see f_int64ss_decimate_by() */ #if !defined(_di_f_int64ss_adjust_) || !defined(_di_f_int64ss_decimate_by_) - extern f_status_t private_f_int64ss_adjust(const f_number_unsigned_t length, f_int64ss_t * const int64ss) F_attribute_visibility_internal_d; + extern f_status_t private_f_int64ss_adjust(const f_number_unsigned_t length, f_int64ss_t * const structure) F_attribute_visibility_internal_d; #endif // !defined(_di_f_int64ss_adjust_) || !defined(_di_f_int64ss_decimate_by_) /** @@ -145,7 +100,7 @@ extern "C" { * * @param length * The length to resize to. - * @param int64ss + * @param structure * The int64ss array to resize. * * @return @@ -156,8 +111,9 @@ 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_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_int64ss_decrease_by() * @see f_int64ss_increase() @@ -165,7 +121,7 @@ extern "C" { * @see f_int64ss_resize() */ #if !defined(_di_f_int64ss_decrease_by_) || !defined(_di_f_int64ss_increase_) || !defined(_di_f_int64ss_increase_by_) || !defined(_di_f_int64ss_resize_) - extern f_status_t private_f_int64ss_resize(const f_number_unsigned_t length, f_int64ss_t * const int64ss) F_attribute_visibility_internal_d; + extern f_status_t private_f_int64ss_resize(const f_number_unsigned_t length, f_int64ss_t * const structure) F_attribute_visibility_internal_d; #endif // !defined(_di_f_int64ss_decrease_by_) || !defined(_di_f_int64ss_increase_) || !defined(_di_f_int64ss_increase_by_) || !defined(_di_f_int64ss_resize_) #ifdef __cplusplus diff --git a/level_0/f_type_array/c/type_array/private-int8.c b/level_0/f_type_array/c/type_array/private-int8.c index a57989b..2a24943 100644 --- a/level_0/f_type_array/c/type_array/private-int8.c +++ b/level_0/f_type_array/c/type_array/private-int8.c @@ -5,27 +5,11 @@ extern "C" { #endif -#if !defined(_di_f_int8s_adjust_) || !defined(_di_f_int8s_decimate_by_) - f_status_t private_f_int8s_adjust(const f_number_unsigned_t length, f_int8s_t * const int8s) { - - const f_status_t status = f_memory_adjust(int8s->size, length, sizeof(int8_t), (void **) & int8s->array); - if (F_status_is_error(status)) return status; - - int8s->size = length; - - if (int8s->used > int8s->size) { - int8s->used = length; - } - - return F_none; - } -#endif // !defined(_di_f_int8s_adjust_) || !defined(_di_f_int8s_decimate_by_) - #if !defined(_di_f_int8s_append_) || !defined(_di_f_int8ss_append_) extern f_status_t private_f_int8s_append(const int8_t source, f_int8s_t * const destination) { - if (destination->used + 1 > destination->size) { - const f_status_t status = private_f_int8s_resize(destination->used + F_memory_default_allocation_small_d, destination); + { + const f_status_t status = f_memory_array_increase(F_memory_default_allocation_small_d, sizeof(int8_t), (void **) &destination->array, &destination->used, &destination->size); if (F_status_is_error(status)) return status; } @@ -38,8 +22,8 @@ extern "C" { #if !defined(_di_f_int8s_append_) || !defined(_di_f_int8s_append_all_) || !defined(_di_f_int8ss_append_all_) extern f_status_t private_f_int8s_append_all(const f_int8s_t source, f_int8s_t * const destination) { - if (destination->used + source.used > destination->size) { - const f_status_t status = private_f_int8s_resize(destination->used + source.used, destination); + { + const f_status_t status = f_memory_array_increase_by(source.used, sizeof(int8_t), (void **) &destination->array, &destination->used, &destination->size); if (F_status_is_error(status)) return status; } @@ -51,73 +35,33 @@ extern "C" { } #endif // !defined(_di_f_int8s_append_) || !defined(_di_f_int8s_append_all_) || !defined(_di_f_int8ss_append_all_) -#if !defined(_di_f_int8s_append_) || !defined(_di_f_int8s_append_all_) || !defined(_di_f_int8s_decrease_by_) || !defined(_di_f_int8s_increase_) || !defined(_di_f_int8s_increase_by_) || !defined(_di_f_int8s_resize_) || !defined(_di_f_int8ss_append_) || !defined(_di_f_int8ss_append_all_) - f_status_t private_f_int8s_resize(const f_number_unsigned_t length, f_int8s_t * const int8s) { - - const f_status_t status = f_memory_resize(int8s->size, length, sizeof(int8_t), (void **) & int8s->array); - if (F_status_is_error(status)) return status; - - int8s->size = length; - - if (int8s->used > int8s->size) { - int8s->used = length; - } - - return F_none; - } -#endif // !defined(_di_f_int8s_append_) || !defined(_di_f_int8s_append_all_) || !defined(_di_f_int8s_decrease_by_) || !defined(_di_f_int8s_increase_) || !defined(_di_f_int8s_increase_by_) || !defined(_di_f_int8s_resize_) || !defined(_di_f_int8ss_append_) || !defined(_di_f_int8ss_append_all_) - #if !defined(_di_f_int8ss_adjust_) || !defined(_di_f_int8ss_decimate_by_) - f_status_t private_f_int8ss_adjust(const f_number_unsigned_t length, f_int8ss_t * const int8ss) { + f_status_t private_f_int8ss_adjust(const f_number_unsigned_t length, f_int8ss_t * const structure) { f_status_t status = F_none; - for (f_number_unsigned_t i = length; i < int8ss->size; ++i) { + for (f_number_unsigned_t i = length; i < structure->size; ++i) { - status = f_memory_destroy(int8ss->array[i].size, sizeof(f_int8s_t), (void **) & int8ss->array[i].array); + status = f_memory_array_adjust(0, sizeof(int8_t), (void **) &structure->array[i].array, &structure->array[i].used, &structure->array[i].size); if (F_status_is_error(status)) return status; - - int8ss->array[i].size = 0; - int8ss->array[i].used = 0; } // for - status = f_memory_adjust(int8ss->size, length, sizeof(f_int8s_t), (void **) & int8ss->array); - if (F_status_is_error(status)) return status; - - int8ss->size = length; - - if (int8ss->used > int8ss->size) { - int8ss->used = length; - } - - return F_none; + return f_memory_array_adjust(length, sizeof(f_int8s_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // !defined(_di_f_int8ss_adjust_) || !defined(_di_f_int8ss_decimate_by_) #if !defined(_di_f_int8ss_decrease_by_) || !defined(_di_f_int8ss_increase_) || !defined(_di_f_int8ss_increase_by_) || !defined(_di_f_int8ss_resize_) - f_status_t private_f_int8ss_resize(const f_number_unsigned_t length, f_int8ss_t * const int8ss) { + f_status_t private_f_int8ss_resize(const f_number_unsigned_t length, f_int8ss_t * const structure) { f_status_t status = F_none; - for (f_number_unsigned_t i = length; i < int8ss->size; ++i) { + for (f_number_unsigned_t i = length; i < structure->size; ++i) { - status = f_memory_delete(int8ss->array[i].size, sizeof(f_int8s_t), (void **) & int8ss->array[i].array); + status = f_memory_array_resize(0, sizeof(int8_t), (void **) &structure->array[i].array, &structure->array[i].used, &structure->array[i].size); if (F_status_is_error(status)) return status; - - int8ss->array[i].size = 0; - int8ss->array[i].used = 0; } // for - status = f_memory_resize(int8ss->size, length, sizeof(f_int8s_t), (void **) & int8ss->array); - if (F_status_is_error(status)) return status; - - int8ss->size = length; - - if (int8ss->used > int8ss->size) { - int8ss->used = length; - } - - return F_none; + return f_memory_array_resize(length, sizeof(f_int8s_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // !defined(_di_f_int8ss_decrease_by_) || !defined(_di_f_int8ss_increase_) || !defined(_di_f_int8ss_increase_by_) || !defined(_di_f_int8ss_resize_) diff --git a/level_0/f_type_array/c/type_array/private-int8.h b/level_0/f_type_array/c/type_array/private-int8.h index cea590a..58596c8 100644 --- a/level_0/f_type_array/c/type_array/private-int8.h +++ b/level_0/f_type_array/c/type_array/private-int8.h @@ -16,29 +16,6 @@ extern "C" { #endif /** - * Private implementation for resizing the int8s array. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The length to adjust to. - * @param int8s - * The int8s array to adjust. - * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + 1 <= size). - * - * Errors (with error bit) from: f_memory_adjust(). - * - * @see f_int8s_adjust() - * @see f_int8s_decimate_by() - */ -#if !defined(_di_f_int8s_adjust_) || !defined(_di_f_int8s_decimate_by_) - extern f_status_t private_f_int8s_adjust(const f_number_unsigned_t length, f_int8s_t * const int8s) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_int8s_adjust_) || !defined(_di_f_int8s_decimate_by_) - -/** * Private implementation for appending the int8 array. * * Intended to be shared to each of the different implementation variations. @@ -51,9 +28,10 @@ extern "C" { * @return * F_none on success. * - * Errors (with error bit) from: f_memory_resize(). + * Errors (with error bit) from: f_memory_array_increase(). + * + * @see f_memory_array_increase() * - * @see f_memory_resize() * @see f_int8s_append() * @see f_int8ss_append() */ @@ -74,9 +52,10 @@ extern "C" { * @return * F_none on success. * - * 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_int8s_append_all() * @see f_int8ss_append() * @see f_int8ss_append_all() @@ -86,43 +65,13 @@ extern "C" { #endif // !defined(_di_f_int8s_append_) || !defined(_di_f_int8s_append_all_) || !defined(_di_f_int8ss_append_all_) /** - * Private implementation for resizing the int8s array. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The length to adjust to. - * @param int8s - * The int8s array to adjust. - * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + 1 <= size). - * - * Errors (with error bit) from: f_memory_resize(). - * - * @see f_int8s_append() - * @see f_int8s_append_all() - * @see f_int8s_decrease_by() - * @see f_int8s_increase() - * @see f_int8s_increase_by() - * @see f_int8s_resize() - * @see f_int8ss_append() - * @see f_int8ss_append_all() - * - */ -#if !defined(_di_f_int8s_append_) || !defined(_di_f_int8s_append_all_) || !defined(_di_f_int8s_decrease_by_) || !defined(_di_f_int8s_increase_) || !defined(_di_f_int8s_increase_by_) || !defined(_di_f_int8s_resize_) || !defined(_di_f_int8ss_append_) || !defined(_di_f_int8ss_append_all_) - extern f_status_t private_f_int8s_resize(const f_number_unsigned_t length, f_int8s_t * const int8s) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_int8s_append_) || !defined(_di_f_int8s_append_all_) || !defined(_di_f_int8s_decrease_by_) || !defined(_di_f_int8s_increase_) || !defined(_di_f_int8s_increase_by_) || !defined(_di_f_int8s_resize_) || !defined(_di_f_int8ss_append_) || !defined(_di_f_int8ss_append_all_) - -/** * Private implementation for resizing the int8ss array. * * Intended to be shared to each of the different implementation variations. * * @param length * The length to adjust to. - * @param int8ss + * @param structure * The int8ss array to adjust. * * @return @@ -133,14 +82,15 @@ 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_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_int8ss_adjust() * @see f_int8ss_decimate_by() */ #if !defined(_di_f_int8ss_adjust_) || !defined(_di_f_int8ss_decimate_by_) - extern f_status_t private_f_int8ss_adjust(const f_number_unsigned_t length, f_int8ss_t * const int8ss) F_attribute_visibility_internal_d; + extern f_status_t private_f_int8ss_adjust(const f_number_unsigned_t length, f_int8ss_t * const structure) F_attribute_visibility_internal_d; #endif // !defined(_di_f_int8ss_adjust_) || !defined(_di_f_int8ss_decimate_by_) /** @@ -150,7 +100,7 @@ extern "C" { * * @param length * The length to resize to. - * @param int8ss + * @param structure * The int8ss array to resize. * * @return @@ -161,8 +111,9 @@ 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_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_int8ss_decrease_by() * @see f_int8ss_increase() @@ -170,7 +121,7 @@ extern "C" { * @see f_int8ss_resize() */ #if !defined(_di_f_int8ss_decrease_by_) || !defined(_di_f_int8ss_increase_) || !defined(_di_f_int8ss_increase_by_) || !defined(_di_f_int8ss_resize_) - extern f_status_t private_f_int8ss_resize(const f_number_unsigned_t length, f_int8ss_t * const int8ss) F_attribute_visibility_internal_d; + extern f_status_t private_f_int8ss_resize(const f_number_unsigned_t length, f_int8ss_t * const structure) F_attribute_visibility_internal_d; #endif // !defined(_di_f_int8ss_decrease_by_) || !defined(_di_f_int8ss_increase_) || !defined(_di_f_int8ss_increase_by_) || !defined(_di_f_int8ss_resize_) #ifdef __cplusplus diff --git a/level_0/f_type_array/c/type_array/private-number_unsigned.c b/level_0/f_type_array/c/type_array/private-number_unsigned.c index 44c4fbd..8f42ea7 100644 --- a/level_0/f_type_array/c/type_array/private-number_unsigned.c +++ b/level_0/f_type_array/c/type_array/private-number_unsigned.c @@ -5,27 +5,11 @@ extern "C" { #endif -#if !defined(_di_f_number_unsigneds_adjust_) || !defined(_di_f_number_unsigneds_decimate_by_) - f_status_t private_f_number_unsigneds_adjust(const f_number_unsigned_t length, f_number_unsigneds_t * const number_unsigneds) { - - const f_status_t status = f_memory_adjust(number_unsigneds->size, length, sizeof(f_number_unsigned_t), (void **) & number_unsigneds->array); - if (F_status_is_error(status)) return status; - - number_unsigneds->size = length; - - if (number_unsigneds->used > number_unsigneds->size) { - number_unsigneds->used = length; - } - - return F_none; - } -#endif // !defined(_di_f_number_unsigneds_adjust_) || !defined(_di_f_number_unsigneds_decimate_by_) - #if !defined(_di_f_number_unsigneds_append_) || !defined(_di_f_number_unsignedss_append_) extern f_status_t private_f_number_unsigneds_append(const f_number_unsigned_t source, f_number_unsigneds_t * const destination) { - if (destination->used + 1 > destination->size) { - const f_status_t status = private_f_number_unsigneds_resize(destination->used + F_memory_default_allocation_small_d, destination); + { + const f_status_t status = f_memory_array_increase(F_memory_default_allocation_small_d, sizeof(f_number_unsigned_t), (void **) &destination->array, &destination->used, &destination->size); if (F_status_is_error(status)) return status; } @@ -38,8 +22,8 @@ extern "C" { #if !defined(_di_f_number_unsigneds_append_) || !defined(_di_f_number_unsigneds_append_all_) || !defined(_di_f_number_unsignedss_append_all_) extern f_status_t private_f_number_unsigneds_append_all(const f_number_unsigneds_t source, f_number_unsigneds_t * const destination) { - if (destination->used + source.used > destination->size) { - const f_status_t status = private_f_number_unsigneds_resize(destination->used + source.used, destination); + { + const f_status_t status = f_memory_array_increase_by(source.used, sizeof(f_number_unsigned_t), (void **) &destination->array, &destination->used, &destination->size); if (F_status_is_error(status)) return status; } @@ -51,73 +35,33 @@ extern "C" { } #endif // !defined(_di_f_number_unsigneds_append_) || !defined(_di_f_number_unsigneds_append_all_) || !defined(_di_f_number_unsignedss_append_all_) -#if !defined(_di_f_number_unsigneds_resize_) || !defined(_di_f_number_unsigneds_append_) || !defined(_di_f_number_unsigneds_decrease_by_) || !defined(_di_f_number_unsignedss_append_) - f_status_t private_f_number_unsigneds_resize(const f_number_unsigned_t length, f_number_unsigneds_t * const lengths) { - - const f_status_t status = f_memory_resize(lengths->size, length, sizeof(f_number_unsigned_t), (void **) & lengths->array); - if (F_status_is_error(status)) return status; - - lengths->size = length; - - if (lengths->used > lengths->size) { - lengths->used = length; - } - - return F_none; - } -#endif // !defined(_di_f_number_unsigneds_resize_) || !defined(_di_f_number_unsigneds_append_) || !defined(_di_f_number_unsigneds_decrease_by_) || !defined(_di_f_number_unsignedss_append_) - #if !defined(_di_f_number_unsignedss_adjust_) || !defined(_di_f_number_unsignedss_decimate_by_) - f_status_t private_f_number_unsignedss_adjust(const f_number_unsigned_t length, f_number_unsignedss_t * const lengthss) { + f_status_t private_f_number_unsignedss_adjust(const f_number_unsigned_t length, f_number_unsignedss_t * const structure) { f_status_t status = F_none; - for (f_number_unsigned_t i = length; i < lengthss->size; ++i) { + for (f_number_unsigned_t i = length; i < structure->size; ++i) { - status = f_memory_destroy(lengthss->array[i].size, sizeof(f_number_unsigneds_t), (void **) & lengthss->array[i].array); + status = f_memory_array_adjust(0, sizeof(f_number_unsigned_t), (void **) &structure->array[i].array, &structure->array[i].used, &structure->array[i].size); if (F_status_is_error(status)) return status; - - lengthss->array[i].size = 0; - lengthss->array[i].used = 0; } // for - status = f_memory_adjust(lengthss->size, length, sizeof(f_number_unsigneds_t), (void **) & lengthss->array); - if (F_status_is_error(status)) return status; - - lengthss->size = length; - - if (lengthss->used > lengthss->size) { - lengthss->used = length; - } - - return F_none; + return f_memory_array_adjust(length, sizeof(f_number_unsigneds_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // !defined(_di_f_number_unsignedss_adjust_) || !defined(_di_f_number_unsignedss_decimate_by_) #if !defined(_di_f_number_unsignedss_decrease_by_) || !defined(_di_f_number_unsignedss_increase_) || !defined(_di_f_number_unsignedss_increase_by_) || !defined(_di_f_number_unsignedss_resize_) - f_status_t private_f_number_unsignedss_resize(const f_number_unsigned_t length, f_number_unsignedss_t * const lengthss) { + f_status_t private_f_number_unsignedss_resize(const f_number_unsigned_t length, f_number_unsignedss_t * const structure) { f_status_t status = F_none; - for (f_number_unsigned_t i = length; i < lengthss->size; ++i) { + for (f_number_unsigned_t i = length; i < structure->size; ++i) { - status = f_memory_delete(lengthss->array[i].size, sizeof(f_number_unsigneds_t), (void **) & lengthss->array[i].array); + status = f_memory_array_resize(0, sizeof(f_number_unsigned_t), (void **) &structure->array[i].array, &structure->array[i].used, &structure->array[i].size); if (F_status_is_error(status)) return status; - - lengthss->array[i].size = 0; - lengthss->array[i].used = 0; } // for - status = f_memory_resize(lengthss->size, length, sizeof(f_number_unsigneds_t), (void **) & lengthss->array); - if (F_status_is_error(status)) return status; - - lengthss->size = length; - - if (lengthss->used > lengthss->size) { - lengthss->used = length; - } - - return F_none; + return f_memory_array_resize(length, sizeof(f_number_unsigneds_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // !defined(_di_f_number_unsignedss_decrease_by_) || !defined(_di_f_number_unsignedss_increase_) || !defined(_di_f_number_unsignedss_increase_by_) || !defined(_di_f_number_unsignedss_resize_) diff --git a/level_0/f_type_array/c/type_array/private-number_unsigned.h b/level_0/f_type_array/c/type_array/private-number_unsigned.h index a945464..90f9483 100644 --- a/level_0/f_type_array/c/type_array/private-number_unsigned.h +++ b/level_0/f_type_array/c/type_array/private-number_unsigned.h @@ -16,30 +16,7 @@ extern "C" { #endif /** - * Private implementation for resizing the number array. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The length to adjust to. - * @param lengths - * The lengths array to adjust. - * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + 1 <= size). - * - * Errors (with error bit) from: f_memory_adjust(). - * - * @see f_number_unsigneds_adjust() - * @see f_number_unsigneds_decimate_by() - */ -#if !defined(_di_f_number_unsigneds_adjust_) || !defined(_di_f_number_unsigneds_decimate_by_) - extern f_status_t private_f_number_unsigneds_adjust(const f_number_unsigned_t length, f_number_unsigneds_t * const lengths) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_number_unsigneds_adjust_) || !defined(_di_f_number_unsigneds_decimate_by_) - -/** - * Private implementation for appending the number array. + * Private implementation for appending the number_unsigned array. * * Intended to be shared to each of the different implementation variations. * @@ -51,9 +28,10 @@ extern "C" { * @return * F_none on success. * - * Errors (with error bit) from: f_memory_resize(). + * Errors (with error bit) from: f_memory_array_increase(). + * + * @see f_memory_array_increase() * - * @see f_memory_resize() * @see f_number_unsigneds_append() * @see f_number_unsignedss_append() */ @@ -62,7 +40,7 @@ extern "C" { #endif // !defined(_di_f_number_unsigneds_append_) || !defined(_di_f_number_unsignedss_append_) /** - * Private implementation for appending the number array. + * Private implementation for appending the number_unsigned array. * * Intended to be shared to each of the different implementation variations. * @@ -74,9 +52,10 @@ extern "C" { * @return * F_none on success. * - * 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_number_unsigneds_append_all() * @see f_number_unsignedss_append() * @see f_number_unsignedss_append_all() @@ -86,39 +65,14 @@ extern "C" { #endif // !defined(_di_f_number_unsigneds_append_) || !defined(_di_f_number_unsigneds_append_all_) || !defined(_di_f_number_unsignedss_append_all_) /** - * Private implementation for resizing the number array. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The length to adjust to. - * @param lengths - * The lengths array to adjust. - * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + 1 <= size). - * - * Errors (with error bit) from: f_memory_resize(). - * - * @see f_number_unsigneds_resize() - * @see f_number_unsigneds_append() - * @see f_number_unsigneds_decrease_by() - * @see f_number_unsignedss_append() - */ -#if !defined(_di_f_number_unsigneds_resize_) || !defined(_di_f_number_unsigneds_append_) || !defined(_di_f_number_unsigneds_decrease_by_) || !defined(_di_f_number_unsignedss_append_) - extern f_status_t private_f_number_unsigneds_resize(const f_number_unsigned_t length, f_number_unsigneds_t * const lengths) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_number_unsigneds_resize_) || !defined(_di_f_number_unsigneds_append_) || !defined(_di_f_number_unsigneds_decrease_by_) || !defined(_di_f_number_unsignedss_append_) - -/** - * Private implementation for resizing the number array. + * Private implementation for resizing the number_unsignedss array. * * Intended to be shared to each of the different implementation variations. * * @param length * The length to adjust to. - * @param lengthss - * The number array to adjust. + * @param structure + * The number_unsignedss array to adjust. * * @return * F_none on success. @@ -128,25 +82,26 @@ 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_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_number_unsignedss_adjust() * @see f_number_unsignedss_decimate_by() */ #if !defined(_di_f_number_unsignedss_adjust_) || !defined(_di_f_number_unsignedss_decimate_by_) - extern f_status_t private_f_number_unsignedss_adjust(const f_number_unsigned_t length, f_number_unsignedss_t * const lengthss) F_attribute_visibility_internal_d; + extern f_status_t private_f_number_unsignedss_adjust(const f_number_unsigned_t length, f_number_unsignedss_t * const structure) F_attribute_visibility_internal_d; #endif // !defined(_di_f_number_unsignedss_adjust_) || !defined(_di_f_number_unsignedss_decimate_by_) /** - * Private implementation for resizing the number array. + * Private implementation for resizing the number_unsignedss array. * * Intended to be shared to each of the different implementation variations. * * @param length * The length to resize to. - * @param lengthss - * The number array to resize. + * @param structure + * The number_unsignedss array to resize. * * @return * F_none on success. @@ -156,8 +111,9 @@ 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_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_number_unsignedss_decrease_by() * @see f_number_unsignedss_increase() @@ -165,7 +121,7 @@ extern "C" { * @see f_number_unsignedss_resize() */ #if !defined(_di_f_number_unsignedss_decrease_by_) || !defined(_di_f_number_unsignedss_increase_) || !defined(_di_f_number_unsignedss_increase_by_) || !defined(_di_f_number_unsignedss_resize_) - extern f_status_t private_f_number_unsignedss_resize(const f_number_unsigned_t length, f_number_unsignedss_t * const lengthss) F_attribute_visibility_internal_d; + extern f_status_t private_f_number_unsignedss_resize(const f_number_unsigned_t length, f_number_unsignedss_t * const structure) F_attribute_visibility_internal_d; #endif // !defined(_di_f_number_unsignedss_decrease_by_) || !defined(_di_f_number_unsignedss_increase_) || !defined(_di_f_number_unsignedss_increase_by_) || !defined(_di_f_number_unsignedss_resize_) #ifdef __cplusplus diff --git a/level_0/f_type_array/c/type_array/private-poll.c b/level_0/f_type_array/c/type_array/private-poll.c index 8d0d4eb..2623355 100644 --- a/level_0/f_type_array/c/type_array/private-poll.c +++ b/level_0/f_type_array/c/type_array/private-poll.c @@ -6,27 +6,11 @@ extern "C" { #endif -#if !defined(_di_f_polls_adjust_) || !defined(_di_f_polls_decimate_by_) - f_status_t private_f_polls_adjust(const f_number_unsigned_t length, f_polls_t * const polls) { - - const f_status_t status = f_memory_adjust(polls->size, length, sizeof(f_poll_t), (void **) & polls->array); - if (F_status_is_error(status)) return status; - - polls->size = length; - - if (polls->used > polls->size) { - polls->used = length; - } - - return F_none; - } -#endif // !defined(_di_f_polls_adjust_) || !defined(_di_f_polls_decimate_by_) - #if !defined(_di_f_polls_append_) || !defined(_di_f_pollss_append_) extern f_status_t private_f_polls_append(const f_poll_t source, f_polls_t * const destination) { - if (destination->used + 1 > destination->size) { - const f_status_t status = private_f_polls_resize(destination->used + F_memory_default_allocation_small_d, destination); + { + const f_status_t status = f_memory_array_increase(F_memory_default_allocation_small_d, sizeof(f_poll_t), (void **) &destination->array, &destination->used, &destination->size); if (F_status_is_error(status)) return status; } @@ -39,8 +23,8 @@ extern "C" { #if !defined(_di_f_polls_append_) || !defined(_di_f_polls_append_all_) || !defined(_di_f_pollss_append_all_) extern f_status_t private_f_polls_append_all(const f_polls_t source, f_polls_t * const destination) { - if (destination->used + source.used > destination->size) { - const f_status_t status = private_f_polls_resize(destination->used + source.used, destination); + { + const f_status_t status = f_memory_array_increase_by(source.used, sizeof(f_poll_t), (void **) &destination->array, &destination->used, &destination->size); if (F_status_is_error(status)) return status; } @@ -52,73 +36,33 @@ extern "C" { } #endif // !defined(_di_f_polls_append_) || !defined(_di_f_polls_append_all_) || !defined(_di_f_pollss_append_all_) -#if !defined(_di_f_polls_resize_) || !defined(_di_f_polls_append_) || !defined(_di_f_polls_decrease_by_) || !defined(_di_f_pollss_append_) - f_status_t private_f_polls_resize(const f_number_unsigned_t length, f_polls_t * const polls) { - - const f_status_t status = f_memory_resize(polls->size, length, sizeof(f_poll_t), (void **) & polls->array); - if (F_status_is_error(status)) return status; - - polls->size = length; - - if (polls->used > polls->size) { - polls->used = length; - } - - return F_none; - } -#endif // !defined(_di_f_polls_resize_) || !defined(_di_f_polls_append_) || !defined(_di_f_polls_decrease_by_) || !defined(_di_f_pollss_append_) - #if !defined(_di_f_pollss_adjust_) || !defined(_di_f_pollss_decimate_by_) - f_status_t private_f_pollss_adjust(const f_number_unsigned_t length, f_pollss_t * const pollss) { + f_status_t private_f_pollss_adjust(const f_number_unsigned_t length, f_pollss_t * const structure) { f_status_t status = F_none; - for (f_number_unsigned_t i = length; i < pollss->size; ++i) { + for (f_number_unsigned_t i = length; i < structure->size; ++i) { - status = f_memory_destroy(pollss->array[i].size, sizeof(f_polls_t), (void **) & pollss->array[i].array); + status = f_memory_array_adjust(0, sizeof(f_poll_t), (void **) &structure->array[i].array, &structure->array[i].used, &structure->array[i].size); if (F_status_is_error(status)) return status; - - pollss->array[i].size = 0; - pollss->array[i].used = 0; } // for - status = f_memory_adjust(pollss->size, length, sizeof(f_polls_t), (void **) & pollss->array); - if (F_status_is_error(status)) return status; - - pollss->size = length; - - if (pollss->used > pollss->size) { - pollss->used = length; - } - - return F_none; + return f_memory_array_adjust(length, sizeof(f_polls_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // !defined(_di_f_pollss_adjust_) || !defined(_di_f_pollss_decimate_by_) #if !defined(_di_f_pollss_decrease_by_) || !defined(_di_f_pollss_increase_) || !defined(_di_f_pollss_increase_by_) || !defined(_di_f_pollss_resize_) - f_status_t private_f_pollss_resize(const f_number_unsigned_t length, f_pollss_t * const pollss) { + f_status_t private_f_pollss_resize(const f_number_unsigned_t length, f_pollss_t * const structure) { f_status_t status = F_none; - for (f_number_unsigned_t i = length; i < pollss->size; ++i) { + for (f_number_unsigned_t i = length; i < structure->size; ++i) { - status = f_memory_delete(pollss->array[i].size, sizeof(f_polls_t), (void **) & pollss->array[i].array); + status = f_memory_array_resize(0, sizeof(f_poll_t), (void **) &structure->array[i].array, &structure->array[i].used, &structure->array[i].size); if (F_status_is_error(status)) return status; - - pollss->array[i].size = 0; - pollss->array[i].used = 0; } // for - status = f_memory_resize(pollss->size, length, sizeof(f_polls_t), (void **) & pollss->array); - if (F_status_is_error(status)) return status; - - pollss->size = length; - - if (pollss->used > pollss->size) { - pollss->used = length; - } - - return F_none; + return f_memory_array_resize(length, sizeof(f_polls_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // !defined(_di_f_pollss_decrease_by_) || !defined(_di_f_pollss_increase_) || !defined(_di_f_pollss_increase_by_) || !defined(_di_f_pollss_resize_) diff --git a/level_0/f_type_array/c/type_array/private-poll.h b/level_0/f_type_array/c/type_array/private-poll.h index 934273b..0a42519 100644 --- a/level_0/f_type_array/c/type_array/private-poll.h +++ b/level_0/f_type_array/c/type_array/private-poll.h @@ -16,29 +16,6 @@ extern "C" { #endif /** - * Private implementation for resizing the polls array. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The length to adjust to. - * @param polls - * The polls array to adjust. - * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + 1 <= size). - * - * Errors (with error bit) from: f_memory_adjust(). - * - * @see f_polls_adjust() - * @see f_polls_decimate_by() - */ -#if !defined(_di_f_polls_adjust_) || !defined(_di_f_polls_decimate_by_) - extern f_status_t private_f_polls_adjust(const f_number_unsigned_t length, f_polls_t * const polls) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_polls_adjust_) || !defined(_di_f_polls_decimate_by_) - -/** * Private implementation for appending the poll array. * * Intended to be shared to each of the different implementation variations. @@ -51,9 +28,10 @@ extern "C" { * @return * F_none on success. * - * Errors (with error bit) from: f_memory_resize(). + * Errors (with error bit) from: f_memory_array_increase(). + * + * @see f_memory_array_increase() * - * @see f_memory_resize() * @see f_polls_append() * @see f_pollss_append() */ @@ -74,9 +52,10 @@ extern "C" { * @return * F_none on success. * - * 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_polls_append_all() * @see f_pollss_append() * @see f_pollss_append_all() @@ -86,38 +65,13 @@ extern "C" { #endif // !defined(_di_f_polls_append_) || !defined(_di_f_polls_append_all_) || !defined(_di_f_pollss_append_all_) /** - * Private implementation for resizing the polls array. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The length to adjust to. - * @param polls - * The polls array to adjust. - * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + 1 <= size). - * - * Errors (with error bit) from: f_memory_resize(). - * - * @see f_polls_resize() - * @see f_polls_append() - * @see f_polls_decrease_by() - * @see f_pollss_append() - */ -#if !defined(_di_f_polls_resize_) || !defined(_di_f_polls_append_) || !defined(_di_f_polls_decrease_by_) || !defined(_di_f_pollss_append_) - extern f_status_t private_f_polls_resize(const f_number_unsigned_t length, f_polls_t * const polls) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_polls_resize_) || !defined(_di_f_polls_append_) || !defined(_di_f_polls_decrease_by_) || !defined(_di_f_pollss_append_) - -/** * Private implementation for resizing the pollss array. * * Intended to be shared to each of the different implementation variations. * * @param length * The length to adjust to. - * @param pollss + * @param structure * The pollss array to adjust. * * @return @@ -128,14 +82,15 @@ 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_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_pollss_adjust() * @see f_pollss_decimate_by() */ #if !defined(_di_f_pollss_adjust_) || !defined(_di_f_pollss_decimate_by_) - extern f_status_t private_f_pollss_adjust(const f_number_unsigned_t length, f_pollss_t * const pollss) F_attribute_visibility_internal_d; + extern f_status_t private_f_pollss_adjust(const f_number_unsigned_t length, f_pollss_t * const structure) F_attribute_visibility_internal_d; #endif // !defined(_di_f_pollss_adjust_) || !defined(_di_f_pollss_decimate_by_) /** @@ -145,7 +100,7 @@ extern "C" { * * @param length * The length to resize to. - * @param pollss + * @param structure * The pollss array to resize. * * @return @@ -156,8 +111,9 @@ 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_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_pollss_decrease_by() * @see f_pollss_increase() @@ -165,7 +121,7 @@ extern "C" { * @see f_pollss_resize() */ #if !defined(_di_f_pollss_decrease_by_) || !defined(_di_f_pollss_increase_) || !defined(_di_f_pollss_increase_by_) || !defined(_di_f_pollss_resize_) - extern f_status_t private_f_pollss_resize(const f_number_unsigned_t length, f_pollss_t * const pollss) F_attribute_visibility_internal_d; + extern f_status_t private_f_pollss_resize(const f_number_unsigned_t length, f_pollss_t * const structure) F_attribute_visibility_internal_d; #endif // !defined(_di_f_pollss_decrease_by_) || !defined(_di_f_pollss_increase_) || !defined(_di_f_pollss_increase_by_) || !defined(_di_f_pollss_resize_) #ifdef __cplusplus diff --git a/level_0/f_type_array/c/type_array/private-state.c b/level_0/f_type_array/c/type_array/private-state.c index c67e4e5..b3875b0 100644 --- a/level_0/f_type_array/c/type_array/private-state.c +++ b/level_0/f_type_array/c/type_array/private-state.c @@ -5,39 +5,15 @@ extern "C" { #endif -#if !defined(_di_f_states_adjust_) || !defined(_di_f_states_decimate_by_) - f_status_t private_f_states_adjust(const f_number_unsigned_t length, f_states_t * const states) { - - const f_status_t status = f_memory_adjust(states->size, length, sizeof(f_state_t), (void **) & states->array); - if (F_status_is_error(status)) return status; - - states->size = length; - - if (states->used > states->size) { - states->used = length; - } - - return F_none; - } -#endif // !defined(_di_f_states_adjust_) || !defined(_di_f_states_decimate_by_) - #if !defined(_di_f_states_append_) || !defined(_di_f_statess_append_) extern f_status_t private_f_states_append(const f_state_t source, f_states_t * const destination) { - if (destination->used + 1 > destination->size) { - const f_status_t status = private_f_states_resize(destination->used + F_memory_default_allocation_small_d, destination); + { + const f_status_t status = f_memory_array_increase(F_memory_default_allocation_small_d, sizeof(f_state_t), (void **) &destination->array, &destination->used, &destination->size); if (F_status_is_error(status)) return status; } - destination->array[destination->used].step_large = source.step_large; - destination->array[destination->used].step_small = source.step_small; - - destination->array[destination->used].handle = source.handle; - destination->array[destination->used].interrupt = source.interrupt; - - destination->array[destination->used].callbacks = source.callbacks; - destination->array[destination->used].custom = source.custom; - destination->array[destination->used++].data = source.data; + destination->array[destination->used++] = source; return F_none; } @@ -46,95 +22,46 @@ extern "C" { #if !defined(_di_f_states_append_) || !defined(_di_f_states_append_all_) || !defined(_di_f_statess_append_all_) extern f_status_t private_f_states_append_all(const f_states_t source, f_states_t * const destination) { - if (destination->used + source.used > destination->size) { - const f_status_t status = private_f_states_resize(destination->used + source.used, destination); + { + const f_status_t status = f_memory_array_increase_by(source.used, sizeof(f_state_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].step_large = source.array[i].step_large; - destination->array[destination->used].step_small = source.array[i].step_small; - - destination->array[destination->used].handle = source.array[i].handle; - destination->array[destination->used].interrupt = source.array[i].interrupt; - - destination->array[destination->used].callbacks = source.array[i].callbacks; - destination->array[destination->used].custom = source.array[i].custom; - destination->array[destination->used++].data = source.array[i].data; + destination->array[destination->used++] = source.array[i]; } // for return F_none; } #endif // !defined(_di_f_states_append_) || !defined(_di_f_states_append_all_) || !defined(_di_f_statess_append_all_) -#if !defined(_di_f_states_resize_) || !defined(_di_f_states_append_) || !defined(_di_f_states_decrease_by_) || !defined(_di_f_statess_append_) - f_status_t private_f_states_resize(const f_number_unsigned_t length, f_states_t * const states) { - - const f_status_t status = f_memory_resize(states->size, length, sizeof(f_state_t), (void **) & states->array); - if (F_status_is_error(status)) return status; - - states->size = length; - - if (states->used > states->size) { - states->used = length; - } - - return F_none; - } -#endif // !defined(_di_f_states_resize_) || !defined(_di_f_states_append_) || !defined(_di_f_states_decrease_by_) || !defined(_di_f_statess_append_) - #if !defined(_di_f_statess_adjust_) || !defined(_di_f_statess_decimate_by_) - f_status_t private_f_statess_adjust(const f_number_unsigned_t length, f_statess_t * const statess) { + f_status_t private_f_statess_adjust(const f_number_unsigned_t length, f_statess_t * const structure) { f_status_t status = F_none; - for (f_number_unsigned_t i = length; i < statess->size; ++i) { + for (f_number_unsigned_t i = length; i < structure->size; ++i) { - status = f_memory_destroy(statess->array[i].size, sizeof(f_states_t), (void **) & statess->array[i].array); + status = f_memory_array_adjust(0, sizeof(f_state_t), (void **) &structure->array[i].array, &structure->array[i].used, &structure->array[i].size); if (F_status_is_error(status)) return status; - - statess->array[i].size = 0; - statess->array[i].used = 0; } // for - status = f_memory_adjust(statess->size, length, sizeof(f_states_t), (void **) & statess->array); - if (F_status_is_error(status)) return status; - - statess->size = length; - - if (statess->used > statess->size) { - statess->used = length; - } - - return F_none; + return f_memory_array_adjust(length, sizeof(f_states_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // !defined(_di_f_statess_adjust_) || !defined(_di_f_statess_decimate_by_) #if !defined(_di_f_statess_decrease_by_) || !defined(_di_f_statess_increase_) || !defined(_di_f_statess_increase_by_) || !defined(_di_f_statess_resize_) - f_status_t private_f_statess_resize(const f_number_unsigned_t length, f_statess_t * const statess) { + f_status_t private_f_statess_resize(const f_number_unsigned_t length, f_statess_t * const structure) { f_status_t status = F_none; - for (f_number_unsigned_t i = length; i < statess->size; ++i) { + for (f_number_unsigned_t i = length; i < structure->size; ++i) { - status = f_memory_delete(statess->array[i].size, sizeof(f_states_t), (void **) & statess->array[i].array); + status = f_memory_array_resize(0, sizeof(f_state_t), (void **) &structure->array[i].array, &structure->array[i].used, &structure->array[i].size); if (F_status_is_error(status)) return status; - - statess->array[i].size = 0; - statess->array[i].used = 0; } // for - status = f_memory_resize(statess->size, length, sizeof(f_states_t), (void **) & statess->array); - if (F_status_is_error(status)) return status; - - statess->size = length; - - if (statess->used > statess->size) { - statess->used = length; - } - - return F_none; + return f_memory_array_resize(length, sizeof(f_states_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // !defined(_di_f_statess_decrease_by_) || !defined(_di_f_statess_increase_) || !defined(_di_f_statess_increase_by_) || !defined(_di_f_statess_resize_) diff --git a/level_0/f_type_array/c/type_array/private-state.h b/level_0/f_type_array/c/type_array/private-state.h index b4d13b6..5293cd6 100644 --- a/level_0/f_type_array/c/type_array/private-state.h +++ b/level_0/f_type_array/c/type_array/private-state.h @@ -16,29 +16,6 @@ extern "C" { #endif /** - * Private implementation for resizing the states array. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The length to adjust to. - * @param states - * The states array to adjust. - * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + 1 <= size). - * - * Errors (with error bit) from: f_memory_adjust(). - * - * @see f_states_adjust() - * @see f_states_decimate_by() - */ -#if !defined(_di_f_states_adjust_) || !defined(_di_f_states_decimate_by_) - extern f_status_t private_f_states_adjust(const f_number_unsigned_t length, f_states_t * const states) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_states_adjust_) || !defined(_di_f_states_decimate_by_) - -/** * Private implementation for appending the state array. * * Intended to be shared to each of the different implementation variations. @@ -51,9 +28,10 @@ extern "C" { * @return * F_none on success. * - * Errors (with error bit) from: f_memory_resize(). + * Errors (with error bit) from: f_memory_array_increase(). + * + * @see f_memory_array_increase() * - * @see f_memory_resize() * @see f_states_append() * @see f_statess_append() */ @@ -74,9 +52,10 @@ extern "C" { * @return * F_none on success. * - * 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_states_append_all() * @see f_statess_append() * @see f_statess_append_all() @@ -86,38 +65,13 @@ extern "C" { #endif // !defined(_di_f_states_append_) || !defined(_di_f_states_append_all_) || !defined(_di_f_statess_append_all_) /** - * Private implementation for resizing the states array. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The length to adjust to. - * @param states - * The states array to adjust. - * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + 1 <= size). - * - * Errors (with error bit) from: f_memory_resize(). - * - * @see f_states_resize() - * @see f_states_append() - * @see f_states_decrease_by() - * @see f_statess_append() - */ -#if !defined(_di_f_states_resize_) || !defined(_di_f_states_append_) || !defined(_di_f_states_decrease_by_) || !defined(_di_f_statess_append_) - extern f_status_t private_f_states_resize(const f_number_unsigned_t length, f_states_t * const states) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_states_resize_) || !defined(_di_f_states_append_) || !defined(_di_f_states_decrease_by_) || !defined(_di_f_statess_append_) - -/** * Private implementation for resizing the statess array. * * Intended to be shared to each of the different implementation variations. * * @param length * The length to adjust to. - * @param statess + * @param structure * The statess array to adjust. * * @return @@ -128,14 +82,15 @@ 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_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_statess_adjust() * @see f_statess_decimate_by() */ #if !defined(_di_f_statess_adjust_) || !defined(_di_f_statess_decimate_by_) - extern f_status_t private_f_statess_adjust(const f_number_unsigned_t length, f_statess_t * const statess) F_attribute_visibility_internal_d; + extern f_status_t private_f_statess_adjust(const f_number_unsigned_t length, f_statess_t * const structure) F_attribute_visibility_internal_d; #endif // !defined(_di_f_statess_adjust_) || !defined(_di_f_statess_decimate_by_) /** @@ -145,7 +100,7 @@ extern "C" { * * @param length * The length to resize to. - * @param statess + * @param structure * The statess array to resize. * * @return @@ -156,8 +111,9 @@ 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_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_statess_decrease_by() * @see f_statess_increase() @@ -165,7 +121,7 @@ extern "C" { * @see f_statess_resize() */ #if !defined(_di_f_statess_decrease_by_) || !defined(_di_f_statess_increase_) || !defined(_di_f_statess_increase_by_) || !defined(_di_f_statess_resize_) - extern f_status_t private_f_statess_resize(const f_number_unsigned_t length, f_statess_t * const statess) F_attribute_visibility_internal_d; + extern f_status_t private_f_statess_resize(const f_number_unsigned_t length, f_statess_t * const structure) F_attribute_visibility_internal_d; #endif // !defined(_di_f_statess_decrease_by_) || !defined(_di_f_statess_increase_) || !defined(_di_f_statess_increase_by_) || !defined(_di_f_statess_resize_) #ifdef __cplusplus diff --git a/level_0/f_type_array/c/type_array/private-status.c b/level_0/f_type_array/c/type_array/private-status.c index 2f27be8..659e2c0 100644 --- a/level_0/f_type_array/c/type_array/private-status.c +++ b/level_0/f_type_array/c/type_array/private-status.c @@ -5,27 +5,11 @@ extern "C" { #endif -#if !defined(_di_f_statuss_adjust_) || !defined(_di_f_statuss_decimate_by_) - f_status_t private_f_statuss_adjust(const f_number_unsigned_t length, f_statuss_t * const statuss) { - - const f_status_t status = f_memory_adjust(statuss->size, length, sizeof(f_status_t), (void **) & statuss->array); - if (F_status_is_error(status)) return status; - - statuss->size = length; - - if (statuss->used > statuss->size) { - statuss->used = length; - } - - return F_none; - } -#endif // !defined(_di_f_statuss_adjust_) || !defined(_di_f_statuss_decimate_by_) - #if !defined(_di_f_statuss_append_) || !defined(_di_f_statusss_append_) extern f_status_t private_f_statuss_append(const f_status_t source, f_statuss_t * const destination) { - if (destination->used + 1 > destination->size) { - const f_status_t status = private_f_statuss_resize(destination->used + F_memory_default_allocation_small_d, destination); + { + const f_status_t status = f_memory_array_increase(F_memory_default_allocation_small_d, sizeof(f_status_t), (void **) &destination->array, &destination->used, &destination->size); if (F_status_is_error(status)) return status; } @@ -38,8 +22,8 @@ extern "C" { #if !defined(_di_f_statuss_append_) || !defined(_di_f_statuss_append_all_) || !defined(_di_f_statusss_append_all_) extern f_status_t private_f_statuss_append_all(const f_statuss_t source, f_statuss_t * const destination) { - if (destination->used + source.used > destination->size) { - const f_status_t status = private_f_statuss_resize(destination->used + source.used, destination); + { + const f_status_t status = f_memory_array_increase_by(source.used, sizeof(f_status_t), (void **) &destination->array, &destination->used, &destination->size); if (F_status_is_error(status)) return status; } @@ -51,73 +35,33 @@ extern "C" { } #endif // !defined(_di_f_statuss_append_) || !defined(_di_f_statuss_append_all_) || !defined(_di_f_statusss_append_all_) -#if !defined(_di_f_statuss_resize_) || !defined(_di_f_statuss_append_) || !defined(_di_f_statuss_decrease_by_) || !defined(_di_f_statusss_append_) - f_status_t private_f_statuss_resize(const f_number_unsigned_t length, f_statuss_t * const statuss) { - - const f_status_t status = f_memory_resize(statuss->size, length, sizeof(f_status_t), (void **) & statuss->array); - if (F_status_is_error(status)) return status; - - statuss->size = length; - - if (statuss->used > statuss->size) { - statuss->used = length; - } - - return F_none; - } -#endif // !defined(_di_f_statuss_resize_) || !defined(_di_f_statuss_append_) || !defined(_di_f_statuss_decrease_by_) || !defined(_di_f_statusss_append_) - #if !defined(_di_f_statusss_adjust_) || !defined(_di_f_statusss_decimate_by_) - f_status_t private_f_statusss_adjust(const f_number_unsigned_t length, f_statusss_t * const statusss) { + f_status_t private_f_statusss_adjust(const f_number_unsigned_t length, f_statusss_t * const structure) { f_status_t status = F_none; - for (f_number_unsigned_t i = length; i < statusss->size; ++i) { + for (f_number_unsigned_t i = length; i < structure->size; ++i) { - status = f_memory_destroy(statusss->array[i].size, sizeof(f_statuss_t), (void **) & statusss->array[i].array); + status = f_memory_array_adjust(0, sizeof(f_status_t), (void **) &structure->array[i].array, &structure->array[i].used, &structure->array[i].size); if (F_status_is_error(status)) return status; - - statusss->array[i].size = 0; - statusss->array[i].used = 0; } // for - status = f_memory_adjust(statusss->size, length, sizeof(f_statuss_t), (void **) & statusss->array); - if (F_status_is_error(status)) return status; - - statusss->size = length; - - if (statusss->used > statusss->size) { - statusss->used = length; - } - - return F_none; + return f_memory_array_adjust(length, sizeof(f_statuss_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // !defined(_di_f_statusss_adjust_) || !defined(_di_f_statusss_decimate_by_) #if !defined(_di_f_statusss_decrease_by_) || !defined(_di_f_statusss_increase_) || !defined(_di_f_statusss_increase_by_) || !defined(_di_f_statusss_resize_) - f_status_t private_f_statusss_resize(const f_number_unsigned_t length, f_statusss_t * const statusss) { + f_status_t private_f_statusss_resize(const f_number_unsigned_t length, f_statusss_t * const structure) { f_status_t status = F_none; - for (f_number_unsigned_t i = length; i < statusss->size; ++i) { + for (f_number_unsigned_t i = length; i < structure->size; ++i) { - status = f_memory_delete(statusss->array[i].size, sizeof(f_statuss_t), (void **) & statusss->array[i].array); + status = f_memory_array_resize(0, sizeof(f_status_t), (void **) &structure->array[i].array, &structure->array[i].used, &structure->array[i].size); if (F_status_is_error(status)) return status; - - statusss->array[i].size = 0; - statusss->array[i].used = 0; } // for - status = f_memory_resize(statusss->size, length, sizeof(f_statuss_t), (void **) & statusss->array); - if (F_status_is_error(status)) return status; - - statusss->size = length; - - if (statusss->used > statusss->size) { - statusss->used = length; - } - - return F_none; + return f_memory_array_resize(length, sizeof(f_statuss_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // !defined(_di_f_statusss_decrease_by_) || !defined(_di_f_statusss_increase_) || !defined(_di_f_statusss_increase_by_) || !defined(_di_f_statusss_resize_) diff --git a/level_0/f_type_array/c/type_array/private-status.h b/level_0/f_type_array/c/type_array/private-status.h index 49bb7de..3c099d7 100644 --- a/level_0/f_type_array/c/type_array/private-status.h +++ b/level_0/f_type_array/c/type_array/private-status.h @@ -16,29 +16,6 @@ extern "C" { #endif /** - * Private implementation for resizing the statuss array. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The length to adjust to. - * @param statuss - * The statuss array to adjust. - * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + 1 <= size). - * - * Errors (with error bit) from: f_memory_adjust(). - * - * @see f_statuss_adjust() - * @see f_statuss_decimate_by() - */ -#if !defined(_di_f_statuss_adjust_) || !defined(_di_f_statuss_decimate_by_) - extern f_status_t private_f_statuss_adjust(const f_number_unsigned_t length, f_statuss_t * const statuss) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_statuss_adjust_) || !defined(_di_f_statuss_decimate_by_) - -/** * Private implementation for appending the status array. * * Intended to be shared to each of the different implementation variations. @@ -51,9 +28,10 @@ extern "C" { * @return * F_none on success. * - * Errors (with error bit) from: f_memory_resize(). + * Errors (with error bit) from: f_memory_array_increase(). + * + * @see f_memory_array_increase() * - * @see f_memory_resize() * @see f_statuss_append() * @see f_statusss_append() */ @@ -74,9 +52,10 @@ extern "C" { * @return * F_none on success. * - * 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_statuss_append_all() * @see f_statusss_append() * @see f_statusss_append_all() @@ -86,38 +65,13 @@ extern "C" { #endif // !defined(_di_f_statuss_append_) || !defined(_di_f_statuss_append_all_) || !defined(_di_f_statusss_append_all_) /** - * Private implementation for resizing the statuss array. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The length to adjust to. - * @param statuss - * The statuss array to adjust. - * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + 1 <= size). - * - * Errors (with error bit) from: f_memory_resize(). - * - * @see f_statuss_resize() - * @see f_statuss_append() - * @see f_statuss_decrease_by() - * @see f_statusss_append() - */ -#if !defined(_di_f_statuss_resize_) || !defined(_di_f_statuss_append_) || !defined(_di_f_statuss_decrease_by_) || !defined(_di_f_statusss_append_) - extern f_status_t private_f_statuss_resize(const f_number_unsigned_t length, f_statuss_t * const statuss) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_statuss_resize_) || !defined(_di_f_statuss_append_) || !defined(_di_f_statuss_decrease_by_) || !defined(_di_f_statusss_append_) - -/** * Private implementation for resizing the statusss array. * * Intended to be shared to each of the different implementation variations. * * @param length * The length to adjust to. - * @param statusss + * @param structure * The statusss array to adjust. * * @return @@ -128,14 +82,15 @@ 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_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_statusss_adjust() * @see f_statusss_decimate_by() */ #if !defined(_di_f_statusss_adjust_) || !defined(_di_f_statusss_decimate_by_) - extern f_status_t private_f_statusss_adjust(const f_number_unsigned_t length, f_statusss_t * const statusss) F_attribute_visibility_internal_d; + extern f_status_t private_f_statusss_adjust(const f_number_unsigned_t length, f_statusss_t * const structure) F_attribute_visibility_internal_d; #endif // !defined(_di_f_statusss_adjust_) || !defined(_di_f_statusss_decimate_by_) /** @@ -145,7 +100,7 @@ extern "C" { * * @param length * The length to resize to. - * @param statusss + * @param structure * The statusss array to resize. * * @return @@ -156,8 +111,9 @@ 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_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_statusss_decrease_by() * @see f_statusss_increase() @@ -165,7 +121,7 @@ extern "C" { * @see f_statusss_resize() */ #if !defined(_di_f_statusss_decrease_by_) || !defined(_di_f_statusss_increase_) || !defined(_di_f_statusss_increase_by_) || !defined(_di_f_statusss_resize_) - extern f_status_t private_f_statusss_resize(const f_number_unsigned_t length, f_statusss_t * const statusss) F_attribute_visibility_internal_d; + extern f_status_t private_f_statusss_resize(const f_number_unsigned_t length, f_statusss_t * const structure) F_attribute_visibility_internal_d; #endif // !defined(_di_f_statusss_decrease_by_) || !defined(_di_f_statusss_increase_) || !defined(_di_f_statusss_increase_by_) || !defined(_di_f_statusss_resize_) #ifdef __cplusplus diff --git a/level_0/f_type_array/c/type_array/private-uint128.c b/level_0/f_type_array/c/type_array/private-uint128.c index 2135b79..86c735b 100644 --- a/level_0/f_type_array/c/type_array/private-uint128.c +++ b/level_0/f_type_array/c/type_array/private-uint128.c @@ -5,27 +5,11 @@ extern "C" { #endif -#if !defined(_di_f_uint128s_adjust_) || !defined(_di_f_uint128s_decimate_by_) - f_status_t private_f_uint128s_adjust(const f_number_unsigned_t length, f_uint128s_t * const uint128s) { - - const f_status_t status = f_memory_adjust(uint128s->size, length, sizeof(f_uint128s_t), (void **) & uint128s->array); - if (F_status_is_error(status)) return status; - - uint128s->size = length; - - if (uint128s->used > uint128s->size) { - uint128s->used = length; - } - - return F_none; - } -#endif // !defined(_di_f_uint128s_adjust_) || !defined(_di_f_uint128s_decimate_by_) - #if !defined(_di_f_uint128s_append_) || !defined(_di_f_uint128ss_append_) extern f_status_t private_f_uint128s_append(const uint128_t source, f_uint128s_t * const destination) { - if (destination->used + 1 > destination->size) { - const f_status_t status = private_f_uint128s_resize(destination->used + F_memory_default_allocation_small_d, destination); + { + const f_status_t status = f_memory_array_increase(F_memory_default_allocation_small_d, sizeof(uint128_t), (void **) &destination->array, &destination->used, &destination->size); if (F_status_is_error(status)) return status; } @@ -38,8 +22,8 @@ extern "C" { #if !defined(_di_f_uint128s_append_) || !defined(_di_f_uint128s_append_all_) || !defined(_di_f_uint128ss_append_all_) extern f_status_t private_f_uint128s_append_all(const f_uint128s_t source, f_uint128s_t * const destination) { - if (destination->used + source.used > destination->size) { - const f_status_t status = private_f_uint128s_resize(destination->used + source.used, destination); + { + const f_status_t status = f_memory_array_increase_by(source.used, sizeof(uint128_t), (void **) &destination->array, &destination->used, &destination->size); if (F_status_is_error(status)) return status; } @@ -51,73 +35,33 @@ extern "C" { } #endif // !defined(_di_f_uint128s_append_) || !defined(_di_f_uint128s_append_all_) || !defined(_di_f_uint128ss_append_all_) -#if !defined(_di_f_uint128s_resize_) || !defined(_di_f_uint128s_append_) || !defined(_di_f_uint128s_decrease_by_) || !defined(_di_f_uint128ss_append_) - f_status_t private_f_uint128s_resize(const f_number_unsigned_t length, f_uint128s_t * const uint128s) { - - const f_status_t status = f_memory_resize(uint128s->size, length, sizeof(f_uint128s_t), (void **) & uint128s->array); - if (F_status_is_error(status)) return status; - - uint128s->size = length; - - if (uint128s->used > uint128s->size) { - uint128s->used = length; - } - - return F_none; - } -#endif // !defined(_di_f_uint128s_resize_) || !defined(_di_f_uint128s_append_) || !defined(_di_f_uint128s_decrease_by_) || !defined(_di_f_uint128ss_append_) - #if !defined(_di_f_uint128ss_adjust_) || !defined(_di_f_uint128ss_decimate_by_) - f_status_t private_f_uint128ss_adjust(const f_number_unsigned_t length, f_uint128ss_t * const uint128ss) { + f_status_t private_f_uint128ss_adjust(const f_number_unsigned_t length, f_uint128ss_t * const structure) { f_status_t status = F_none; - for (f_number_unsigned_t i = length; i < uint128ss->size; ++i) { + for (f_number_unsigned_t i = length; i < structure->size; ++i) { - status = f_memory_destroy(uint128ss->array[i].size, sizeof(f_uint128s_t), (void **) & uint128ss->array[i].array); + status = f_memory_array_adjust(0, sizeof(uint128_t), (void **) &structure->array[i].array, &structure->array[i].used, &structure->array[i].size); if (F_status_is_error(status)) return status; - - uint128ss->array[i].size = 0; - uint128ss->array[i].used = 0; } // for - status = f_memory_adjust(uint128ss->size, length, sizeof(f_uint128s_t), (void **) & uint128ss->array); - if (F_status_is_error(status)) return status; - - uint128ss->size = length; - - if (uint128ss->used > uint128ss->size) { - uint128ss->used = length; - } - - return F_none; + return f_memory_array_adjust(length, sizeof(f_uint128s_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // !defined(_di_f_uint128ss_adjust_) || !defined(_di_f_uint128ss_decimate_by_) #if !defined(_di_f_uint128ss_decrease_by_) || !defined(_di_f_uint128ss_increase_) || !defined(_di_f_uint128ss_increase_by_) || !defined(_di_f_uint128ss_resize_) - f_status_t private_f_uint128ss_resize(const f_number_unsigned_t length, f_uint128ss_t * const uint128ss) { + f_status_t private_f_uint128ss_resize(const f_number_unsigned_t length, f_uint128ss_t * const structure) { f_status_t status = F_none; - for (f_number_unsigned_t i = length; i < uint128ss->size; ++i) { + for (f_number_unsigned_t i = length; i < structure->size; ++i) { - status = f_memory_delete(uint128ss->array[i].size, sizeof(f_uint128s_t), (void **) & uint128ss->array[i].array); + status = f_memory_array_resize(0, sizeof(uint128_t), (void **) &structure->array[i].array, &structure->array[i].used, &structure->array[i].size); if (F_status_is_error(status)) return status; - - uint128ss->array[i].size = 0; - uint128ss->array[i].used = 0; } // for - status = f_memory_resize(uint128ss->size, length, sizeof(f_uint128s_t), (void **) & uint128ss->array); - if (F_status_is_error(status)) return status; - - uint128ss->size = length; - - if (uint128ss->used > uint128ss->size) { - uint128ss->used = length; - } - - return F_none; + return f_memory_array_resize(length, sizeof(f_uint128s_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // !defined(_di_f_uint128ss_decrease_by_) || !defined(_di_f_uint128ss_increase_) || !defined(_di_f_uint128ss_increase_by_) || !defined(_di_f_uint128ss_resize_) diff --git a/level_0/f_type_array/c/type_array/private-uint128.h b/level_0/f_type_array/c/type_array/private-uint128.h index 0bb1716..62edda5 100644 --- a/level_0/f_type_array/c/type_array/private-uint128.h +++ b/level_0/f_type_array/c/type_array/private-uint128.h @@ -16,29 +16,6 @@ extern "C" { #endif /** - * Private implementation for resizing the uint128s array. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The length to adjust to. - * @param uint128s - * The uint128s array to adjust. - * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + 1 <= size). - * - * Errors (with error bit) from: f_memory_adjust(). - * - * @see f_uint128s_adjust() - * @see f_uint128s_decimate_by() - */ -#if !defined(_di_f_uint128s_adjust_) || !defined(_di_f_uint128s_decimate_by_) - extern f_status_t private_f_uint128s_adjust(const f_number_unsigned_t length, f_uint128s_t * const uint128s) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_uint128s_adjust_) || !defined(_di_f_uint128s_decimate_by_) - -/** * Private implementation for appending the uint128 array. * * Intended to be shared to each of the different implementation variations. @@ -51,9 +28,10 @@ extern "C" { * @return * F_none on success. * - * Errors (with error bit) from: f_memory_resize(). + * Errors (with error bit) from: f_memory_array_increase(). + * + * @see f_memory_array_increase() * - * @see f_memory_resize() * @see f_uint128s_append() * @see f_uint128ss_append() */ @@ -74,9 +52,10 @@ extern "C" { * @return * F_none on success. * - * 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_uint128s_append_all() * @see f_uint128ss_append() * @see f_uint128ss_append_all() @@ -86,38 +65,13 @@ extern "C" { #endif // !defined(_di_f_uint128s_append_) || !defined(_di_f_uint128s_append_all_) || !defined(_di_f_uint128ss_append_all_) /** - * Private implementation for resizing the uint128s array. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The length to adjust to. - * @param uint128s - * The uint128s array to adjust. - * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + 1 <= size). - * - * Errors (with error bit) from: f_memory_resize(). - * - * @see f_uint128s_resize() - * @see f_uint128s_append() - * @see f_uint128s_decrease_by() - * @see f_uint128ss_append() - */ -#if !defined(_di_f_uint128s_resize_) || !defined(_di_f_uint128s_append_) || !defined(_di_f_uint128s_decrease_by_) || !defined(_di_f_uint128ss_append_) - extern f_status_t private_f_uint128s_resize(const f_number_unsigned_t length, f_uint128s_t * const uint128s) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_uint128s_resize_) || !defined(_di_f_uint128s_append_) || !defined(_di_f_uint128s_decrease_by_) || !defined(_di_f_uint128ss_append_) - -/** * Private implementation for resizing the uint128ss array. * * Intended to be shared to each of the different implementation variations. * * @param length * The length to adjust to. - * @param uint128ss + * @param structure * The uint128ss array to adjust. * * @return @@ -128,14 +82,15 @@ 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_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_uint128ss_adjust() * @see f_uint128ss_decimate_by() */ #if !defined(_di_f_uint128ss_adjust_) || !defined(_di_f_uint128ss_decimate_by_) - extern f_status_t private_f_uint128ss_adjust(const f_number_unsigned_t length, f_uint128ss_t * const uint128ss) F_attribute_visibility_internal_d; + extern f_status_t private_f_uint128ss_adjust(const f_number_unsigned_t length, f_uint128ss_t * const structure) F_attribute_visibility_internal_d; #endif // !defined(_di_f_uint128ss_adjust_) || !defined(_di_f_uint128ss_decimate_by_) /** @@ -145,7 +100,7 @@ extern "C" { * * @param length * The length to resize to. - * @param uint128ss + * @param structure * The uint128ss array to resize. * * @return @@ -156,8 +111,9 @@ 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_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_uint128ss_decrease_by() * @see f_uint128ss_increase() @@ -165,7 +121,7 @@ extern "C" { * @see f_uint128ss_resize() */ #if !defined(_di_f_uint128ss_decrease_by_) || !defined(_di_f_uint128ss_increase_) || !defined(_di_f_uint128ss_increase_by_) || !defined(_di_f_uint128ss_resize_) - extern f_status_t private_f_uint128ss_resize(const f_number_unsigned_t length, f_uint128ss_t * const uint128ss) F_attribute_visibility_internal_d; + extern f_status_t private_f_uint128ss_resize(const f_number_unsigned_t length, f_uint128ss_t * const structure) F_attribute_visibility_internal_d; #endif // !defined(_di_f_uint128ss_decrease_by_) || !defined(_di_f_uint128ss_increase_) || !defined(_di_f_uint128ss_increase_by_) || !defined(_di_f_uint128ss_resize_) #ifdef __cplusplus diff --git a/level_0/f_type_array/c/type_array/private-uint16.c b/level_0/f_type_array/c/type_array/private-uint16.c index 31b7065..e1c7063 100644 --- a/level_0/f_type_array/c/type_array/private-uint16.c +++ b/level_0/f_type_array/c/type_array/private-uint16.c @@ -5,27 +5,11 @@ extern "C" { #endif -#if !defined(_di_f_uint16s_adjust_) || !defined(_di_f_uint16s_decimate_by_) - f_status_t private_f_uint16s_adjust(const f_number_unsigned_t length, f_uint16s_t * const uint16s) { - - const f_status_t status = f_memory_adjust(uint16s->size, length, sizeof(uint16_t), (void **) & uint16s->array); - if (F_status_is_error(status)) return status; - - uint16s->size = length; - - if (uint16s->used > uint16s->size) { - uint16s->used = length; - } - - return F_none; - } -#endif // !defined(_di_f_uint16s_adjust_) || !defined(_di_f_uint16s_decimate_by_) - #if !defined(_di_f_uint16s_append_) || !defined(_di_f_uint16ss_append_) extern f_status_t private_f_uint16s_append(const uint16_t source, f_uint16s_t * const destination) { - if (destination->used + 1 > destination->size) { - const f_status_t status = private_f_uint16s_resize(destination->used + F_memory_default_allocation_small_d, destination); + { + const f_status_t status = f_memory_array_increase(F_memory_default_allocation_small_d, sizeof(uint16_t), (void **) &destination->array, &destination->used, &destination->size); if (F_status_is_error(status)) return status; } @@ -38,8 +22,8 @@ extern "C" { #if !defined(_di_f_uint16s_append_) || !defined(_di_f_uint16s_append_all_) || !defined(_di_f_uint16ss_append_all_) extern f_status_t private_f_uint16s_append_all(const f_uint16s_t source, f_uint16s_t * const destination) { - if (destination->used + source.used > destination->size) { - const f_status_t status = private_f_uint16s_resize(destination->used + source.used, destination); + { + const f_status_t status = f_memory_array_increase_by(source.used, sizeof(uint16_t), (void **) &destination->array, &destination->used, &destination->size); if (F_status_is_error(status)) return status; } @@ -51,73 +35,33 @@ extern "C" { } #endif // !defined(_di_f_uint16s_append_) || !defined(_di_f_uint16s_append_all_) || !defined(_di_f_uint16ss_append_all_) -#if !defined(_di_f_uint16s_resize_) || !defined(_di_f_uint16s_append_) || !defined(_di_f_uint16s_decrease_by_) || !defined(_di_f_uint16ss_append_) - f_status_t private_f_uint16s_resize(const f_number_unsigned_t length, f_uint16s_t * const uint16s) { - - const f_status_t status = f_memory_resize(uint16s->size, length, sizeof(uint16_t), (void **) & uint16s->array); - if (F_status_is_error(status)) return status; - - uint16s->size = length; - - if (uint16s->used > uint16s->size) { - uint16s->used = length; - } - - return F_none; - } -#endif // !defined(_di_f_uint16s_resize_) || !defined(_di_f_uint16s_append_) || !defined(_di_f_uint16s_decrease_by_) || !defined(_di_f_uint16ss_append_) - #if !defined(_di_f_uint16ss_adjust_) || !defined(_di_f_uint16ss_decimate_by_) - f_status_t private_f_uint16ss_adjust(const f_number_unsigned_t length, f_uint16ss_t * const uint16ss) { + f_status_t private_f_uint16ss_adjust(const f_number_unsigned_t length, f_uint16ss_t * const structure) { f_status_t status = F_none; - for (f_number_unsigned_t i = length; i < uint16ss->size; ++i) { + for (f_number_unsigned_t i = length; i < structure->size; ++i) { - status = f_memory_destroy(uint16ss->array[i].size, sizeof(f_uint16s_t), (void **) & uint16ss->array[i].array); + status = f_memory_array_adjust(0, sizeof(uint16_t), (void **) &structure->array[i].array, &structure->array[i].used, &structure->array[i].size); if (F_status_is_error(status)) return status; - - uint16ss->array[i].size = 0; - uint16ss->array[i].used = 0; } // for - status = f_memory_adjust(uint16ss->size, length, sizeof(f_uint16s_t), (void **) & uint16ss->array); - if (F_status_is_error(status)) return status; - - uint16ss->size = length; - - if (uint16ss->used > uint16ss->size) { - uint16ss->used = length; - } - - return F_none; + return f_memory_array_adjust(length, sizeof(f_uint16s_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // !defined(_di_f_uint16ss_adjust_) || !defined(_di_f_uint16ss_decimate_by_) #if !defined(_di_f_uint16ss_decrease_by_) || !defined(_di_f_uint16ss_increase_) || !defined(_di_f_uint16ss_increase_by_) || !defined(_di_f_uint16ss_resize_) - f_status_t private_f_uint16ss_resize(const f_number_unsigned_t length, f_uint16ss_t * const uint16ss) { + f_status_t private_f_uint16ss_resize(const f_number_unsigned_t length, f_uint16ss_t * const structure) { f_status_t status = F_none; - for (f_number_unsigned_t i = length; i < uint16ss->size; ++i) { + for (f_number_unsigned_t i = length; i < structure->size; ++i) { - status = f_memory_delete(uint16ss->array[i].size, sizeof(f_uint16s_t), (void **) & uint16ss->array[i].array); + status = f_memory_array_resize(0, sizeof(uint16_t), (void **) &structure->array[i].array, &structure->array[i].used, &structure->array[i].size); if (F_status_is_error(status)) return status; - - uint16ss->array[i].size = 0; - uint16ss->array[i].used = 0; } // for - status = f_memory_resize(uint16ss->size, length, sizeof(f_uint16s_t), (void **) & uint16ss->array); - if (F_status_is_error(status)) return status; - - uint16ss->size = length; - - if (uint16ss->used > uint16ss->size) { - uint16ss->used = length; - } - - return F_none; + return f_memory_array_resize(length, sizeof(f_uint16s_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // !defined(_di_f_uint16ss_decrease_by_) || !defined(_di_f_uint16ss_increase_) || !defined(_di_f_uint16ss_increase_by_) || !defined(_di_f_uint16ss_resize_) diff --git a/level_0/f_type_array/c/type_array/private-uint16.h b/level_0/f_type_array/c/type_array/private-uint16.h index 8997b66..641a4e2 100644 --- a/level_0/f_type_array/c/type_array/private-uint16.h +++ b/level_0/f_type_array/c/type_array/private-uint16.h @@ -16,29 +16,6 @@ extern "C" { #endif /** - * Private implementation for resizing the uint16s array. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The length to adjust to. - * @param uint16s - * The uint16s array to adjust. - * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + 1 <= size). - * - * Errors (with error bit) from: f_memory_adjust(). - * - * @see f_uint16s_adjust() - * @see f_uint16s_decimate_by() - */ -#if !defined(_di_f_uint16s_adjust_) || !defined(_di_f_uint16s_decimate_by_) - extern f_status_t private_f_uint16s_adjust(const f_number_unsigned_t length, f_uint16s_t * const uint16s) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_uint16s_adjust_) || !defined(_di_f_uint16s_decimate_by_) - -/** * Private implementation for appending the uint16 array. * * Intended to be shared to each of the different implementation variations. @@ -51,9 +28,10 @@ extern "C" { * @return * F_none on success. * - * Errors (with error bit) from: f_memory_resize(). + * Errors (with error bit) from: f_memory_array_increase(). + * + * @see f_memory_array_increase() * - * @see f_memory_resize() * @see f_uint16s_append() * @see f_uint16ss_append() */ @@ -74,9 +52,10 @@ extern "C" { * @return * F_none on success. * - * 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_uint16s_append_all() * @see f_uint16ss_append() * @see f_uint16ss_append_all() @@ -86,38 +65,13 @@ extern "C" { #endif // !defined(_di_f_uint16s_append_) || !defined(_di_f_uint16s_append_all_) || !defined(_di_f_uint16ss_append_all_) /** - * Private implementation for resizing the uint16s array. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The length to adjust to. - * @param uint16s - * The uint16s array to adjust. - * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + 1 <= size). - * - * Errors (with error bit) from: f_memory_resize(). - * - * @see f_uint16s_resize() - * @see f_uint16s_append() - * @see f_uint16s_decrease_by() - * @see f_uint16ss_append() - */ -#if !defined(_di_f_uint16s_resize_) || !defined(_di_f_uint16s_append_) || !defined(_di_f_uint16s_decrease_by_) || !defined(_di_f_uint16ss_append_) - extern f_status_t private_f_uint16s_resize(const f_number_unsigned_t length, f_uint16s_t * const uint16s) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_uint16s_resize_) || !defined(_di_f_uint16s_append_) || !defined(_di_f_uint16s_decrease_by_) || !defined(_di_f_uint16ss_append_) - -/** * Private implementation for resizing the uint16ss array. * * Intended to be shared to each of the different implementation variations. * * @param length * The length to adjust to. - * @param uint16ss + * @param structure * The uint16ss array to adjust. * * @return @@ -128,14 +82,15 @@ 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_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_uint16ss_adjust() * @see f_uint16ss_decimate_by() */ #if !defined(_di_f_uint16ss_adjust_) || !defined(_di_f_uint16ss_decimate_by_) - extern f_status_t private_f_uint16ss_adjust(const f_number_unsigned_t length, f_uint16ss_t * const uint16ss) F_attribute_visibility_internal_d; + extern f_status_t private_f_uint16ss_adjust(const f_number_unsigned_t length, f_uint16ss_t * const structure) F_attribute_visibility_internal_d; #endif // !defined(_di_f_uint16ss_adjust_) || !defined(_di_f_uint16ss_decimate_by_) /** @@ -145,7 +100,7 @@ extern "C" { * * @param length * The length to resize to. - * @param uint16ss + * @param structure * The uint16ss array to resize. * * @return @@ -156,8 +111,9 @@ 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_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_uint16ss_decrease_by() * @see f_uint16ss_increase() @@ -165,7 +121,7 @@ extern "C" { * @see f_uint16ss_resize() */ #if !defined(_di_f_uint16ss_decrease_by_) || !defined(_di_f_uint16ss_increase_) || !defined(_di_f_uint16ss_increase_by_) || !defined(_di_f_uint16ss_resize_) - extern f_status_t private_f_uint16ss_resize(const f_number_unsigned_t length, f_uint16ss_t * const uint16ss) F_attribute_visibility_internal_d; + extern f_status_t private_f_uint16ss_resize(const f_number_unsigned_t length, f_uint16ss_t * const structure) F_attribute_visibility_internal_d; #endif // !defined(_di_f_uint16ss_decrease_by_) || !defined(_di_f_uint16ss_increase_) || !defined(_di_f_uint16ss_increase_by_) || !defined(_di_f_uint16ss_resize_) #ifdef __cplusplus diff --git a/level_0/f_type_array/c/type_array/private-uint32.c b/level_0/f_type_array/c/type_array/private-uint32.c index 3e30a03..7556684 100644 --- a/level_0/f_type_array/c/type_array/private-uint32.c +++ b/level_0/f_type_array/c/type_array/private-uint32.c @@ -5,27 +5,11 @@ extern "C" { #endif -#if !defined(_di_f_uint32s_adjust_) || !defined(_di_f_uint32s_decimate_by_) - f_status_t private_f_uint32s_adjust(const f_number_unsigned_t length, f_uint32s_t * const uint32s) { - - const f_status_t status = f_memory_adjust(uint32s->size, length, sizeof(uint32_t), (void **) & uint32s->array); - if (F_status_is_error(status)) return status; - - uint32s->size = length; - - if (uint32s->used > uint32s->size) { - uint32s->used = length; - } - - return F_none; - } -#endif // !defined(_di_f_uint32s_adjust_) || !defined(_di_f_uint32s_decimate_by_) - #if !defined(_di_f_uint32s_append_) || !defined(_di_f_uint32ss_append_) extern f_status_t private_f_uint32s_append(const uint32_t source, f_uint32s_t * const destination) { - if (destination->used + 1 > destination->size) { - const f_status_t status = private_f_uint32s_resize(destination->used + F_memory_default_allocation_small_d, destination); + { + const f_status_t status = f_memory_array_increase(F_memory_default_allocation_small_d, sizeof(uint32_t), (void **) &destination->array, &destination->used, &destination->size); if (F_status_is_error(status)) return status; } @@ -38,8 +22,8 @@ extern "C" { #if !defined(_di_f_uint32s_append_) || !defined(_di_f_uint32s_append_all_) || !defined(_di_f_uint32ss_append_all_) extern f_status_t private_f_uint32s_append_all(const f_uint32s_t source, f_uint32s_t * const destination) { - if (destination->used + source.used > destination->size) { - const f_status_t status = private_f_uint32s_resize(destination->used + source.used, destination); + { + const f_status_t status = f_memory_array_increase_by(source.used, sizeof(uint32_t), (void **) &destination->array, &destination->used, &destination->size); if (F_status_is_error(status)) return status; } @@ -51,73 +35,33 @@ extern "C" { } #endif // !defined(_di_f_uint32s_append_) || !defined(_di_f_uint32s_append_all_) || !defined(_di_f_uint32ss_append_all_) -#if !defined(_di_f_uint32s_resize_) || !defined(_di_f_uint32s_append_) || !defined(_di_f_uint32s_decrease_by_) || !defined(_di_f_uint32ss_append_) - f_status_t private_f_uint32s_resize(const f_number_unsigned_t length, f_uint32s_t * const uint32s) { - - const f_status_t status = f_memory_resize(uint32s->size, length, sizeof(uint32_t), (void **) & uint32s->array); - if (F_status_is_error(status)) return status; - - uint32s->size = length; - - if (uint32s->used > uint32s->size) { - uint32s->used = length; - } - - return F_none; - } -#endif // !defined(_di_f_uint32s_resize_) || !defined(_di_f_uint32s_append_) || !defined(_di_f_uint32s_decrease_by_) || !defined(_di_f_uint32ss_append_) - #if !defined(_di_f_uint32ss_adjust_) || !defined(_di_f_uint32ss_decimate_by_) - f_status_t private_f_uint32ss_adjust(const f_number_unsigned_t length, f_uint32ss_t * const uint32ss) { + f_status_t private_f_uint32ss_adjust(const f_number_unsigned_t length, f_uint32ss_t * const structure) { f_status_t status = F_none; - for (f_number_unsigned_t i = length; i < uint32ss->size; ++i) { + for (f_number_unsigned_t i = length; i < structure->size; ++i) { - status = f_memory_destroy(uint32ss->array[i].size, sizeof(f_uint32s_t), (void **) & uint32ss->array[i].array); + status = f_memory_array_adjust(0, sizeof(uint32_t), (void **) &structure->array[i].array, &structure->array[i].used, &structure->array[i].size); if (F_status_is_error(status)) return status; - - uint32ss->array[i].size = 0; - uint32ss->array[i].used = 0; } // for - status = f_memory_adjust(uint32ss->size, length, sizeof(f_uint32s_t), (void **) & uint32ss->array); - if (F_status_is_error(status)) return status; - - uint32ss->size = length; - - if (uint32ss->used > uint32ss->size) { - uint32ss->used = length; - } - - return F_none; + return f_memory_array_adjust(length, sizeof(f_uint32s_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // !defined(_di_f_uint32ss_adjust_) || !defined(_di_f_uint32ss_decimate_by_) #if !defined(_di_f_uint32ss_decrease_by_) || !defined(_di_f_uint32ss_increase_) || !defined(_di_f_uint32ss_increase_by_) || !defined(_di_f_uint32ss_resize_) - f_status_t private_f_uint32ss_resize(const f_number_unsigned_t length, f_uint32ss_t * const uint32ss) { + f_status_t private_f_uint32ss_resize(const f_number_unsigned_t length, f_uint32ss_t * const structure) { f_status_t status = F_none; - for (f_number_unsigned_t i = length; i < uint32ss->size; ++i) { + for (f_number_unsigned_t i = length; i < structure->size; ++i) { - status = f_memory_delete(uint32ss->array[i].size, sizeof(f_uint32s_t), (void **) & uint32ss->array[i].array); + status = f_memory_array_resize(0, sizeof(uint32_t), (void **) &structure->array[i].array, &structure->array[i].used, &structure->array[i].size); if (F_status_is_error(status)) return status; - - uint32ss->array[i].size = 0; - uint32ss->array[i].used = 0; } // for - status = f_memory_resize(uint32ss->size, length, sizeof(f_uint32s_t), (void **) & uint32ss->array); - if (F_status_is_error(status)) return status; - - uint32ss->size = length; - - if (uint32ss->used > uint32ss->size) { - uint32ss->used = length; - } - - return F_none; + return f_memory_array_resize(length, sizeof(f_uint32s_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // !defined(_di_f_uint32ss_decrease_by_) || !defined(_di_f_uint32ss_increase_) || !defined(_di_f_uint32ss_increase_by_) || !defined(_di_f_uint32ss_resize_) diff --git a/level_0/f_type_array/c/type_array/private-uint32.h b/level_0/f_type_array/c/type_array/private-uint32.h index 706b05c..02e7cb4 100644 --- a/level_0/f_type_array/c/type_array/private-uint32.h +++ b/level_0/f_type_array/c/type_array/private-uint32.h @@ -16,29 +16,6 @@ extern "C" { #endif /** - * Private implementation for resizing the uint32s array. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The length to adjust to. - * @param uint32s - * The uint32s array to adjust. - * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + 1 <= size). - * - * Errors (with error bit) from: f_memory_adjust(). - * - * @see f_uint32s_adjust() - * @see f_uint32s_decimate_by() - */ -#if !defined(_di_f_uint32s_adjust_) || !defined(_di_f_uint32s_decimate_by_) - extern f_status_t private_f_uint32s_adjust(const f_number_unsigned_t length, f_uint32s_t * const uint32s) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_uint32s_adjust_) || !defined(_di_f_uint32s_decimate_by_) - -/** * Private implementation for appending the uint32 array. * * Intended to be shared to each of the different implementation variations. @@ -51,9 +28,10 @@ extern "C" { * @return * F_none on success. * - * Errors (with error bit) from: f_memory_resize(). + * Errors (with error bit) from: f_memory_array_increase(). + * + * @see f_memory_array_increase() * - * @see f_memory_resize() * @see f_uint32s_append() * @see f_uint32ss_append() */ @@ -74,9 +52,10 @@ extern "C" { * @return * F_none on success. * - * 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_uint32s_append_all() * @see f_uint32ss_append() * @see f_uint32ss_append_all() @@ -86,38 +65,13 @@ extern "C" { #endif // !defined(_di_f_uint32s_append_) || !defined(_di_f_uint32s_append_all_) || !defined(_di_f_uint32ss_append_all_) /** - * Private implementation for resizing the uint32s array. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The length to adjust to. - * @param uint32s - * The uint32s array to adjust. - * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + 1 <= size). - * - * Errors (with error bit) from: f_memory_resize(). - * - * @see f_uint32s_resize() - * @see f_uint32s_append() - * @see f_uint32s_decrease_by() - * @see f_uint32ss_append() - */ -#if !defined(_di_f_uint32s_resize_) || !defined(_di_f_uint32s_append_) || !defined(_di_f_uint32s_decrease_by_) || !defined(_di_f_uint32ss_append_) - extern f_status_t private_f_uint32s_resize(const f_number_unsigned_t length, f_uint32s_t * const uint32s) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_uint32s_resize_) || !defined(_di_f_uint32s_append_) || !defined(_di_f_uint32s_decrease_by_) || !defined(_di_f_uint32ss_append_) - -/** * Private implementation for resizing the uint32ss array. * * Intended to be shared to each of the different implementation variations. * * @param length * The length to adjust to. - * @param uint32ss + * @param structure * The uint32ss array to adjust. * * @return @@ -128,14 +82,15 @@ 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_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_uint32ss_adjust() * @see f_uint32ss_decimate_by() */ #if !defined(_di_f_uint32ss_adjust_) || !defined(_di_f_uint32ss_decimate_by_) - extern f_status_t private_f_uint32ss_adjust(const f_number_unsigned_t length, f_uint32ss_t * const uint32ss) F_attribute_visibility_internal_d; + extern f_status_t private_f_uint32ss_adjust(const f_number_unsigned_t length, f_uint32ss_t * const structure) F_attribute_visibility_internal_d; #endif // !defined(_di_f_uint32ss_adjust_) || !defined(_di_f_uint32ss_decimate_by_) /** @@ -145,7 +100,7 @@ extern "C" { * * @param length * The length to resize to. - * @param uint32ss + * @param structure * The uint32ss array to resize. * * @return @@ -156,8 +111,9 @@ 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_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_uint32ss_decrease_by() * @see f_uint32ss_increase() @@ -165,7 +121,7 @@ extern "C" { * @see f_uint32ss_resize() */ #if !defined(_di_f_uint32ss_decrease_by_) || !defined(_di_f_uint32ss_increase_) || !defined(_di_f_uint32ss_increase_by_) || !defined(_di_f_uint32ss_resize_) - extern f_status_t private_f_uint32ss_resize(const f_number_unsigned_t length, f_uint32ss_t * const uint32ss) F_attribute_visibility_internal_d; + extern f_status_t private_f_uint32ss_resize(const f_number_unsigned_t length, f_uint32ss_t * const structure) F_attribute_visibility_internal_d; #endif // !defined(_di_f_uint32ss_decrease_by_) || !defined(_di_f_uint32ss_increase_) || !defined(_di_f_uint32ss_increase_by_) || !defined(_di_f_uint32ss_resize_) #ifdef __cplusplus diff --git a/level_0/f_type_array/c/type_array/private-uint64.c b/level_0/f_type_array/c/type_array/private-uint64.c index e53aee9..4153b48 100644 --- a/level_0/f_type_array/c/type_array/private-uint64.c +++ b/level_0/f_type_array/c/type_array/private-uint64.c @@ -5,27 +5,11 @@ extern "C" { #endif -#if !defined(_di_f_uint64s_adjust_) || !defined(_di_f_uint64s_decimate_by_) - f_status_t private_f_uint64s_adjust(const f_number_unsigned_t length, f_uint64s_t * const uint64s) { - - const f_status_t status = f_memory_adjust(uint64s->size, length, sizeof(uint64_t), (void **) & uint64s->array); - if (F_status_is_error(status)) return status; - - uint64s->size = length; - - if (uint64s->used > uint64s->size) { - uint64s->used = length; - } - - return F_none; - } -#endif // !defined(_di_f_uint64s_adjust_) || !defined(_di_f_uint64s_decimate_by_) - #if !defined(_di_f_uint64s_append_) || !defined(_di_f_uint64ss_append_) extern f_status_t private_f_uint64s_append(const uint64_t source, f_uint64s_t * const destination) { - if (destination->used + 1 > destination->size) { - const f_status_t status = private_f_uint64s_resize(destination->used + F_memory_default_allocation_small_d, destination); + { + const f_status_t status = f_memory_array_increase(F_memory_default_allocation_small_d, sizeof(uint64_t), (void **) &destination->array, &destination->used, &destination->size); if (F_status_is_error(status)) return status; } @@ -38,8 +22,8 @@ extern "C" { #if !defined(_di_f_uint64s_append_) || !defined(_di_f_uint64s_append_all_) || !defined(_di_f_uint64ss_append_all_) extern f_status_t private_f_uint64s_append_all(const f_uint64s_t source, f_uint64s_t * const destination) { - if (destination->used + source.used > destination->size) { - const f_status_t status = private_f_uint64s_resize(destination->used + source.used, destination); + { + const f_status_t status = f_memory_array_increase_by(source.used, sizeof(uint64_t), (void **) &destination->array, &destination->used, &destination->size); if (F_status_is_error(status)) return status; } @@ -51,73 +35,33 @@ extern "C" { } #endif // !defined(_di_f_uint64s_append_) || !defined(_di_f_uint64s_append_all_) || !defined(_di_f_uint64ss_append_all_) -#if !defined(_di_f_uint64s_resize_) || !defined(_di_f_uint64s_append_) || !defined(_di_f_uint64s_decrease_by_) || !defined(_di_f_uint64ss_append_) - f_status_t private_f_uint64s_resize(const f_number_unsigned_t length, f_uint64s_t * const uint64s) { - - const f_status_t status = f_memory_resize(uint64s->size, length, sizeof(uint64_t), (void **) & uint64s->array); - if (F_status_is_error(status)) return status; - - uint64s->size = length; - - if (uint64s->used > uint64s->size) { - uint64s->used = length; - } - - return F_none; - } -#endif // !defined(_di_f_uint64s_resize_) || !defined(_di_f_uint64s_append_) || !defined(_di_f_uint64s_decrease_by_) || !defined(_di_f_uint64ss_append_) - #if !defined(_di_f_uint64ss_adjust_) || !defined(_di_f_uint64ss_decimate_by_) - f_status_t private_f_uint64ss_adjust(const f_number_unsigned_t length, f_uint64ss_t * const uint64ss) { + f_status_t private_f_uint64ss_adjust(const f_number_unsigned_t length, f_uint64ss_t * const structure) { f_status_t status = F_none; - for (f_number_unsigned_t i = length; i < uint64ss->size; ++i) { + for (f_number_unsigned_t i = length; i < structure->size; ++i) { - status = f_memory_destroy(uint64ss->array[i].size, sizeof(f_uint64s_t), (void **) & uint64ss->array[i].array); + status = f_memory_array_adjust(0, sizeof(uint64_t), (void **) &structure->array[i].array, &structure->array[i].used, &structure->array[i].size); if (F_status_is_error(status)) return status; - - uint64ss->array[i].size = 0; - uint64ss->array[i].used = 0; } // for - status = f_memory_adjust(uint64ss->size, length, sizeof(f_uint64s_t), (void **) & uint64ss->array); - if (F_status_is_error(status)) return status; - - uint64ss->size = length; - - if (uint64ss->used > uint64ss->size) { - uint64ss->used = length; - } - - return F_none; + return f_memory_array_adjust(length, sizeof(f_uint64s_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // !defined(_di_f_uint64ss_adjust_) || !defined(_di_f_uint64ss_decimate_by_) #if !defined(_di_f_uint64ss_decrease_by_) || !defined(_di_f_uint64ss_increase_) || !defined(_di_f_uint64ss_increase_by_) || !defined(_di_f_uint64ss_resize_) - f_status_t private_f_uint64ss_resize(const f_number_unsigned_t length, f_uint64ss_t * const uint64ss) { + f_status_t private_f_uint64ss_resize(const f_number_unsigned_t length, f_uint64ss_t * const structure) { f_status_t status = F_none; - for (f_number_unsigned_t i = length; i < uint64ss->size; ++i) { + for (f_number_unsigned_t i = length; i < structure->size; ++i) { - status = f_memory_delete(uint64ss->array[i].size, sizeof(f_uint64s_t), (void **) & uint64ss->array[i].array); + status = f_memory_array_resize(0, sizeof(uint64_t), (void **) &structure->array[i].array, &structure->array[i].used, &structure->array[i].size); if (F_status_is_error(status)) return status; - - uint64ss->array[i].size = 0; - uint64ss->array[i].used = 0; } // for - status = f_memory_resize(uint64ss->size, length, sizeof(f_uint64s_t), (void **) & uint64ss->array); - if (F_status_is_error(status)) return status; - - uint64ss->size = length; - - if (uint64ss->used > uint64ss->size) { - uint64ss->used = length; - } - - return F_none; + return f_memory_array_resize(length, sizeof(f_uint64s_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // !defined(_di_f_uint64ss_decrease_by_) || !defined(_di_f_uint64ss_increase_) || !defined(_di_f_uint64ss_increase_by_) || !defined(_di_f_uint64ss_resize_) diff --git a/level_0/f_type_array/c/type_array/private-uint64.h b/level_0/f_type_array/c/type_array/private-uint64.h index b4857d5..5142b9a 100644 --- a/level_0/f_type_array/c/type_array/private-uint64.h +++ b/level_0/f_type_array/c/type_array/private-uint64.h @@ -16,29 +16,6 @@ extern "C" { #endif /** - * Private implementation for resizing the uint64s array. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The length to adjust to. - * @param uint64s - * The uint64s array to adjust. - * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + 1 <= size). - * - * Errors (with error bit) from: f_memory_adjust(). - * - * @see f_uint64s_adjust() - * @see f_uint64s_decimate_by() - */ -#if !defined(_di_f_uint64s_adjust_) || !defined(_di_f_uint64s_decimate_by_) - extern f_status_t private_f_uint64s_adjust(const f_number_unsigned_t length, f_uint64s_t * const uint64s) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_uint64s_adjust_) || !defined(_di_f_uint64s_decimate_by_) - -/** * Private implementation for appending the uint64 array. * * Intended to be shared to each of the different implementation variations. @@ -51,9 +28,10 @@ extern "C" { * @return * F_none on success. * - * Errors (with error bit) from: f_memory_resize(). + * Errors (with error bit) from: f_memory_array_increase(). + * + * @see f_memory_array_increase() * - * @see f_memory_resize() * @see f_uint64s_append() * @see f_uint64ss_append() */ @@ -74,9 +52,10 @@ extern "C" { * @return * F_none on success. * - * 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_uint64s_append_all() * @see f_uint64ss_append() * @see f_uint64ss_append_all() @@ -86,38 +65,13 @@ extern "C" { #endif // !defined(_di_f_uint64s_append_) || !defined(_di_f_uint64s_append_all_) || !defined(_di_f_uint64ss_append_all_) /** - * Private implementation for resizing the uint64s array. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The length to adjust to. - * @param uint64s - * The uint64s array to adjust. - * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + 1 <= size). - * - * Errors (with error bit) from: f_memory_resize(). - * - * @see f_uint64s_resize() - * @see f_uint64s_append() - * @see f_uint64s_decrease_by() - * @see f_uint64ss_append() - */ -#if !defined(_di_f_uint64s_resize_) || !defined(_di_f_uint64s_append_) || !defined(_di_f_uint64s_decrease_by_) || !defined(_di_f_uint64ss_append_) - extern f_status_t private_f_uint64s_resize(const f_number_unsigned_t length, f_uint64s_t * const uint64s) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_uint64s_resize_) || !defined(_di_f_uint64s_append_) || !defined(_di_f_uint64s_decrease_by_) || !defined(_di_f_uint64ss_append_) - -/** * Private implementation for resizing the uint64ss array. * * Intended to be shared to each of the different implementation variations. * * @param length * The length to adjust to. - * @param uint64ss + * @param structure * The uint64ss array to adjust. * * @return @@ -128,14 +82,15 @@ 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_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_uint64ss_adjust() * @see f_uint64ss_decimate_by() */ #if !defined(_di_f_uint64ss_adjust_) || !defined(_di_f_uint64ss_decimate_by_) - extern f_status_t private_f_uint64ss_adjust(const f_number_unsigned_t length, f_uint64ss_t * const uint64ss) F_attribute_visibility_internal_d; + extern f_status_t private_f_uint64ss_adjust(const f_number_unsigned_t length, f_uint64ss_t * const structure) F_attribute_visibility_internal_d; #endif // !defined(_di_f_uint64ss_adjust_) || !defined(_di_f_uint64ss_decimate_by_) /** @@ -145,7 +100,7 @@ extern "C" { * * @param length * The length to resize to. - * @param uint64ss + * @param structure * The uint64ss array to resize. * * @return @@ -156,8 +111,9 @@ 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_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_uint64ss_decrease_by() * @see f_uint64ss_increase() @@ -165,7 +121,7 @@ extern "C" { * @see f_uint64ss_resize() */ #if !defined(_di_f_uint64ss_decrease_by_) || !defined(_di_f_uint64ss_increase_) || !defined(_di_f_uint64ss_increase_by_) || !defined(_di_f_uint64ss_resize_) - extern f_status_t private_f_uint64ss_resize(const f_number_unsigned_t length, f_uint64ss_t * const uint64ss) F_attribute_visibility_internal_d; + extern f_status_t private_f_uint64ss_resize(const f_number_unsigned_t length, f_uint64ss_t * const structure) F_attribute_visibility_internal_d; #endif // !defined(_di_f_uint64ss_decrease_by_) || !defined(_di_f_uint64ss_increase_) || !defined(_di_f_uint64ss_increase_by_) || !defined(_di_f_uint64ss_resize_) #ifdef __cplusplus diff --git a/level_0/f_type_array/c/type_array/private-uint8.c b/level_0/f_type_array/c/type_array/private-uint8.c index 3b11fb9..617509f 100644 --- a/level_0/f_type_array/c/type_array/private-uint8.c +++ b/level_0/f_type_array/c/type_array/private-uint8.c @@ -5,27 +5,11 @@ extern "C" { #endif -#if !defined(_di_f_uint8s_adjust_) || !defined(_di_f_uint8s_decimate_by_) - f_status_t private_f_uint8s_adjust(const f_number_unsigned_t length, f_uint8s_t * const uint8s) { - - const f_status_t status = f_memory_adjust(uint8s->size, length, sizeof(uint8_t), (void **) & uint8s->array); - if (F_status_is_error(status)) return status; - - uint8s->size = length; - - if (uint8s->used > uint8s->size) { - uint8s->used = length; - } - - return F_none; - } -#endif // !defined(_di_f_uint8s_adjust_) || !defined(_di_f_uint8s_decimate_by_) - #if !defined(_di_f_uint8s_append_) || !defined(_di_f_uint8ss_append_) extern f_status_t private_f_uint8s_append(const uint8_t source, f_uint8s_t * const destination) { - if (destination->used + 1 > destination->size) { - const f_status_t status = private_f_uint8s_resize(destination->used + F_memory_default_allocation_small_d, destination); + { + const f_status_t status = f_memory_array_increase(F_memory_default_allocation_small_d, sizeof(uint8_t), (void **) &destination->array, &destination->used, &destination->size); if (F_status_is_error(status)) return status; } @@ -38,8 +22,8 @@ extern "C" { #if !defined(_di_f_uint8s_append_) || !defined(_di_f_uint8s_append_all_) || !defined(_di_f_uint8ss_append_all_) extern f_status_t private_f_uint8s_append_all(const f_uint8s_t source, f_uint8s_t * const destination) { - if (destination->used + source.used > destination->size) { - const f_status_t status = private_f_uint8s_resize(destination->used + source.used, destination); + { + const f_status_t status = f_memory_array_increase_by(source.used, sizeof(uint8_t), (void **) &destination->array, &destination->used, &destination->size); if (F_status_is_error(status)) return status; } @@ -51,73 +35,33 @@ extern "C" { } #endif // !defined(_di_f_uint8s_append_) || !defined(_di_f_uint8s_append_all_) || !defined(_di_f_uint8ss_append_all_) -#if !defined(_di_f_uint8s_append_) || !defined(_di_f_uint8s_append_all_) || !defined(_di_f_uint8s_decrease_by_) || !defined(_di_f_uint8s_increase_) || !defined(_di_f_uint8s_increase_by_) || !defined(_di_f_uint8s_resize_) || !defined(_di_f_uint8ss_append_) || !defined(_di_f_uint8ss_append_all_) - f_status_t private_f_uint8s_resize(const f_number_unsigned_t length, f_uint8s_t * const uint8s) { - - const f_status_t status = f_memory_resize(uint8s->size, length, sizeof(uint8_t), (void **) & uint8s->array); - if (F_status_is_error(status)) return status; - - uint8s->size = length; - - if (uint8s->used > uint8s->size) { - uint8s->used = length; - } - - return F_none; - } -#endif // !defined(_di_f_uint8s_append_) || !defined(_di_f_uint8s_append_all_) || !defined(_di_f_uint8s_decrease_by_) || !defined(_di_f_uint8s_increase_) || !defined(_di_f_uint8s_increase_by_) || !defined(_di_f_uint8s_resize_) || !defined(_di_f_uint8ss_append_) || !defined(_di_f_uint8ss_append_all_) - #if !defined(_di_f_uint8ss_adjust_) || !defined(_di_f_uint8ss_decimate_by_) - f_status_t private_f_uint8ss_adjust(const f_number_unsigned_t length, f_uint8ss_t * const uint8ss) { + f_status_t private_f_uint8ss_adjust(const f_number_unsigned_t length, f_uint8ss_t * const structure) { f_status_t status = F_none; - for (f_number_unsigned_t i = length; i < uint8ss->size; ++i) { + for (f_number_unsigned_t i = length; i < structure->size; ++i) { - status = f_memory_destroy(uint8ss->array[i].size, sizeof(f_uint8s_t), (void **) & uint8ss->array[i].array); + status = f_memory_array_adjust(0, sizeof(uint8_t), (void **) &structure->array[i].array, &structure->array[i].used, &structure->array[i].size); if (F_status_is_error(status)) return status; - - uint8ss->array[i].size = 0; - uint8ss->array[i].used = 0; } // for - status = f_memory_adjust(uint8ss->size, length, sizeof(f_uint8s_t), (void **) & uint8ss->array); - if (F_status_is_error(status)) return status; - - uint8ss->size = length; - - if (uint8ss->used > uint8ss->size) { - uint8ss->used = length; - } - - return F_none; + return f_memory_array_adjust(length, sizeof(f_uint8s_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // !defined(_di_f_uint8ss_adjust_) || !defined(_di_f_uint8ss_decimate_by_) #if !defined(_di_f_uint8ss_decrease_by_) || !defined(_di_f_uint8ss_increase_) || !defined(_di_f_uint8ss_increase_by_) || !defined(_di_f_uint8ss_resize_) - f_status_t private_f_uint8ss_resize(const f_number_unsigned_t length, f_uint8ss_t * const uint8ss) { + f_status_t private_f_uint8ss_resize(const f_number_unsigned_t length, f_uint8ss_t * const structure) { f_status_t status = F_none; - for (f_number_unsigned_t i = length; i < uint8ss->size; ++i) { + for (f_number_unsigned_t i = length; i < structure->size; ++i) { - status = f_memory_delete(uint8ss->array[i].size, sizeof(f_uint8s_t), (void **) & uint8ss->array[i].array); + status = f_memory_array_resize(0, sizeof(uint8_t), (void **) &structure->array[i].array, &structure->array[i].used, &structure->array[i].size); if (F_status_is_error(status)) return status; - - uint8ss->array[i].size = 0; - uint8ss->array[i].used = 0; } // for - status = f_memory_resize(uint8ss->size, length, sizeof(f_uint8s_t), (void **) & uint8ss->array); - if (F_status_is_error(status)) return status; - - uint8ss->size = length; - - if (uint8ss->used > uint8ss->size) { - uint8ss->used = length; - } - - return F_none; + return f_memory_array_resize(length, sizeof(f_uint8s_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // !defined(_di_f_uint8ss_decrease_by_) || !defined(_di_f_uint8ss_increase_) || !defined(_di_f_uint8ss_increase_by_) || !defined(_di_f_uint8ss_resize_) diff --git a/level_0/f_type_array/c/type_array/private-uint8.h b/level_0/f_type_array/c/type_array/private-uint8.h index 212f2f7..ec55c4d 100644 --- a/level_0/f_type_array/c/type_array/private-uint8.h +++ b/level_0/f_type_array/c/type_array/private-uint8.h @@ -16,29 +16,6 @@ extern "C" { #endif /** - * Private implementation for resizing the uint8s array. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The length to adjust to. - * @param uint8s - * The uint8s array to adjust. - * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + 1 <= size). - * - * Errors (with error bit) from: f_memory_adjust(). - * - * @see f_uint8s_adjust() - * @see f_uint8s_decimate_by() - */ -#if !defined(_di_f_uint8s_adjust_) || !defined(_di_f_uint8s_decimate_by_) - extern f_status_t private_f_uint8s_adjust(const f_number_unsigned_t length, f_uint8s_t * const uint8s) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_uint8s_adjust_) || !defined(_di_f_uint8s_decimate_by_) - -/** * Private implementation for appending the uint8 array. * * Intended to be shared to each of the different implementation variations. @@ -51,9 +28,10 @@ extern "C" { * @return * F_none on success. * - * Errors (with error bit) from: f_memory_resize(). + * Errors (with error bit) from: f_memory_array_increase(). + * + * @see f_memory_array_increase() * - * @see f_memory_resize() * @see f_uint8s_append() * @see f_uint8ss_append() */ @@ -74,9 +52,10 @@ extern "C" { * @return * F_none on success. * - * 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_uint8s_append_all() * @see f_uint8ss_append() * @see f_uint8ss_append_all() @@ -86,43 +65,13 @@ extern "C" { #endif // !defined(_di_f_uint8s_append_) || !defined(_di_f_uint8s_append_all_) || !defined(_di_f_uint8ss_append_all_) /** - * Private implementation for resizing the uint8s array. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The length to adjust to. - * @param uint8s - * The uint8s array to adjust. - * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + 1 <= size). - * - * Errors (with error bit) from: f_memory_resize(). - * - * @see f_uint8s_append() - * @see f_uint8s_append_all() - * @see f_uint8s_decrease_by() - * @see f_uint8s_increase() - * @see f_uint8s_increase_by() - * @see f_uint8s_resize() - * @see f_uint8ss_append() - * @see f_uint8ss_append_all() - * - */ -#if !defined(_di_f_uint8s_append_) || !defined(_di_f_uint8s_append_all_) || !defined(_di_f_uint8s_decrease_by_) || !defined(_di_f_uint8s_increase_) || !defined(_di_f_uint8s_increase_by_) || !defined(_di_f_uint8s_resize_) || !defined(_di_f_uint8ss_append_) || !defined(_di_f_uint8ss_append_all_) - extern f_status_t private_f_uint8s_resize(const f_number_unsigned_t length, f_uint8s_t * const uint8s) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_uint8s_append_) || !defined(_di_f_uint8s_append_all_) || !defined(_di_f_uint8s_decrease_by_) || !defined(_di_f_uint8s_increase_) || !defined(_di_f_uint8s_increase_by_) || !defined(_di_f_uint8s_resize_) || !defined(_di_f_uint8ss_append_) || !defined(_di_f_uint8ss_append_all_) - -/** * Private implementation for resizing the uint8ss array. * * Intended to be shared to each of the different implementation variations. * * @param length * The length to adjust to. - * @param uint8ss + * @param structure * The uint8ss array to adjust. * * @return @@ -133,14 +82,15 @@ 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_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_uint8ss_adjust() * @see f_uint8ss_decimate_by() */ #if !defined(_di_f_uint8ss_adjust_) || !defined(_di_f_uint8ss_decimate_by_) - extern f_status_t private_f_uint8ss_adjust(const f_number_unsigned_t length, f_uint8ss_t * const uint8ss) F_attribute_visibility_internal_d; + extern f_status_t private_f_uint8ss_adjust(const f_number_unsigned_t length, f_uint8ss_t * const structure) F_attribute_visibility_internal_d; #endif // !defined(_di_f_uint8ss_adjust_) || !defined(_di_f_uint8ss_decimate_by_) /** @@ -150,7 +100,7 @@ extern "C" { * * @param length * The length to resize to. - * @param uint8ss + * @param structure * The uint8ss array to resize. * * @return @@ -161,8 +111,9 @@ 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_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_uint8ss_decrease_by() * @see f_uint8ss_increase() @@ -170,7 +121,7 @@ extern "C" { * @see f_uint8ss_resize() */ #if !defined(_di_f_uint8ss_decrease_by_) || !defined(_di_f_uint8ss_increase_) || !defined(_di_f_uint8ss_increase_by_) || !defined(_di_f_uint8ss_resize_) - extern f_status_t private_f_uint8ss_resize(const f_number_unsigned_t length, f_uint8ss_t * const uint8ss) F_attribute_visibility_internal_d; + extern f_status_t private_f_uint8ss_resize(const f_number_unsigned_t length, f_uint8ss_t * const structure) F_attribute_visibility_internal_d; #endif // !defined(_di_f_uint8ss_decrease_by_) || !defined(_di_f_uint8ss_increase_) || !defined(_di_f_uint8ss_increase_by_) || !defined(_di_f_uint8ss_resize_) #ifdef __cplusplus diff --git a/level_0/f_type_array/c/type_array/state.c b/level_0/f_type_array/c/type_array/state.c index 6aaa94e..178276d 100644 --- a/level_0/f_type_array/c/type_array/state.c +++ b/level_0/f_type_array/c/type_array/state.c @@ -7,12 +7,12 @@ extern "C" { #endif #ifndef _di_f_states_adjust_ - f_status_t f_states_adjust(const f_number_unsigned_t length, f_states_t * const states) { + f_status_t f_states_adjust(const f_number_unsigned_t length, f_states_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!states) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_states_adjust(length, states); + return f_memory_array_adjust(length, sizeof(f_state_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_states_adjust_ @@ -39,98 +39,62 @@ extern "C" { #endif // _di_f_states_append_all_ #ifndef _di_f_states_decimate_by_ - f_status_t f_states_decimate_by(const f_number_unsigned_t amount, f_states_t * const states) { + f_status_t f_states_decimate_by(const f_number_unsigned_t amount, f_states_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!states) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; - - if (states->size - amount > 0) { - return private_f_states_adjust(states->size - amount, states); - } - - return private_f_states_adjust(0, states); + return f_memory_array_decimate_by(amount, sizeof(f_state_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_states_decimate_by_ #ifndef _di_f_states_decrease_by_ - f_status_t f_states_decrease_by(const f_number_unsigned_t amount, f_states_t * const states) { + f_status_t f_states_decrease_by(const f_number_unsigned_t amount, f_states_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!states) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; - - if (states->size - amount > 0) { - return private_f_states_resize(states->size - amount, states); - } - - return private_f_states_resize(0, states); + return f_memory_array_decrease_by(amount, sizeof(f_state_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_states_decrease_by_ #ifndef _di_f_states_increase_ - f_status_t f_states_increase(const f_number_unsigned_t step, f_states_t * const states) { + f_status_t f_states_increase(const f_number_unsigned_t step, f_states_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!states) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (step && states->used + 1 > states->size) { - f_number_unsigned_t size = states->used + step; - - if (size > F_number_t_size_unsigned_d) { - if (states->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_states_resize(size, states); - } - - return F_data_not; + return f_memory_array_increase(step, sizeof(f_state_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_states_increase_ #ifndef _di_f_states_increase_by_ - f_status_t f_states_increase_by(const f_number_unsigned_t amount, f_states_t * const states) { + f_status_t f_states_increase_by(const f_number_unsigned_t amount, f_states_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!states) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; - - if (states->used + amount > states->size) { - if (states->used + amount > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } - - return private_f_states_resize(states->used + amount, states); - } - - return F_data_not; + return f_memory_array_increase_by(amount, sizeof(f_state_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_states_increase_by_ #ifndef _di_f_states_resize_ - f_status_t f_states_resize(const f_number_unsigned_t length, f_states_t * const states) { + f_status_t f_states_resize(const f_number_unsigned_t length, f_states_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!states) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_states_resize(length, states); + return f_memory_array_resize(length, sizeof(f_state_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_states_resize_ #ifndef _di_f_statess_adjust_ - f_status_t f_statess_adjust(const f_number_unsigned_t length, f_statess_t * const statess) { + f_status_t f_statess_adjust(const f_number_unsigned_t length, f_statess_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!statess) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_statess_adjust(length, statess); + return private_f_statess_adjust(length, structure); } #endif // _di_f_statess_adjust_ @@ -142,12 +106,8 @@ extern "C" { if (!source.used) return F_data_not; - f_status_t status = F_none; - - if (destination->used + 1 > destination->size) { - status = private_f_statess_resize(destination->used + F_memory_default_allocation_small_d, destination); - if (F_status_is_error(status)) return status; - } + f_status_t status = f_memory_array_increase(F_memory_default_allocation_small_d, sizeof(f_states_t), (void **) &destination->array, &destination->used, &destination->size); + if (F_status_is_error(status)) return status; status = private_f_states_append_all(source, &destination->array[destination->used]); if (F_status_is_error(status)) return status; @@ -166,12 +126,8 @@ extern "C" { if (!source.used) return F_data_not; - f_status_t status = F_none; - - if (destination->used + source.used > destination->size) { - status = private_f_statess_resize(destination->used + source.used, destination); - if (F_status_is_error(status)) return status; - } + f_status_t status = f_memory_array_increase_by(source.used, sizeof(f_states_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->used) { @@ -188,55 +144,47 @@ extern "C" { #endif // _di_f_statess_append_all_ #ifndef _di_f_statess_decimate_by_ - f_status_t f_statess_decimate_by(const f_number_unsigned_t amount, f_statess_t * const statess) { + f_status_t f_statess_decimate_by(const f_number_unsigned_t amount, f_statess_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!statess) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - if (statess->size - amount > 0) { - return private_f_statess_adjust(statess->size - amount, statess); - } - - return private_f_statess_adjust(0, statess); + return private_f_statess_adjust((structure->size - amount > 0) ? structure->size - amount : 0, structure); } #endif // _di_f_statess_decimate_by_ #ifndef _di_f_statess_decrease_by_ - f_status_t f_statess_decrease_by(const f_number_unsigned_t amount, f_statess_t * const statess) { + f_status_t f_statess_decrease_by(const f_number_unsigned_t amount, f_statess_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!statess) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - if (statess->size - amount > 0) { - return private_f_statess_resize(statess->size - amount, statess); - } - - return private_f_statess_resize(0, statess); + return private_f_statess_resize((structure->size - amount > 0) ? structure->size - amount : 0, structure); } #endif // _di_f_statess_decrease_by_ #ifndef _di_f_statess_increase_ - f_status_t f_statess_increase(const f_number_unsigned_t step, f_statess_t * const statess) { + f_status_t f_statess_increase(const f_number_unsigned_t step, f_statess_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!statess) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (step && statess->used + 1 > statess->size) { - f_number_unsigned_t size = statess->used + step; + if (step && structure->used + 1 > structure->size) { + if (structure->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + + f_number_unsigned_t length = structure->used + step; - if (size > F_number_t_size_unsigned_d) { - if (statess->used + 1 > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + if (length > F_number_t_size_unsigned_d) { + if (structure->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - size = F_number_t_size_unsigned_d; + length = F_number_t_size_unsigned_d; } - return private_f_statess_resize(size, statess); + return private_f_statess_resize(length, structure); } return F_data_not; @@ -244,19 +192,21 @@ extern "C" { #endif // _di_f_statess_increase_ #ifndef _di_f_statess_increase_by_ - f_status_t f_statess_increase_by(const f_number_unsigned_t amount, f_statess_t * const statess) { + f_status_t f_statess_increase_by(const f_number_unsigned_t amount, f_statess_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!statess) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; + if (amount) { + if (structure->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - if (statess->used + amount > statess->size) { - if (statess->used + amount > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + const f_number_unsigned_t length = structure->used + amount; - return private_f_statess_resize(statess->used + amount, statess); + if (length > structure->size) { + if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + + return private_f_statess_resize(structure->used + amount, structure); + } } return F_data_not; @@ -264,12 +214,12 @@ extern "C" { #endif // _di_f_statess_increase_by_ #ifndef _di_f_statess_resize_ - f_status_t f_statess_resize(const f_number_unsigned_t length, f_statess_t * const statess) { + f_status_t f_statess_resize(const f_number_unsigned_t length, f_statess_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!statess) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_statess_resize(length, statess); + return private_f_statess_resize(length, structure); } #endif // _di_f_statess_resize_ diff --git a/level_0/f_type_array/c/type_array/state.h b/level_0/f_type_array/c/type_array/state.h index 0838133..dd30c69 100644 --- a/level_0/f_type_array/c/type_array/state.h +++ b/level_0/f_type_array/c/type_array/state.h @@ -21,7 +21,7 @@ extern "C" { * * @param length * The new size to use. - * @param states + * @param structure * The string states array to resize. * * @return @@ -29,10 +29,12 @@ extern "C" { * * 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_array_adjust(). + * + * @see f_memory_array_adjust() */ #ifndef _di_f_states_adjust_ - extern f_status_t f_states_adjust(const f_number_unsigned_t length, f_states_t * const states); + extern f_status_t f_states_adjust(const f_number_unsigned_t length, f_states_t * const structure); #endif // _di_f_states_adjust_ /** @@ -49,7 +51,9 @@ extern "C" { * * 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(). + * + * @see f_memory_array_increase() */ #ifndef _di_f_states_append_ extern f_status_t f_states_append(const f_state_t source, f_states_t * const destination); @@ -69,7 +73,9 @@ extern "C" { * * 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() */ #ifndef _di_f_states_append_all_ extern f_status_t f_states_append_all(const f_states_t source, f_states_t * const destination); @@ -84,7 +90,7 @@ extern "C" { * * @param amount * A positive number representing how much to decimate the size by. - * @param states + * @param structure * The string states array to resize. * * @return @@ -93,10 +99,12 @@ extern "C" { * * 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_array_decimate_by(). + * + * @see f_memory_array_decimate_by() */ #ifndef _di_f_states_decimate_by_ - extern f_status_t f_states_decimate_by(const f_number_unsigned_t amount, f_states_t * const states); + extern f_status_t f_states_decimate_by(const f_number_unsigned_t amount, f_states_t * const structure); #endif // _di_f_states_decimate_by_ /** @@ -108,7 +116,7 @@ extern "C" { * * @param amount * A positive number representing how much to decrease the size by. - * @param states + * @param structure * The string states array to resize. * * @return @@ -117,10 +125,12 @@ extern "C" { * * 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_decrease_by(). + * + * @see f_memory_array_decrease_by() */ #ifndef _di_f_states_decrease_by_ - extern f_status_t f_states_decrease_by(const f_number_unsigned_t amount, f_states_t * const states); + extern f_status_t f_states_decrease_by(const f_number_unsigned_t amount, f_states_t * const structure); #endif // _di_f_states_decrease_by_ /** @@ -132,7 +142,7 @@ extern "C" { * @param step * The allocation step to use. * Must be greater than 0. - * @param states + * @param structure * The string states array to resize. * * @return @@ -142,10 +152,12 @@ extern "C" { * F_array_too_large (with error bit) if the new array length is too large. * 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(). + * + * @see f_memory_array_increase() */ #ifndef _di_f_states_increase_ - extern f_status_t f_states_increase(const f_number_unsigned_t step, f_states_t * const states); + extern f_status_t f_states_increase(const f_number_unsigned_t step, f_states_t * const structure); #endif // _di_f_states_increase_ /** @@ -157,7 +169,7 @@ extern "C" { * * @param amount * A positive number representing how much to increase the size by. - * @param states + * @param structure * The string states array to resize. * * @return @@ -167,10 +179,12 @@ extern "C" { * F_array_too_large (with error bit) if the new array length is too large. * 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() */ #ifndef _di_f_states_increase_by_ - extern f_status_t f_states_increase_by(const f_number_unsigned_t amount, f_states_t * const states); + extern f_status_t f_states_increase_by(const f_number_unsigned_t amount, f_states_t * const structure); #endif // _di_f_states_increase_by_ /** @@ -178,7 +192,7 @@ extern "C" { * * @param length * The new size to use. - * @param states + * @param structure * The string states array to adjust. * * @return @@ -186,10 +200,12 @@ extern "C" { * * 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(). + * + * @see f_memory_array_resize() */ #ifndef _di_f_states_resize_ - extern f_status_t f_states_resize(const f_number_unsigned_t length, f_states_t * const states); + extern f_status_t f_states_resize(const f_number_unsigned_t length, f_states_t * const structure); #endif // _di_f_states_resize_ /** @@ -197,7 +213,7 @@ extern "C" { * * @param length * The new size to use. - * @param statess + * @param structure * The string statess array to resize. * * @return @@ -205,11 +221,12 @@ extern "C" { * * 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() */ #ifndef _di_f_statess_adjust_ - extern f_status_t f_statess_adjust(const f_number_unsigned_t length, f_statess_t * const statess); + extern f_status_t f_statess_adjust(const f_number_unsigned_t length, f_statess_t * const structure); #endif // _di_f_statess_adjust_ /** @@ -226,7 +243,11 @@ extern "C" { * * 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(). + * Errors (with error bit) from: f_memory_array_increase_by(). + * + * @see f_memory_array_increase() + * @see f_memory_array_increase_by() */ #ifndef _di_f_statess_append_ extern f_status_t f_statess_append(const f_states_t source, f_statess_t * const destination); @@ -246,7 +267,9 @@ extern "C" { * * 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() */ #ifndef _di_f_statess_append_all_ extern f_status_t f_statess_append_all(const f_statess_t source, f_statess_t * const destination); @@ -261,20 +284,20 @@ extern "C" { * * @param amount * A positive number representing how much to decimate the size by. - * @param statess + * @param structure * The string statess array to resize. * * @return * F_none on success. - * F_data_not if amount is 0. * * 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() */ #ifndef _di_f_statess_decimate_by_ - extern f_status_t f_statess_decimate_by(const f_number_unsigned_t amount, f_statess_t * const statess); + extern f_status_t f_statess_decimate_by(const f_number_unsigned_t amount, f_statess_t * const structure); #endif // _di_f_statess_decimate_by_ /** @@ -286,20 +309,20 @@ extern "C" { * * @param amount * A positive number representing how much to decrease the size by. - * @param statess + * @param structure * The string statess array to resize. * * @return * F_none on success. - * F_data_not if amount is 0. * * 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() */ #ifndef _di_f_statess_decrease_by_ - extern f_status_t f_statess_decrease_by(const f_number_unsigned_t amount, f_statess_t * const statess); + extern f_status_t f_statess_decrease_by(const f_number_unsigned_t amount, f_statess_t * const structure); #endif // _di_f_statess_decrease_by_ /** @@ -311,7 +334,7 @@ extern "C" { * @param step * The allocation step to use. * Must be greater than 0. - * @param statess + * @param structure * The string statess array to resize. * * @return @@ -321,10 +344,12 @@ extern "C" { * F_array_too_large (with error bit) if the new array length is too large. * 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(). + * + * @see f_memory_array_resize() */ #ifndef _di_f_statess_increase_ - extern f_status_t f_statess_increase(const f_number_unsigned_t step, f_statess_t * const statess); + extern f_status_t f_statess_increase(const f_number_unsigned_t step, f_statess_t * const structure); #endif // _di_f_statess_increase_ /** @@ -336,7 +361,7 @@ extern "C" { * * @param amount * A positive number representing how much to increase the size by. - * @param statess + * @param structure * The string statess array to resize. * * @return @@ -346,10 +371,12 @@ extern "C" { * F_array_too_large (with error bit) if the new array length is too large. * 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(). + * + * @see f_memory_array_resize() */ #ifndef _di_f_statess_increase_by_ - extern f_status_t f_statess_increase_by(const f_number_unsigned_t amount, f_statess_t * const statess); + extern f_status_t f_statess_increase_by(const f_number_unsigned_t amount, f_statess_t * const structure); #endif // _di_f_statess_increase_by_ /** @@ -357,7 +384,7 @@ extern "C" { * * @param length * The new size to use. - * @param statess + * @param structure * The string statess array to adjust. * * @return @@ -365,11 +392,12 @@ extern "C" { * * 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() */ #ifndef _di_f_statess_resize_ - extern f_status_t f_statess_resize(const f_number_unsigned_t length, f_statess_t * const statess); + extern f_status_t f_statess_resize(const f_number_unsigned_t length, f_statess_t * const structure); #endif // _di_f_statess_resize_ #ifdef __cplusplus diff --git a/level_0/f_type_array/c/type_array/status.c b/level_0/f_type_array/c/type_array/status.c index 55da1a6..dc52567 100644 --- a/level_0/f_type_array/c/type_array/status.c +++ b/level_0/f_type_array/c/type_array/status.c @@ -7,12 +7,12 @@ extern "C" { #endif #ifndef _di_f_statuss_adjust_ - f_status_t f_statuss_adjust(const f_number_unsigned_t length, f_statuss_t * const statuss) { + f_status_t f_statuss_adjust(const f_number_unsigned_t length, f_statuss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!statuss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_statuss_adjust(length, statuss); + return f_memory_array_adjust(length, sizeof(f_status_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_statuss_adjust_ @@ -39,98 +39,62 @@ extern "C" { #endif // _di_f_statuss_append_all_ #ifndef _di_f_statuss_decimate_by_ - f_status_t f_statuss_decimate_by(const f_number_unsigned_t amount, f_statuss_t * const statuss) { + f_status_t f_statuss_decimate_by(const f_number_unsigned_t amount, f_statuss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!statuss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; - - if (statuss->size - amount > 0) { - return private_f_statuss_adjust(statuss->size - amount, statuss); - } - - return private_f_statuss_adjust(0, statuss); + return f_memory_array_decimate_by(amount, sizeof(f_status_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_statuss_decimate_by_ #ifndef _di_f_statuss_decrease_by_ - f_status_t f_statuss_decrease_by(const f_number_unsigned_t amount, f_statuss_t * const statuss) { + f_status_t f_statuss_decrease_by(const f_number_unsigned_t amount, f_statuss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!statuss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; - - if (statuss->size - amount > 0) { - return private_f_statuss_resize(statuss->size - amount, statuss); - } - - return private_f_statuss_resize(0, statuss); + return f_memory_array_decrease_by(amount, sizeof(f_status_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_statuss_decrease_by_ #ifndef _di_f_statuss_increase_ - f_status_t f_statuss_increase(const f_number_unsigned_t step, f_statuss_t * const statuss) { + f_status_t f_statuss_increase(const f_number_unsigned_t step, f_statuss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!statuss) return F_status_set_error(F_parameter); + if (!structure) 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_statuss_resize(size, statuss); - } - - return F_data_not; + return f_memory_array_increase(step, sizeof(f_status_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_statuss_increase_ #ifndef _di_f_statuss_increase_by_ - f_status_t f_statuss_increase_by(const f_number_unsigned_t amount, f_statuss_t * const statuss) { + f_status_t f_statuss_increase_by(const f_number_unsigned_t amount, f_statuss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!statuss) return F_status_set_error(F_parameter); + if (!structure) 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_statuss_resize(statuss->used + amount, statuss); - } - - return F_data_not; + return f_memory_array_increase_by(amount, sizeof(f_status_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_statuss_increase_by_ #ifndef _di_f_statuss_resize_ - f_status_t f_statuss_resize(const f_number_unsigned_t length, f_statuss_t * const statuss) { + f_status_t f_statuss_resize(const f_number_unsigned_t length, f_statuss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!statuss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_statuss_resize(length, statuss); + return f_memory_array_resize(length, sizeof(f_status_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_statuss_resize_ #ifndef _di_f_statusss_adjust_ - f_status_t f_statusss_adjust(const f_number_unsigned_t length, f_statusss_t * const statusss) { + f_status_t f_statusss_adjust(const f_number_unsigned_t length, f_statusss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!statusss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_statusss_adjust(length, statusss); + return private_f_statusss_adjust(length, structure); } #endif // _di_f_statusss_adjust_ @@ -142,12 +106,8 @@ extern "C" { if (!source.used) return F_data_not; - f_status_t status = F_none; - - if (destination->used + 1 > destination->size) { - status = private_f_statusss_resize(destination->used + F_memory_default_allocation_small_d, destination); - if (F_status_is_error(status)) return status; - } + f_status_t status = f_memory_array_increase(F_memory_default_allocation_small_d, sizeof(f_statuss_t), (void **) &destination->array, &destination->used, &destination->size); + if (F_status_is_error(status)) return status; status = private_f_statuss_append_all(source, &destination->array[destination->used]); if (F_status_is_error(status)) return status; @@ -166,12 +126,8 @@ extern "C" { if (!source.used) return F_data_not; - f_status_t status = F_none; - - if (destination->used + source.used > destination->size) { - status = private_f_statusss_resize(destination->used + source.used, destination); - if (F_status_is_error(status)) return status; - } + f_status_t status = f_memory_array_increase_by(source.used, sizeof(f_statuss_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->used) { @@ -188,55 +144,47 @@ extern "C" { #endif // _di_f_statusss_append_all_ #ifndef _di_f_statusss_decimate_by_ - f_status_t f_statusss_decimate_by(const f_number_unsigned_t amount, f_statusss_t * const statusss) { + f_status_t f_statusss_decimate_by(const f_number_unsigned_t amount, f_statusss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!statusss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - if (statusss->size - amount > 0) { - return private_f_statusss_adjust(statusss->size - amount, statusss); - } - - return private_f_statusss_adjust(0, statusss); + return private_f_statusss_adjust((structure->size - amount > 0) ? structure->size - amount : 0, structure); } #endif // _di_f_statusss_decimate_by_ #ifndef _di_f_statusss_decrease_by_ - f_status_t f_statusss_decrease_by(const f_number_unsigned_t amount, f_statusss_t * const statusss) { + f_status_t f_statusss_decrease_by(const f_number_unsigned_t amount, f_statusss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!statusss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - if (statusss->size - amount > 0) { - return private_f_statusss_resize(statusss->size - amount, statusss); - } - - return private_f_statusss_resize(0, statusss); + return private_f_statusss_resize((structure->size - amount > 0) ? structure->size - amount : 0, structure); } #endif // _di_f_statusss_decrease_by_ #ifndef _di_f_statusss_increase_ - f_status_t f_statusss_increase(const f_number_unsigned_t step, f_statusss_t * const statusss) { + f_status_t f_statusss_increase(const f_number_unsigned_t step, f_statusss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!statusss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (step && statusss->used + 1 > statusss->size) { - f_number_unsigned_t size = statusss->used + step; + if (step && structure->used + 1 > structure->size) { + if (structure->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + + f_number_unsigned_t length = structure->used + step; - if (size > F_number_t_size_unsigned_d) { - if (statusss->used + 1 > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + if (length > F_number_t_size_unsigned_d) { + if (structure->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - size = F_number_t_size_unsigned_d; + length = F_number_t_size_unsigned_d; } - return private_f_statusss_resize(size, statusss); + return private_f_statusss_resize(length, structure); } return F_data_not; @@ -244,19 +192,21 @@ extern "C" { #endif // _di_f_statusss_increase_ #ifndef _di_f_statusss_increase_by_ - f_status_t f_statusss_increase_by(const f_number_unsigned_t amount, f_statusss_t * const statusss) { + f_status_t f_statusss_increase_by(const f_number_unsigned_t amount, f_statusss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!statusss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; + if (amount) { + if (structure->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - if (statusss->used + amount > statusss->size) { - if (statusss->used + amount > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + const f_number_unsigned_t length = structure->used + amount; - return private_f_statusss_resize(statusss->used + amount, statusss); + if (length > structure->size) { + if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + + return private_f_statusss_resize(structure->used + amount, structure); + } } return F_data_not; @@ -264,12 +214,12 @@ extern "C" { #endif // _di_f_statusss_increase_by_ #ifndef _di_f_statusss_resize_ - f_status_t f_statusss_resize(const f_number_unsigned_t length, f_statusss_t * const statusss) { + f_status_t f_statusss_resize(const f_number_unsigned_t length, f_statusss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!statusss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_statusss_resize(length, statusss); + return private_f_statusss_resize(length, structure); } #endif // _di_f_statusss_resize_ diff --git a/level_0/f_type_array/c/type_array/status.h b/level_0/f_type_array/c/type_array/status.h index 19a4353..3a2845d 100644 --- a/level_0/f_type_array/c/type_array/status.h +++ b/level_0/f_type_array/c/type_array/status.h @@ -21,7 +21,7 @@ extern "C" { * * @param length * The new size to use. - * @param statuss + * @param structure * The string statuss array to resize. * * @return @@ -29,10 +29,12 @@ extern "C" { * * 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_array_adjust(). + * + * @see f_memory_array_adjust() */ #ifndef _di_f_statuss_adjust_ - extern f_status_t f_statuss_adjust(const f_number_unsigned_t length, f_statuss_t * const statuss); + extern f_status_t f_statuss_adjust(const f_number_unsigned_t length, f_statuss_t * const structure); #endif // _di_f_statuss_adjust_ /** @@ -49,7 +51,9 @@ extern "C" { * * 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(). + * + * @see f_memory_array_increase() */ #ifndef _di_f_statuss_append_ extern f_status_t f_statuss_append(const f_status_t source, f_statuss_t * const destination); @@ -69,7 +73,9 @@ extern "C" { * * 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() */ #ifndef _di_f_statuss_append_all_ extern f_status_t f_statuss_append_all(const f_statuss_t source, f_statuss_t * const destination); @@ -84,7 +90,7 @@ extern "C" { * * @param amount * A positive number representing how much to decimate the size by. - * @param statuss + * @param structure * The string statuss array to resize. * * @return @@ -93,10 +99,12 @@ extern "C" { * * 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_array_decimate_by(). + * + * @see f_memory_array_decimate_by() */ #ifndef _di_f_statuss_decimate_by_ - extern f_status_t f_statuss_decimate_by(const f_number_unsigned_t amount, f_statuss_t * const statuss); + extern f_status_t f_statuss_decimate_by(const f_number_unsigned_t amount, f_statuss_t * const structure); #endif // _di_f_statuss_decimate_by_ /** @@ -108,7 +116,7 @@ extern "C" { * * @param amount * A positive number representing how much to decrease the size by. - * @param statuss + * @param structure * The string statuss array to resize. * * @return @@ -117,10 +125,12 @@ extern "C" { * * 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_decrease_by(). + * + * @see f_memory_array_decrease_by() */ #ifndef _di_f_statuss_decrease_by_ - extern f_status_t f_statuss_decrease_by(const f_number_unsigned_t amount, f_statuss_t * const statuss); + extern f_status_t f_statuss_decrease_by(const f_number_unsigned_t amount, f_statuss_t * const structure); #endif // _di_f_statuss_decrease_by_ /** @@ -132,7 +142,7 @@ extern "C" { * @param step * The allocation step to use. * Must be greater than 0. - * @param statuss + * @param structure * The string statuss array to resize. * * @return @@ -142,10 +152,12 @@ extern "C" { * F_array_too_large (with error bit) if the new array length is too large. * 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(). + * + * @see f_memory_array_increase() */ #ifndef _di_f_statuss_increase_ - extern f_status_t f_statuss_increase(const f_number_unsigned_t step, f_statuss_t * const statuss); + extern f_status_t f_statuss_increase(const f_number_unsigned_t step, f_statuss_t * const structure); #endif // _di_f_statuss_increase_ /** @@ -157,7 +169,7 @@ extern "C" { * * @param amount * A positive number representing how much to increase the size by. - * @param statuss + * @param structure * The string statuss array to resize. * * @return @@ -167,10 +179,12 @@ extern "C" { * F_array_too_large (with error bit) if the new array length is too large. * 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() */ #ifndef _di_f_statuss_increase_by_ - extern f_status_t f_statuss_increase_by(const f_number_unsigned_t amount, f_statuss_t * const statuss); + extern f_status_t f_statuss_increase_by(const f_number_unsigned_t amount, f_statuss_t * const structure); #endif // _di_f_statuss_increase_by_ /** @@ -178,7 +192,7 @@ extern "C" { * * @param length * The new size to use. - * @param statuss + * @param structure * The string statuss array to adjust. * * @return @@ -186,10 +200,12 @@ extern "C" { * * 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(). + * + * @see f_memory_array_resize() */ #ifndef _di_f_statuss_resize_ - extern f_status_t f_statuss_resize(const f_number_unsigned_t length, f_statuss_t * const statuss); + extern f_status_t f_statuss_resize(const f_number_unsigned_t length, f_statuss_t * const structure); #endif // _di_f_statuss_resize_ /** @@ -197,7 +213,7 @@ extern "C" { * * @param length * The new size to use. - * @param statusss + * @param structure * The string statusss array to resize. * * @return @@ -205,11 +221,12 @@ extern "C" { * * 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() */ #ifndef _di_f_statusss_adjust_ - extern f_status_t f_statusss_adjust(const f_number_unsigned_t length, f_statusss_t * const statusss); + extern f_status_t f_statusss_adjust(const f_number_unsigned_t length, f_statusss_t * const structure); #endif // _di_f_statusss_adjust_ /** @@ -226,7 +243,11 @@ extern "C" { * * 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(). + * Errors (with error bit) from: f_memory_array_increase_by(). + * + * @see f_memory_array_increase() + * @see f_memory_array_increase_by() */ #ifndef _di_f_statusss_append_ extern f_status_t f_statusss_append(const f_statuss_t source, f_statusss_t * const destination); @@ -246,7 +267,9 @@ extern "C" { * * 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() */ #ifndef _di_f_statusss_append_all_ extern f_status_t f_statusss_append_all(const f_statusss_t source, f_statusss_t * const destination); @@ -261,20 +284,20 @@ extern "C" { * * @param amount * A positive number representing how much to decimate the size by. - * @param statusss + * @param structure * The string statusss array to resize. * * @return * F_none on success. - * F_data_not if amount is 0. * * 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() */ #ifndef _di_f_statusss_decimate_by_ - extern f_status_t f_statusss_decimate_by(const f_number_unsigned_t amount, f_statusss_t * const statusss); + extern f_status_t f_statusss_decimate_by(const f_number_unsigned_t amount, f_statusss_t * const structure); #endif // _di_f_statusss_decimate_by_ /** @@ -286,20 +309,20 @@ extern "C" { * * @param amount * A positive number representing how much to decrease the size by. - * @param statusss + * @param structure * The string statusss array to resize. * * @return * F_none on success. - * F_data_not if amount is 0. * * 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() */ #ifndef _di_f_statusss_decrease_by_ - extern f_status_t f_statusss_decrease_by(const f_number_unsigned_t amount, f_statusss_t * const statusss); + extern f_status_t f_statusss_decrease_by(const f_number_unsigned_t amount, f_statusss_t * const structure); #endif // _di_f_statusss_decrease_by_ /** @@ -311,7 +334,7 @@ extern "C" { * @param step * The allocation step to use. * Must be greater than 0. - * @param statusss + * @param structure * The string statusss array to resize. * * @return @@ -321,10 +344,12 @@ extern "C" { * F_array_too_large (with error bit) if the new array length is too large. * 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(). + * + * @see f_memory_array_resize() */ #ifndef _di_f_statusss_increase_ - extern f_status_t f_statusss_increase(const f_number_unsigned_t step, f_statusss_t * const statusss); + extern f_status_t f_statusss_increase(const f_number_unsigned_t step, f_statusss_t * const structure); #endif // _di_f_statusss_increase_ /** @@ -336,7 +361,7 @@ extern "C" { * * @param amount * A positive number representing how much to increase the size by. - * @param statusss + * @param structure * The string statusss array to resize. * * @return @@ -346,10 +371,12 @@ extern "C" { * F_array_too_large (with error bit) if the new array length is too large. * 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(). + * + * @see f_memory_array_resize() */ #ifndef _di_f_statusss_increase_by_ - extern f_status_t f_statusss_increase_by(const f_number_unsigned_t amount, f_statusss_t * const statusss); + extern f_status_t f_statusss_increase_by(const f_number_unsigned_t amount, f_statusss_t * const structure); #endif // _di_f_statusss_increase_by_ /** @@ -357,7 +384,7 @@ extern "C" { * * @param length * The new size to use. - * @param statusss + * @param structure * The string statusss array to adjust. * * @return @@ -365,11 +392,12 @@ extern "C" { * * 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() */ #ifndef _di_f_statusss_resize_ - extern f_status_t f_statusss_resize(const f_number_unsigned_t length, f_statusss_t * const statusss); + extern f_status_t f_statusss_resize(const f_number_unsigned_t length, f_statusss_t * const structure); #endif // _di_f_statusss_resize_ #ifdef __cplusplus diff --git a/level_0/f_type_array/c/type_array/uint128.c b/level_0/f_type_array/c/type_array/uint128.c index 35b288a..844ae10 100644 --- a/level_0/f_type_array/c/type_array/uint128.c +++ b/level_0/f_type_array/c/type_array/uint128.c @@ -7,12 +7,12 @@ extern "C" { #endif #ifndef _di_f_uint128s_adjust_ - f_status_t f_uint128s_adjust(const f_number_unsigned_t length, f_uint128s_t * const uint128s) { + f_status_t f_uint128s_adjust(const f_number_unsigned_t length, f_uint128s_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!uint128s) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_uint128s_adjust(length, uint128s); + return f_memory_array_adjust(length, sizeof(uint128_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_uint128s_adjust_ @@ -39,98 +39,62 @@ extern "C" { #endif // _di_f_uint128s_append_all_ #ifndef _di_f_uint128s_decimate_by_ - f_status_t f_uint128s_decimate_by(const f_number_unsigned_t amount, f_uint128s_t * const uint128s) { + f_status_t f_uint128s_decimate_by(const f_number_unsigned_t amount, f_uint128s_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!uint128s) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; - - if (uint128s->size - amount > 0) { - return private_f_uint128s_adjust(uint128s->size - amount, uint128s); - } - - return private_f_uint128s_adjust(0, uint128s); + return f_memory_array_decimate_by(amount, sizeof(uint128_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_uint128s_decimate_by_ #ifndef _di_f_uint128s_decrease_by_ - f_status_t f_uint128s_decrease_by(const f_number_unsigned_t amount, f_uint128s_t * const uint128s) { + f_status_t f_uint128s_decrease_by(const f_number_unsigned_t amount, f_uint128s_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!uint128s) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; - - if (uint128s->size - amount > 0) { - return private_f_uint128s_resize(uint128s->size - amount, uint128s); - } - - return private_f_uint128s_resize(0, uint128s); + return f_memory_array_decrease_by(amount, sizeof(uint128_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_uint128s_decrease_by_ #ifndef _di_f_uint128s_increase_ - f_status_t f_uint128s_increase(const f_number_unsigned_t step, f_uint128s_t * const uint128s) { + f_status_t f_uint128s_increase(const f_number_unsigned_t step, f_uint128s_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!uint128s) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (step && uint128s->used + 1 > uint128s->size) { - f_number_unsigned_t size = uint128s->used + step; - - if (size > F_number_t_size_unsigned_d) { - if (uint128s->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_uint128s_resize(size, uint128s); - } - - return F_data_not; + return f_memory_array_increase(step, sizeof(uint128_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_uint128s_increase_ #ifndef _di_f_uint128s_increase_by_ - f_status_t f_uint128s_increase_by(const f_number_unsigned_t amount, f_uint128s_t * const uint128s) { + f_status_t f_uint128s_increase_by(const f_number_unsigned_t amount, f_uint128s_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!uint128s) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; - - if (uint128s->used + amount > uint128s->size) { - if (uint128s->used + amount > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } - - return private_f_uint128s_resize(uint128s->used + amount, uint128s); - } - - return F_data_not; + return f_memory_array_increase_by(amount, sizeof(uint128_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_uint128s_increase_by_ #ifndef _di_f_uint128s_resize_ - f_status_t f_uint128s_resize(const f_number_unsigned_t length, f_uint128s_t * const uint128s) { + f_status_t f_uint128s_resize(const f_number_unsigned_t length, f_uint128s_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!uint128s) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_uint128s_resize(length, uint128s); + return f_memory_array_resize(length, sizeof(uint128_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_uint128s_resize_ #ifndef _di_f_uint128ss_adjust_ - f_status_t f_uint128ss_adjust(const f_number_unsigned_t length, f_uint128ss_t * const uint128ss) { + f_status_t f_uint128ss_adjust(const f_number_unsigned_t length, f_uint128ss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!uint128ss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_uint128ss_adjust(length, uint128ss); + return private_f_uint128ss_adjust(length, structure); } #endif // _di_f_uint128ss_adjust_ @@ -142,12 +106,8 @@ extern "C" { if (!source.used) return F_data_not; - f_status_t status = F_none; - - if (destination->used + 1 > destination->size) { - status = private_f_uint128ss_resize(destination->used + F_memory_default_allocation_small_d, destination); - if (F_status_is_error(status)) return status; - } + f_status_t status = f_memory_array_increase(F_memory_default_allocation_small_d, sizeof(f_uint128s_t), (void **) &destination->array, &destination->used, &destination->size); + if (F_status_is_error(status)) return status; status = private_f_uint128s_append_all(source, &destination->array[destination->used]); if (F_status_is_error(status)) return status; @@ -166,12 +126,8 @@ extern "C" { if (!source.used) return F_data_not; - f_status_t status = F_none; - - if (destination->used + source.used > destination->size) { - status = private_f_uint128ss_resize(destination->used + source.used, destination); - if (F_status_is_error(status)) return status; - } + f_status_t status = f_memory_array_increase_by(source.used, sizeof(f_uint128s_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->used) { @@ -188,55 +144,47 @@ extern "C" { #endif // _di_f_uint128ss_append_all_ #ifndef _di_f_uint128ss_decimate_by_ - f_status_t f_uint128ss_decimate_by(const f_number_unsigned_t amount, f_uint128ss_t * const uint128ss) { + f_status_t f_uint128ss_decimate_by(const f_number_unsigned_t amount, f_uint128ss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!uint128ss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - if (uint128ss->size - amount > 0) { - return private_f_uint128ss_adjust(uint128ss->size - amount, uint128ss); - } - - return private_f_uint128ss_adjust(0, uint128ss); + return private_f_uint128ss_adjust((structure->size - amount > 0) ? structure->size - amount : 0, structure); } #endif // _di_f_uint128ss_decimate_by_ #ifndef _di_f_uint128ss_decrease_by_ - f_status_t f_uint128ss_decrease_by(const f_number_unsigned_t amount, f_uint128ss_t * const uint128ss) { + f_status_t f_uint128ss_decrease_by(const f_number_unsigned_t amount, f_uint128ss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!uint128ss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - if (uint128ss->size - amount > 0) { - return private_f_uint128ss_resize(uint128ss->size - amount, uint128ss); - } - - return private_f_uint128ss_resize(0, uint128ss); + return private_f_uint128ss_resize((structure->size - amount > 0) ? structure->size - amount : 0, structure); } #endif // _di_f_uint128ss_decrease_by_ #ifndef _di_f_uint128ss_increase_ - f_status_t f_uint128ss_increase(const f_number_unsigned_t step, f_uint128ss_t * const uint128ss) { + f_status_t f_uint128ss_increase(const f_number_unsigned_t step, f_uint128ss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!uint128ss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (step && uint128ss->used + 1 > uint128ss->size) { - f_number_unsigned_t size = uint128ss->used + step; + if (step && structure->used + 1 > structure->size) { + if (structure->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + + f_number_unsigned_t length = structure->used + step; - if (size > F_number_t_size_unsigned_d) { - if (uint128ss->used + 1 > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + if (length > F_number_t_size_unsigned_d) { + if (structure->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - size = F_number_t_size_unsigned_d; + length = F_number_t_size_unsigned_d; } - return private_f_uint128ss_resize(size, uint128ss); + return private_f_uint128ss_resize(length, structure); } return F_data_not; @@ -244,19 +192,21 @@ extern "C" { #endif // _di_f_uint128ss_increase_ #ifndef _di_f_uint128ss_increase_by_ - f_status_t f_uint128ss_increase_by(const f_number_unsigned_t amount, f_uint128ss_t * const uint128ss) { + f_status_t f_uint128ss_increase_by(const f_number_unsigned_t amount, f_uint128ss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!uint128ss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; + if (amount) { + if (structure->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - if (uint128ss->used + amount > uint128ss->size) { - if (uint128ss->used + amount > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + const f_number_unsigned_t length = structure->used + amount; - return private_f_uint128ss_resize(uint128ss->used + amount, uint128ss); + if (length > structure->size) { + if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + + return private_f_uint128ss_resize(structure->used + amount, structure); + } } return F_data_not; @@ -264,12 +214,12 @@ extern "C" { #endif // _di_f_uint128ss_increase_by_ #ifndef _di_f_uint128ss_resize_ - f_status_t f_uint128ss_resize(const f_number_unsigned_t length, f_uint128ss_t * const uint128ss) { + f_status_t f_uint128ss_resize(const f_number_unsigned_t length, f_uint128ss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!uint128ss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_uint128ss_resize(length, uint128ss); + return private_f_uint128ss_resize(length, structure); } #endif // _di_f_uint128ss_resize_ diff --git a/level_0/f_type_array/c/type_array/uint128.h b/level_0/f_type_array/c/type_array/uint128.h index 7f410c6..1c68028 100644 --- a/level_0/f_type_array/c/type_array/uint128.h +++ b/level_0/f_type_array/c/type_array/uint128.h @@ -21,7 +21,7 @@ extern "C" { * * @param length * The new size to use. - * @param uint128s + * @param structure * The string uint128s array to resize. * * @return @@ -29,10 +29,12 @@ extern "C" { * * 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_array_adjust(). + * + * @see f_memory_array_adjust() */ #ifndef _di_f_uint128s_adjust_ - extern f_status_t f_uint128s_adjust(const f_number_unsigned_t length, f_uint128s_t * const uint128s); + extern f_status_t f_uint128s_adjust(const f_number_unsigned_t length, f_uint128s_t * const structure); #endif // _di_f_uint128s_adjust_ /** @@ -49,7 +51,9 @@ extern "C" { * * 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(). + * + * @see f_memory_array_increase() */ #ifndef _di_f_uint128s_append_ extern f_status_t f_uint128s_append(const uint128_t source, f_uint128s_t * const destination); @@ -69,7 +73,9 @@ extern "C" { * * 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() */ #ifndef _di_f_uint128s_append_all_ extern f_status_t f_uint128s_append_all(const f_uint128s_t source, f_uint128s_t * const destination); @@ -84,7 +90,7 @@ extern "C" { * * @param amount * A positive number representing how much to decimate the size by. - * @param uint128s + * @param structure * The string uint128s array to resize. * * @return @@ -93,10 +99,12 @@ extern "C" { * * 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_array_decimate_by(). + * + * @see f_memory_array_decimate_by() */ #ifndef _di_f_uint128s_decimate_by_ - extern f_status_t f_uint128s_decimate_by(const f_number_unsigned_t amount, f_uint128s_t * const uint128s); + extern f_status_t f_uint128s_decimate_by(const f_number_unsigned_t amount, f_uint128s_t * const structure); #endif // _di_f_uint128s_decimate_by_ /** @@ -108,7 +116,7 @@ extern "C" { * * @param amount * A positive number representing how much to decrease the size by. - * @param uint128s + * @param structure * The string uint128s array to resize. * * @return @@ -117,10 +125,12 @@ extern "C" { * * 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_decrease_by(). + * + * @see f_memory_array_decrease_by() */ #ifndef _di_f_uint128s_decrease_by_ - extern f_status_t f_uint128s_decrease_by(const f_number_unsigned_t amount, f_uint128s_t * const uint128s); + extern f_status_t f_uint128s_decrease_by(const f_number_unsigned_t amount, f_uint128s_t * const structure); #endif // _di_f_uint128s_decrease_by_ /** @@ -132,7 +142,7 @@ extern "C" { * @param step * The allocation step to use. * Must be greater than 0. - * @param uint128s + * @param structure * The string uint128s array to resize. * * @return @@ -142,10 +152,12 @@ extern "C" { * F_array_too_large (with error bit) if the new array length is too large. * 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(). + * + * @see f_memory_array_increase() */ #ifndef _di_f_uint128s_increase_ - extern f_status_t f_uint128s_increase(const f_number_unsigned_t step, f_uint128s_t * const uint128s); + extern f_status_t f_uint128s_increase(const f_number_unsigned_t step, f_uint128s_t * const structure); #endif // _di_f_uint128s_increase_ /** @@ -157,7 +169,7 @@ extern "C" { * * @param amount * A positive number representing how much to increase the size by. - * @param uint128s + * @param structure * The string uint128s array to resize. * * @return @@ -167,10 +179,12 @@ extern "C" { * F_array_too_large (with error bit) if the new array length is too large. * 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() */ #ifndef _di_f_uint128s_increase_by_ - extern f_status_t f_uint128s_increase_by(const f_number_unsigned_t amount, f_uint128s_t * const uint128s); + extern f_status_t f_uint128s_increase_by(const f_number_unsigned_t amount, f_uint128s_t * const structure); #endif // _di_f_uint128s_increase_by_ /** @@ -178,7 +192,7 @@ extern "C" { * * @param length * The new size to use. - * @param uint128s + * @param structure * The string uint128s array to adjust. * * @return @@ -186,10 +200,12 @@ extern "C" { * * 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(). + * + * @see f_memory_array_resize() */ #ifndef _di_f_uint128s_resize_ - extern f_status_t f_uint128s_resize(const f_number_unsigned_t length, f_uint128s_t * const uint128s); + extern f_status_t f_uint128s_resize(const f_number_unsigned_t length, f_uint128s_t * const structure); #endif // _di_f_uint128s_resize_ /** @@ -197,7 +213,7 @@ extern "C" { * * @param length * The new size to use. - * @param uint128ss + * @param structure * The string uint128ss array to resize. * * @return @@ -205,11 +221,12 @@ extern "C" { * * 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() */ #ifndef _di_f_uint128ss_adjust_ - extern f_status_t f_uint128ss_adjust(const f_number_unsigned_t length, f_uint128ss_t * const uint128ss); + extern f_status_t f_uint128ss_adjust(const f_number_unsigned_t length, f_uint128ss_t * const structure); #endif // _di_f_uint128ss_adjust_ /** @@ -226,7 +243,11 @@ extern "C" { * * 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(). + * Errors (with error bit) from: f_memory_array_increase_by(). + * + * @see f_memory_array_increase() + * @see f_memory_array_increase_by() */ #ifndef _di_f_uint128ss_append_ extern f_status_t f_uint128ss_append(const f_uint128s_t source, f_uint128ss_t * const destination); @@ -246,7 +267,9 @@ extern "C" { * * 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() */ #ifndef _di_f_uint128ss_append_all_ extern f_status_t f_uint128ss_append_all(const f_uint128ss_t source, f_uint128ss_t * const destination); @@ -261,7 +284,7 @@ extern "C" { * * @param amount * A positive number representing how much to decimate the size by. - * @param uint128ss + * @param structure * The string uint128ss array to resize. * * @return @@ -269,11 +292,12 @@ extern "C" { * * 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() */ #ifndef _di_f_uint128ss_decimate_by_ - extern f_status_t f_uint128ss_decimate_by(const f_number_unsigned_t amount, f_uint128ss_t * const uint128ss); + extern f_status_t f_uint128ss_decimate_by(const f_number_unsigned_t amount, f_uint128ss_t * const structure); #endif // _di_f_uint128ss_decimate_by_ /** @@ -285,7 +309,7 @@ extern "C" { * * @param amount * A positive number representing how much to decrease the size by. - * @param uint128ss + * @param structure * The string uint128ss array to resize. * * @return @@ -293,11 +317,12 @@ extern "C" { * * 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() */ #ifndef _di_f_uint128ss_decrease_by_ - extern f_status_t f_uint128ss_decrease_by(const f_number_unsigned_t amount, f_uint128ss_t * const uint128ss); + extern f_status_t f_uint128ss_decrease_by(const f_number_unsigned_t amount, f_uint128ss_t * const structure); #endif // _di_f_uint128ss_decrease_by_ /** @@ -309,7 +334,7 @@ extern "C" { * @param step * The allocation step to use. * Must be greater than 0. - * @param uint128ss + * @param structure * The string uint128ss array to resize. * * @return @@ -319,10 +344,12 @@ extern "C" { * F_array_too_large (with error bit) if the new array length is too large. * 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(). + * + * @see f_memory_array_resize() */ #ifndef _di_f_uint128ss_increase_ - extern f_status_t f_uint128ss_increase(const f_number_unsigned_t step, f_uint128ss_t * const uint128ss); + extern f_status_t f_uint128ss_increase(const f_number_unsigned_t step, f_uint128ss_t * const structure); #endif // _di_f_uint128ss_increase_ /** @@ -334,7 +361,7 @@ extern "C" { * * @param amount * A positive number representing how much to increase the size by. - * @param uint128ss + * @param structure * The string uint128ss array to resize. * * @return @@ -344,10 +371,12 @@ extern "C" { * F_array_too_large (with error bit) if the new array length is too large. * 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(). + * + * @see f_memory_array_resize() */ #ifndef _di_f_uint128ss_increase_by_ - extern f_status_t f_uint128ss_increase_by(const f_number_unsigned_t amount, f_uint128ss_t * const uint128ss); + extern f_status_t f_uint128ss_increase_by(const f_number_unsigned_t amount, f_uint128ss_t * const structure); #endif // _di_f_uint128ss_increase_by_ /** @@ -355,7 +384,7 @@ extern "C" { * * @param length * The new size to use. - * @param uint128ss + * @param structure * The string uint128ss array to adjust. * * @return @@ -363,11 +392,12 @@ extern "C" { * * 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() */ #ifndef _di_f_uint128ss_resize_ - extern f_status_t f_uint128ss_resize(const f_number_unsigned_t length, f_uint128ss_t * const uint128ss); + extern f_status_t f_uint128ss_resize(const f_number_unsigned_t length, f_uint128ss_t * const structure); #endif // _di_f_uint128ss_resize_ #ifdef __cplusplus diff --git a/level_0/f_type_array/c/type_array/uint16.c b/level_0/f_type_array/c/type_array/uint16.c index 9ecabe0..91e6a02 100644 --- a/level_0/f_type_array/c/type_array/uint16.c +++ b/level_0/f_type_array/c/type_array/uint16.c @@ -7,12 +7,12 @@ extern "C" { #endif #ifndef _di_f_uint16s_adjust_ - f_status_t f_uint16s_adjust(const f_number_unsigned_t length, f_uint16s_t * const uint16s) { + f_status_t f_uint16s_adjust(const f_number_unsigned_t length, f_uint16s_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!uint16s) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_uint16s_adjust(length, uint16s); + return f_memory_array_adjust(length, sizeof(uint16_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_uint16s_adjust_ @@ -39,98 +39,62 @@ extern "C" { #endif // _di_f_uint16s_append_all_ #ifndef _di_f_uint16s_decimate_by_ - f_status_t f_uint16s_decimate_by(const f_number_unsigned_t amount, f_uint16s_t * const uint16s) { + f_status_t f_uint16s_decimate_by(const f_number_unsigned_t amount, f_uint16s_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!uint16s) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; - - if (uint16s->size - amount > 0) { - return private_f_uint16s_adjust(uint16s->size - amount, uint16s); - } - - return private_f_uint16s_adjust(0, uint16s); + return f_memory_array_decimate_by(amount, sizeof(uint16_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_uint16s_decimate_by_ #ifndef _di_f_uint16s_decrease_by_ - f_status_t f_uint16s_decrease_by(const f_number_unsigned_t amount, f_uint16s_t * const uint16s) { + f_status_t f_uint16s_decrease_by(const f_number_unsigned_t amount, f_uint16s_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!uint16s) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; - - if (uint16s->size - amount > 0) { - return private_f_uint16s_resize(uint16s->size - amount, uint16s); - } - - return private_f_uint16s_resize(0, uint16s); + return f_memory_array_decrease_by(amount, sizeof(uint16_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_uint16s_decrease_by_ #ifndef _di_f_uint16s_increase_ - f_status_t f_uint16s_increase(const f_number_unsigned_t step, f_uint16s_t * const uint16s) { + f_status_t f_uint16s_increase(const f_number_unsigned_t step, f_uint16s_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!uint16s) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (step && uint16s->used + 1 > uint16s->size) { - f_number_unsigned_t size = uint16s->used + step; - - if (size > F_number_t_size_unsigned_d) { - if (uint16s->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_uint16s_resize(size, uint16s); - } - - return F_data_not; + return f_memory_array_increase(step, sizeof(uint16_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_uint16s_increase_ #ifndef _di_f_uint16s_increase_by_ - f_status_t f_uint16s_increase_by(const f_number_unsigned_t amount, f_uint16s_t * const uint16s) { + f_status_t f_uint16s_increase_by(const f_number_unsigned_t amount, f_uint16s_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!uint16s) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; - - if (uint16s->used + amount > uint16s->size) { - if (uint16s->used + amount > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } - - return private_f_uint16s_resize(uint16s->used + amount, uint16s); - } - - return F_data_not; + return f_memory_array_increase_by(amount, sizeof(uint16_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_uint16s_increase_by_ #ifndef _di_f_uint16s_resize_ - f_status_t f_uint16s_resize(const f_number_unsigned_t length, f_uint16s_t * const uint16s) { + f_status_t f_uint16s_resize(const f_number_unsigned_t length, f_uint16s_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!uint16s) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_uint16s_resize(length, uint16s); + return f_memory_array_resize(length, sizeof(uint16_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_uint16s_resize_ #ifndef _di_f_uint16ss_adjust_ - f_status_t f_uint16ss_adjust(const f_number_unsigned_t length, f_uint16ss_t * const uint16ss) { + f_status_t f_uint16ss_adjust(const f_number_unsigned_t length, f_uint16ss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!uint16ss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_uint16ss_adjust(length, uint16ss); + return private_f_uint16ss_adjust(length, structure); } #endif // _di_f_uint16ss_adjust_ @@ -142,12 +106,8 @@ extern "C" { if (!source.used) return F_data_not; - f_status_t status = F_none; - - if (destination->used + 1 > destination->size) { - status = private_f_uint16ss_resize(destination->used + F_memory_default_allocation_small_d, destination); - if (F_status_is_error(status)) return status; - } + f_status_t status = f_memory_array_increase(F_memory_default_allocation_small_d, sizeof(f_uint16s_t), (void **) &destination->array, &destination->used, &destination->size); + if (F_status_is_error(status)) return status; status = private_f_uint16s_append_all(source, &destination->array[destination->used]); if (F_status_is_error(status)) return status; @@ -166,12 +126,8 @@ extern "C" { if (!source.used) return F_data_not; - f_status_t status = F_none; - - if (destination->used + source.used > destination->size) { - status = private_f_uint16ss_resize(destination->used + source.used, destination); - if (F_status_is_error(status)) return status; - } + f_status_t status = f_memory_array_increase_by(source.used, sizeof(f_uint16s_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->used) { @@ -188,55 +144,47 @@ extern "C" { #endif // _di_f_uint16ss_append_all_ #ifndef _di_f_uint16ss_decimate_by_ - f_status_t f_uint16ss_decimate_by(const f_number_unsigned_t amount, f_uint16ss_t * const uint16ss) { + f_status_t f_uint16ss_decimate_by(const f_number_unsigned_t amount, f_uint16ss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!uint16ss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - if (uint16ss->size - amount > 0) { - return private_f_uint16ss_adjust(uint16ss->size - amount, uint16ss); - } - - return private_f_uint16ss_adjust(0, uint16ss); + return private_f_uint16ss_adjust((structure->size - amount > 0) ? structure->size - amount : 0, structure); } #endif // _di_f_uint16ss_decimate_by_ #ifndef _di_f_uint16ss_decrease_by_ - f_status_t f_uint16ss_decrease_by(const f_number_unsigned_t amount, f_uint16ss_t * const uint16ss) { + f_status_t f_uint16ss_decrease_by(const f_number_unsigned_t amount, f_uint16ss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!uint16ss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - if (uint16ss->size - amount > 0) { - return private_f_uint16ss_resize(uint16ss->size - amount, uint16ss); - } - - return private_f_uint16ss_resize(0, uint16ss); + return private_f_uint16ss_resize((structure->size - amount > 0) ? structure->size - amount : 0, structure); } #endif // _di_f_uint16ss_decrease_by_ #ifndef _di_f_uint16ss_increase_ - f_status_t f_uint16ss_increase(const f_number_unsigned_t step, f_uint16ss_t * const uint16ss) { + f_status_t f_uint16ss_increase(const f_number_unsigned_t step, f_uint16ss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!uint16ss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (step && uint16ss->used + 1 > uint16ss->size) { - f_number_unsigned_t size = uint16ss->used + step; + if (step && structure->used + 1 > structure->size) { + if (structure->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + + f_number_unsigned_t length = structure->used + step; - if (size > F_number_t_size_unsigned_d) { - if (uint16ss->used + 1 > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + if (length > F_number_t_size_unsigned_d) { + if (structure->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - size = F_number_t_size_unsigned_d; + length = F_number_t_size_unsigned_d; } - return private_f_uint16ss_resize(size, uint16ss); + return private_f_uint16ss_resize(length, structure); } return F_data_not; @@ -244,19 +192,21 @@ extern "C" { #endif // _di_f_uint16ss_increase_ #ifndef _di_f_uint16ss_increase_by_ - f_status_t f_uint16ss_increase_by(const f_number_unsigned_t amount, f_uint16ss_t * const uint16ss) { + f_status_t f_uint16ss_increase_by(const f_number_unsigned_t amount, f_uint16ss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!uint16ss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; + if (amount) { + if (structure->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - if (uint16ss->used + amount > uint16ss->size) { - if (uint16ss->used + amount > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + const f_number_unsigned_t length = structure->used + amount; - return private_f_uint16ss_resize(uint16ss->used + amount, uint16ss); + if (length > structure->size) { + if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + + return private_f_uint16ss_resize(structure->used + amount, structure); + } } return F_data_not; @@ -264,12 +214,12 @@ extern "C" { #endif // _di_f_uint16ss_increase_by_ #ifndef _di_f_uint16ss_resize_ - f_status_t f_uint16ss_resize(const f_number_unsigned_t length, f_uint16ss_t * const uint16ss) { + f_status_t f_uint16ss_resize(const f_number_unsigned_t length, f_uint16ss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!uint16ss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_uint16ss_resize(length, uint16ss); + return private_f_uint16ss_resize(length, structure); } #endif // _di_f_uint16ss_resize_ diff --git a/level_0/f_type_array/c/type_array/uint16.h b/level_0/f_type_array/c/type_array/uint16.h index 09d2341..b7cd2dd 100644 --- a/level_0/f_type_array/c/type_array/uint16.h +++ b/level_0/f_type_array/c/type_array/uint16.h @@ -21,7 +21,7 @@ extern "C" { * * @param length * The new size to use. - * @param uint16s + * @param structure * The string uint16s array to resize. * * @return @@ -29,10 +29,12 @@ extern "C" { * * 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_array_adjust(). + * + * @see f_memory_array_adjust() */ #ifndef _di_f_uint16s_adjust_ - extern f_status_t f_uint16s_adjust(const f_number_unsigned_t length, f_uint16s_t * const uint16s); + extern f_status_t f_uint16s_adjust(const f_number_unsigned_t length, f_uint16s_t * const structure); #endif // _di_f_uint16s_adjust_ /** @@ -49,7 +51,9 @@ extern "C" { * * 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(). + * + * @see f_memory_array_increase() */ #ifndef _di_f_uint16s_append_ extern f_status_t f_uint16s_append(const uint16_t source, f_uint16s_t * const destination); @@ -69,7 +73,9 @@ extern "C" { * * 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() */ #ifndef _di_f_uint16s_append_all_ extern f_status_t f_uint16s_append_all(const f_uint16s_t source, f_uint16s_t * const destination); @@ -84,7 +90,7 @@ extern "C" { * * @param amount * A positive number representing how much to decimate the size by. - * @param uint16s + * @param structure * The string uint16s array to resize. * * @return @@ -93,10 +99,12 @@ extern "C" { * * 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_array_decimate_by(). + * + * @see f_memory_array_decimate_by() */ #ifndef _di_f_uint16s_decimate_by_ - extern f_status_t f_uint16s_decimate_by(const f_number_unsigned_t amount, f_uint16s_t * const uint16s); + extern f_status_t f_uint16s_decimate_by(const f_number_unsigned_t amount, f_uint16s_t * const structure); #endif // _di_f_uint16s_decimate_by_ /** @@ -108,18 +116,21 @@ extern "C" { * * @param amount * A positive number representing how much to decrease the size by. - * @param uint16s + * @param structure * The string uint16s array to resize. * * @return * F_none on success. + * F_data_not if amount is 0. * * 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_decrease_by(). + * + * @see f_memory_array_decrease_by() */ #ifndef _di_f_uint16s_decrease_by_ - extern f_status_t f_uint16s_decrease_by(const f_number_unsigned_t amount, f_uint16s_t * const uint16s); + extern f_status_t f_uint16s_decrease_by(const f_number_unsigned_t amount, f_uint16s_t * const structure); #endif // _di_f_uint16s_decrease_by_ /** @@ -131,7 +142,7 @@ extern "C" { * @param step * The allocation step to use. * Must be greater than 0. - * @param uint16s + * @param structure * The string uint16s array to resize. * * @return @@ -141,10 +152,12 @@ extern "C" { * F_array_too_large (with error bit) if the new array length is too large. * 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(). + * + * @see f_memory_array_increase() */ #ifndef _di_f_uint16s_increase_ - extern f_status_t f_uint16s_increase(const f_number_unsigned_t step, f_uint16s_t * const uint16s); + extern f_status_t f_uint16s_increase(const f_number_unsigned_t step, f_uint16s_t * const structure); #endif // _di_f_uint16s_increase_ /** @@ -156,7 +169,7 @@ extern "C" { * * @param amount * A positive number representing how much to increase the size by. - * @param uint16s + * @param structure * The string uint16s array to resize. * * @return @@ -166,10 +179,12 @@ extern "C" { * F_array_too_large (with error bit) if the new array length is too large. * 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() */ #ifndef _di_f_uint16s_increase_by_ - extern f_status_t f_uint16s_increase_by(const f_number_unsigned_t amount, f_uint16s_t * const uint16s); + extern f_status_t f_uint16s_increase_by(const f_number_unsigned_t amount, f_uint16s_t * const structure); #endif // _di_f_uint16s_increase_by_ /** @@ -177,7 +192,7 @@ extern "C" { * * @param length * The new size to use. - * @param uint16s + * @param structure * The string uint16s array to adjust. * * @return @@ -185,10 +200,12 @@ extern "C" { * * 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(). + * + * @see f_memory_array_resize() */ #ifndef _di_f_uint16s_resize_ - extern f_status_t f_uint16s_resize(const f_number_unsigned_t length, f_uint16s_t * const uint16s); + extern f_status_t f_uint16s_resize(const f_number_unsigned_t length, f_uint16s_t * const structure); #endif // _di_f_uint16s_resize_ /** @@ -196,7 +213,7 @@ extern "C" { * * @param length * The new size to use. - * @param uint16ss + * @param structure * The string uint16ss array to resize. * * @return @@ -204,11 +221,12 @@ extern "C" { * * 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() */ #ifndef _di_f_uint16ss_adjust_ - extern f_status_t f_uint16ss_adjust(const f_number_unsigned_t length, f_uint16ss_t * const uint16ss); + extern f_status_t f_uint16ss_adjust(const f_number_unsigned_t length, f_uint16ss_t * const structure); #endif // _di_f_uint16ss_adjust_ /** @@ -225,7 +243,11 @@ extern "C" { * * 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(). + * Errors (with error bit) from: f_memory_array_increase_by(). + * + * @see f_memory_array_increase() + * @see f_memory_array_increase_by() */ #ifndef _di_f_uint16ss_append_ extern f_status_t f_uint16ss_append(const f_uint16s_t source, f_uint16ss_t * const destination); @@ -245,7 +267,9 @@ extern "C" { * * 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() */ #ifndef _di_f_uint16ss_append_all_ extern f_status_t f_uint16ss_append_all(const f_uint16ss_t source, f_uint16ss_t * const destination); @@ -260,20 +284,20 @@ extern "C" { * * @param amount * A positive number representing how much to decimate the size by. - * @param uint16ss + * @param structure * The string uint16ss array to resize. * * @return * F_none on success. - * F_data_not if amount is 0. * * 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() */ #ifndef _di_f_uint16ss_decimate_by_ - extern f_status_t f_uint16ss_decimate_by(const f_number_unsigned_t amount, f_uint16ss_t * const uint16ss); + extern f_status_t f_uint16ss_decimate_by(const f_number_unsigned_t amount, f_uint16ss_t * const structure); #endif // _di_f_uint16ss_decimate_by_ /** @@ -285,7 +309,7 @@ extern "C" { * * @param amount * A positive number representing how much to decrease the size by. - * @param uint16ss + * @param structure * The string uint16ss array to resize. * * @return @@ -293,11 +317,12 @@ extern "C" { * * 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() */ #ifndef _di_f_uint16ss_decrease_by_ - extern f_status_t f_uint16ss_decrease_by(const f_number_unsigned_t amount, f_uint16ss_t * const uint16ss); + extern f_status_t f_uint16ss_decrease_by(const f_number_unsigned_t amount, f_uint16ss_t * const structure); #endif // _di_f_uint16ss_decrease_by_ /** @@ -309,7 +334,7 @@ extern "C" { * @param step * The allocation step to use. * Must be greater than 0. - * @param uint16ss + * @param structure * The string uint16ss array to resize. * * @return @@ -319,10 +344,12 @@ extern "C" { * F_array_too_large (with error bit) if the new array length is too large. * 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(). + * + * @see f_memory_array_resize() */ #ifndef _di_f_uint16ss_increase_ - extern f_status_t f_uint16ss_increase(const f_number_unsigned_t step, f_uint16ss_t * const uint16ss); + extern f_status_t f_uint16ss_increase(const f_number_unsigned_t step, f_uint16ss_t * const structure); #endif // _di_f_uint16ss_increase_ /** @@ -334,7 +361,7 @@ extern "C" { * * @param amount * A positive number representing how much to increase the size by. - * @param uint16ss + * @param structure * The string uint16ss array to resize. * * @return @@ -344,10 +371,12 @@ extern "C" { * F_array_too_large (with error bit) if the new array length is too large. * 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(). + * + * @see f_memory_array_resize() */ #ifndef _di_f_uint16ss_increase_by_ - extern f_status_t f_uint16ss_increase_by(const f_number_unsigned_t amount, f_uint16ss_t * const uint16ss); + extern f_status_t f_uint16ss_increase_by(const f_number_unsigned_t amount, f_uint16ss_t * const structure); #endif // _di_f_uint16ss_increase_by_ /** @@ -355,7 +384,7 @@ extern "C" { * * @param length * The new size to use. - * @param uint16ss + * @param structure * The string uint16ss array to adjust. * * @return @@ -363,11 +392,12 @@ extern "C" { * * 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() */ #ifndef _di_f_uint16ss_resize_ - extern f_status_t f_uint16ss_resize(const f_number_unsigned_t length, f_uint16ss_t * const uint16ss); + extern f_status_t f_uint16ss_resize(const f_number_unsigned_t length, f_uint16ss_t * const structure); #endif // _di_f_uint16ss_resize_ #ifdef __cplusplus diff --git a/level_0/f_type_array/c/type_array/uint32.c b/level_0/f_type_array/c/type_array/uint32.c index 6f314b4..84bf5ec 100644 --- a/level_0/f_type_array/c/type_array/uint32.c +++ b/level_0/f_type_array/c/type_array/uint32.c @@ -7,12 +7,12 @@ extern "C" { #endif #ifndef _di_f_uint32s_adjust_ - f_status_t f_uint32s_adjust(const f_number_unsigned_t length, f_uint32s_t * const uint32s) { + f_status_t f_uint32s_adjust(const f_number_unsigned_t length, f_uint32s_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!uint32s) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_uint32s_adjust(length, uint32s); + return f_memory_array_adjust(length, sizeof(uint32_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_uint32s_adjust_ @@ -39,98 +39,62 @@ extern "C" { #endif // _di_f_uint32s_append_all_ #ifndef _di_f_uint32s_decimate_by_ - f_status_t f_uint32s_decimate_by(const f_number_unsigned_t amount, f_uint32s_t * const uint32s) { + f_status_t f_uint32s_decimate_by(const f_number_unsigned_t amount, f_uint32s_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!uint32s) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; - - if (uint32s->size - amount > 0) { - return private_f_uint32s_adjust(uint32s->size - amount, uint32s); - } - - return private_f_uint32s_adjust(0, uint32s); + return f_memory_array_decimate_by(amount, sizeof(uint32_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_uint32s_decimate_by_ #ifndef _di_f_uint32s_decrease_by_ - f_status_t f_uint32s_decrease_by(const f_number_unsigned_t amount, f_uint32s_t * const uint32s) { + f_status_t f_uint32s_decrease_by(const f_number_unsigned_t amount, f_uint32s_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!uint32s) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; - - if (uint32s->size - amount > 0) { - return private_f_uint32s_resize(uint32s->size - amount, uint32s); - } - - return private_f_uint32s_resize(0, uint32s); + return f_memory_array_decrease_by(amount, sizeof(uint32_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_uint32s_decrease_by_ #ifndef _di_f_uint32s_increase_ - f_status_t f_uint32s_increase(const f_number_unsigned_t step, f_uint32s_t * const uint32s) { + f_status_t f_uint32s_increase(const f_number_unsigned_t step, f_uint32s_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!uint32s) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (step && uint32s->used + 1 > uint32s->size) { - f_number_unsigned_t size = uint32s->used + step; - - if (size > F_number_t_size_unsigned_d) { - if (uint32s->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_uint32s_resize(size, uint32s); - } - - return F_data_not; + return f_memory_array_increase(step, sizeof(uint32_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_uint32s_increase_ #ifndef _di_f_uint32s_increase_by_ - f_status_t f_uint32s_increase_by(const f_number_unsigned_t amount, f_uint32s_t * const uint32s) { + f_status_t f_uint32s_increase_by(const f_number_unsigned_t amount, f_uint32s_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!uint32s) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; - - if (uint32s->used + amount > uint32s->size) { - if (uint32s->used + amount > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } - - return private_f_uint32s_resize(uint32s->used + amount, uint32s); - } - - return F_data_not; + return f_memory_array_increase_by(amount, sizeof(uint32_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_uint32s_increase_by_ #ifndef _di_f_uint32s_resize_ - f_status_t f_uint32s_resize(const f_number_unsigned_t length, f_uint32s_t * const uint32s) { + f_status_t f_uint32s_resize(const f_number_unsigned_t length, f_uint32s_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!uint32s) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_uint32s_resize(length, uint32s); + return f_memory_array_resize(length, sizeof(uint32_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_uint32s_resize_ #ifndef _di_f_uint32ss_adjust_ - f_status_t f_uint32ss_adjust(const f_number_unsigned_t length, f_uint32ss_t * const uint32ss) { + f_status_t f_uint32ss_adjust(const f_number_unsigned_t length, f_uint32ss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!uint32ss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_uint32ss_adjust(length, uint32ss); + return private_f_uint32ss_adjust(length, structure); } #endif // _di_f_uint32ss_adjust_ @@ -142,12 +106,8 @@ extern "C" { if (!source.used) return F_data_not; - f_status_t status = F_none; - - if (destination->used + 1 > destination->size) { - status = private_f_uint32ss_resize(destination->used + F_memory_default_allocation_small_d, destination); - if (F_status_is_error(status)) return status; - } + f_status_t status = f_memory_array_increase(F_memory_default_allocation_small_d, sizeof(f_uint32s_t), (void **) &destination->array, &destination->used, &destination->size); + if (F_status_is_error(status)) return status; status = private_f_uint32s_append_all(source, &destination->array[destination->used]); if (F_status_is_error(status)) return status; @@ -166,12 +126,8 @@ extern "C" { if (!source.used) return F_data_not; - f_status_t status = F_none; - - if (destination->used + source.used > destination->size) { - status = private_f_uint32ss_resize(destination->used + source.used, destination); - if (F_status_is_error(status)) return status; - } + f_status_t status = f_memory_array_increase_by(source.used, sizeof(f_uint32s_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->used) { @@ -188,55 +144,47 @@ extern "C" { #endif // _di_f_uint32ss_append_all_ #ifndef _di_f_uint32ss_decimate_by_ - f_status_t f_uint32ss_decimate_by(const f_number_unsigned_t amount, f_uint32ss_t * const uint32ss) { + f_status_t f_uint32ss_decimate_by(const f_number_unsigned_t amount, f_uint32ss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!uint32ss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - if (uint32ss->size - amount > 0) { - return private_f_uint32ss_adjust(uint32ss->size - amount, uint32ss); - } - - return private_f_uint32ss_adjust(0, uint32ss); + return private_f_uint32ss_adjust((structure->size - amount > 0) ? structure->size - amount : 0, structure); } #endif // _di_f_uint32ss_decimate_by_ #ifndef _di_f_uint32ss_decrease_by_ - f_status_t f_uint32ss_decrease_by(const f_number_unsigned_t amount, f_uint32ss_t * const uint32ss) { + f_status_t f_uint32ss_decrease_by(const f_number_unsigned_t amount, f_uint32ss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!uint32ss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - if (uint32ss->size - amount > 0) { - return private_f_uint32ss_resize(uint32ss->size - amount, uint32ss); - } - - return private_f_uint32ss_resize(0, uint32ss); + return private_f_uint32ss_resize((structure->size - amount > 0) ? structure->size - amount : 0, structure); } #endif // _di_f_uint32ss_decrease_by_ #ifndef _di_f_uint32ss_increase_ - f_status_t f_uint32ss_increase(const f_number_unsigned_t step, f_uint32ss_t * const uint32ss) { + f_status_t f_uint32ss_increase(const f_number_unsigned_t step, f_uint32ss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!uint32ss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (step && uint32ss->used + 1 > uint32ss->size) { - f_number_unsigned_t size = uint32ss->used + step; + if (step && structure->used + 1 > structure->size) { + if (structure->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + + f_number_unsigned_t length = structure->used + step; - if (size > F_number_t_size_unsigned_d) { - if (uint32ss->used + 1 > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + if (length > F_number_t_size_unsigned_d) { + if (structure->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - size = F_number_t_size_unsigned_d; + length = F_number_t_size_unsigned_d; } - return private_f_uint32ss_resize(size, uint32ss); + return private_f_uint32ss_resize(length, structure); } return F_data_not; @@ -244,19 +192,21 @@ extern "C" { #endif // _di_f_uint32ss_increase_ #ifndef _di_f_uint32ss_increase_by_ - f_status_t f_uint32ss_increase_by(const f_number_unsigned_t amount, f_uint32ss_t * const uint32ss) { + f_status_t f_uint32ss_increase_by(const f_number_unsigned_t amount, f_uint32ss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!uint32ss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; + if (amount) { + if (structure->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - if (uint32ss->used + amount > uint32ss->size) { - if (uint32ss->used + amount > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + const f_number_unsigned_t length = structure->used + amount; - return private_f_uint32ss_resize(uint32ss->used + amount, uint32ss); + if (length > structure->size) { + if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + + return private_f_uint32ss_resize(structure->used + amount, structure); + } } return F_data_not; @@ -264,12 +214,12 @@ extern "C" { #endif // _di_f_uint32ss_increase_by_ #ifndef _di_f_uint32ss_resize_ - f_status_t f_uint32ss_resize(const f_number_unsigned_t length, f_uint32ss_t * const uint32ss) { + f_status_t f_uint32ss_resize(const f_number_unsigned_t length, f_uint32ss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!uint32ss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_uint32ss_resize(length, uint32ss); + return private_f_uint32ss_resize(length, structure); } #endif // _di_f_uint32ss_resize_ diff --git a/level_0/f_type_array/c/type_array/uint32.h b/level_0/f_type_array/c/type_array/uint32.h index bbb6762..06894ab 100644 --- a/level_0/f_type_array/c/type_array/uint32.h +++ b/level_0/f_type_array/c/type_array/uint32.h @@ -21,7 +21,7 @@ extern "C" { * * @param length * The new size to use. - * @param uint32s + * @param structure * The string uint32s array to resize. * * @return @@ -29,10 +29,12 @@ extern "C" { * * 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_array_adjust(). + * + * @see f_memory_array_adjust() */ #ifndef _di_f_uint32s_adjust_ - extern f_status_t f_uint32s_adjust(const f_number_unsigned_t length, f_uint32s_t * const uint32s); + extern f_status_t f_uint32s_adjust(const f_number_unsigned_t length, f_uint32s_t * const structure); #endif // _di_f_uint32s_adjust_ /** @@ -49,7 +51,9 @@ extern "C" { * * 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(). + * + * @see f_memory_array_increase() */ #ifndef _di_f_uint32s_append_ extern f_status_t f_uint32s_append(const uint32_t source, f_uint32s_t * const destination); @@ -69,7 +73,9 @@ extern "C" { * * 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() */ #ifndef _di_f_uint32s_append_all_ extern f_status_t f_uint32s_append_all(const f_uint32s_t source, f_uint32s_t * const destination); @@ -84,7 +90,7 @@ extern "C" { * * @param amount * A positive number representing how much to decimate the size by. - * @param uint32s + * @param structure * The string uint32s array to resize. * * @return @@ -93,10 +99,12 @@ extern "C" { * * 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_array_decimate_by(). + * + * @see f_memory_array_decimate_by() */ #ifndef _di_f_uint32s_decimate_by_ - extern f_status_t f_uint32s_decimate_by(const f_number_unsigned_t amount, f_uint32s_t * const uint32s); + extern f_status_t f_uint32s_decimate_by(const f_number_unsigned_t amount, f_uint32s_t * const structure); #endif // _di_f_uint32s_decimate_by_ /** @@ -108,18 +116,21 @@ extern "C" { * * @param amount * A positive number representing how much to decrease the size by. - * @param uint32s + * @param structure * The string uint32s array to resize. * * @return * F_none on success. + * F_data_not if amount is 0. * * 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_decrease_by(). + * + * @see f_memory_array_decrease_by() */ #ifndef _di_f_uint32s_decrease_by_ - extern f_status_t f_uint32s_decrease_by(const f_number_unsigned_t amount, f_uint32s_t * const uint32s); + extern f_status_t f_uint32s_decrease_by(const f_number_unsigned_t amount, f_uint32s_t * const structure); #endif // _di_f_uint32s_decrease_by_ /** @@ -131,7 +142,7 @@ extern "C" { * @param step * The allocation step to use. * Must be greater than 0. - * @param uint32s + * @param structure * The string uint32s array to resize. * * @return @@ -141,10 +152,12 @@ extern "C" { * F_array_too_large (with error bit) if the new array length is too large. * 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(). + * + * @see f_memory_array_increase() */ #ifndef _di_f_uint32s_increase_ - extern f_status_t f_uint32s_increase(const f_number_unsigned_t step, f_uint32s_t * const uint32s); + extern f_status_t f_uint32s_increase(const f_number_unsigned_t step, f_uint32s_t * const structure); #endif // _di_f_uint32s_increase_ /** @@ -156,7 +169,7 @@ extern "C" { * * @param amount * A positive number representing how much to increase the size by. - * @param uint32s + * @param structure * The string uint32s array to resize. * * @return @@ -166,10 +179,12 @@ extern "C" { * F_array_too_large (with error bit) if the new array length is too large. * 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() */ #ifndef _di_f_uint32s_increase_by_ - extern f_status_t f_uint32s_increase_by(const f_number_unsigned_t amount, f_uint32s_t * const uint32s); + extern f_status_t f_uint32s_increase_by(const f_number_unsigned_t amount, f_uint32s_t * const structure); #endif // _di_f_uint32s_increase_by_ /** @@ -177,7 +192,7 @@ extern "C" { * * @param length * The new size to use. - * @param uint32s + * @param structure * The string uint32s array to adjust. * * @return @@ -185,10 +200,12 @@ extern "C" { * * 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(). + * + * @see f_memory_array_resize() */ #ifndef _di_f_uint32s_resize_ - extern f_status_t f_uint32s_resize(const f_number_unsigned_t length, f_uint32s_t * const uint32s); + extern f_status_t f_uint32s_resize(const f_number_unsigned_t length, f_uint32s_t * const structure); #endif // _di_f_uint32s_resize_ /** @@ -196,7 +213,7 @@ extern "C" { * * @param length * The new size to use. - * @param uint32ss + * @param structure * The string uint32ss array to resize. * * @return @@ -204,11 +221,12 @@ extern "C" { * * 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() */ #ifndef _di_f_uint32ss_adjust_ - extern f_status_t f_uint32ss_adjust(const f_number_unsigned_t length, f_uint32ss_t * const uint32ss); + extern f_status_t f_uint32ss_adjust(const f_number_unsigned_t length, f_uint32ss_t * const structure); #endif // _di_f_uint32ss_adjust_ /** @@ -225,7 +243,11 @@ extern "C" { * * 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(). + * Errors (with error bit) from: f_memory_array_increase_by(). + * + * @see f_memory_array_increase() + * @see f_memory_array_increase_by() */ #ifndef _di_f_uint32ss_append_ extern f_status_t f_uint32ss_append(const f_uint32s_t source, f_uint32ss_t * const destination); @@ -245,7 +267,9 @@ extern "C" { * * 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() */ #ifndef _di_f_uint32ss_append_all_ extern f_status_t f_uint32ss_append_all(const f_uint32ss_t source, f_uint32ss_t * const destination); @@ -260,20 +284,20 @@ extern "C" { * * @param amount * A positive number representing how much to decimate the size by. - * @param uint32ss + * @param structure * The string uint32ss array to resize. * * @return * F_none on success. - * F_data_not if amount is 0. * * 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() */ #ifndef _di_f_uint32ss_decimate_by_ - extern f_status_t f_uint32ss_decimate_by(const f_number_unsigned_t amount, f_uint32ss_t * const uint32ss); + extern f_status_t f_uint32ss_decimate_by(const f_number_unsigned_t amount, f_uint32ss_t * const structure); #endif // _di_f_uint32ss_decimate_by_ /** @@ -285,7 +309,7 @@ extern "C" { * * @param amount * A positive number representing how much to decrease the size by. - * @param uint32ss + * @param structure * The string uint32ss array to resize. * * @return @@ -293,11 +317,12 @@ extern "C" { * * 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() */ #ifndef _di_f_uint32ss_decrease_by_ - extern f_status_t f_uint32ss_decrease_by(const f_number_unsigned_t amount, f_uint32ss_t * const uint32ss); + extern f_status_t f_uint32ss_decrease_by(const f_number_unsigned_t amount, f_uint32ss_t * const structure); #endif // _di_f_uint32ss_decrease_by_ /** @@ -309,7 +334,7 @@ extern "C" { * @param step * The allocation step to use. * Must be greater than 0. - * @param uint32ss + * @param structure * The string uint32ss array to resize. * * @return @@ -319,10 +344,12 @@ extern "C" { * F_array_too_large (with error bit) if the new array length is too large. * 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(). + * + * @see f_memory_array_resize() */ #ifndef _di_f_uint32ss_increase_ - extern f_status_t f_uint32ss_increase(const f_number_unsigned_t step, f_uint32ss_t * const uint32ss); + extern f_status_t f_uint32ss_increase(const f_number_unsigned_t step, f_uint32ss_t * const structure); #endif // _di_f_uint32ss_increase_ /** @@ -334,7 +361,7 @@ extern "C" { * * @param amount * A positive number representing how much to increase the size by. - * @param uint32ss + * @param structure * The string uint32ss array to resize. * * @return @@ -344,10 +371,12 @@ extern "C" { * F_array_too_large (with error bit) if the new array length is too large. * 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(). + * + * @see f_memory_array_resize() */ #ifndef _di_f_uint32ss_increase_by_ - extern f_status_t f_uint32ss_increase_by(const f_number_unsigned_t amount, f_uint32ss_t * const uint32ss); + extern f_status_t f_uint32ss_increase_by(const f_number_unsigned_t amount, f_uint32ss_t * const structure); #endif // _di_f_uint32ss_increase_by_ /** @@ -355,7 +384,7 @@ extern "C" { * * @param length * The new size to use. - * @param uint32ss + * @param structure * The string uint32ss array to adjust. * * @return @@ -363,11 +392,12 @@ extern "C" { * * 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() */ #ifndef _di_f_uint32ss_resize_ - extern f_status_t f_uint32ss_resize(const f_number_unsigned_t length, f_uint32ss_t * const uint32ss); + extern f_status_t f_uint32ss_resize(const f_number_unsigned_t length, f_uint32ss_t * const structure); #endif // _di_f_uint32ss_resize_ #ifdef __cplusplus diff --git a/level_0/f_type_array/c/type_array/uint64.c b/level_0/f_type_array/c/type_array/uint64.c index 529b063..facdc3b 100644 --- a/level_0/f_type_array/c/type_array/uint64.c +++ b/level_0/f_type_array/c/type_array/uint64.c @@ -7,12 +7,12 @@ extern "C" { #endif #ifndef _di_f_uint64s_adjust_ - f_status_t f_uint64s_adjust(const f_number_unsigned_t length, f_uint64s_t * const uint64s) { + f_status_t f_uint64s_adjust(const f_number_unsigned_t length, f_uint64s_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!uint64s) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_uint64s_adjust(length, uint64s); + return f_memory_array_adjust(length, sizeof(uint64_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_uint64s_adjust_ @@ -39,98 +39,62 @@ extern "C" { #endif // _di_f_uint64s_append_all_ #ifndef _di_f_uint64s_decimate_by_ - f_status_t f_uint64s_decimate_by(const f_number_unsigned_t amount, f_uint64s_t * const uint64s) { + f_status_t f_uint64s_decimate_by(const f_number_unsigned_t amount, f_uint64s_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!uint64s) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; - - if (uint64s->size - amount > 0) { - return private_f_uint64s_adjust(uint64s->size - amount, uint64s); - } - - return private_f_uint64s_adjust(0, uint64s); + return f_memory_array_decimate_by(amount, sizeof(uint64_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_uint64s_decimate_by_ #ifndef _di_f_uint64s_decrease_by_ - f_status_t f_uint64s_decrease_by(const f_number_unsigned_t amount, f_uint64s_t * const uint64s) { + f_status_t f_uint64s_decrease_by(const f_number_unsigned_t amount, f_uint64s_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!uint64s) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; - - if (uint64s->size - amount > 0) { - return private_f_uint64s_resize(uint64s->size - amount, uint64s); - } - - return private_f_uint64s_resize(0, uint64s); + return f_memory_array_decrease_by(amount, sizeof(uint64_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_uint64s_decrease_by_ #ifndef _di_f_uint64s_increase_ - f_status_t f_uint64s_increase(const f_number_unsigned_t step, f_uint64s_t * const uint64s) { + f_status_t f_uint64s_increase(const f_number_unsigned_t step, f_uint64s_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!uint64s) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (step && uint64s->used + 1 > uint64s->size) { - f_number_unsigned_t size = uint64s->used + step; - - if (size > F_number_t_size_unsigned_d) { - if (uint64s->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_uint64s_resize(size, uint64s); - } - - return F_data_not; + return f_memory_array_increase(step, sizeof(uint64_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_uint64s_increase_ #ifndef _di_f_uint64s_increase_by_ - f_status_t f_uint64s_increase_by(const f_number_unsigned_t amount, f_uint64s_t * const uint64s) { + f_status_t f_uint64s_increase_by(const f_number_unsigned_t amount, f_uint64s_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!uint64s) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; - - if (uint64s->used + amount > uint64s->size) { - if (uint64s->used + amount > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } - - return private_f_uint64s_resize(uint64s->used + amount, uint64s); - } - - return F_data_not; + return f_memory_array_increase_by(amount, sizeof(uint64_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_uint64s_increase_by_ #ifndef _di_f_uint64s_resize_ - f_status_t f_uint64s_resize(const f_number_unsigned_t length, f_uint64s_t * const uint64s) { + f_status_t f_uint64s_resize(const f_number_unsigned_t length, f_uint64s_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!uint64s) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_uint64s_resize(length, uint64s); + return f_memory_array_resize(length, sizeof(uint64_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_uint64s_resize_ #ifndef _di_f_uint64ss_adjust_ - f_status_t f_uint64ss_adjust(const f_number_unsigned_t length, f_uint64ss_t * const uint64ss) { + f_status_t f_uint64ss_adjust(const f_number_unsigned_t length, f_uint64ss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!uint64ss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_uint64ss_adjust(length, uint64ss); + return private_f_uint64ss_adjust(length, structure); } #endif // _di_f_uint64ss_adjust_ @@ -142,12 +106,8 @@ extern "C" { if (!source.used) return F_data_not; - f_status_t status = F_none; - - if (destination->used + 1 > destination->size) { - status = private_f_uint64ss_resize(destination->used + F_memory_default_allocation_small_d, destination); - if (F_status_is_error(status)) return status; - } + f_status_t status = f_memory_array_increase(F_memory_default_allocation_small_d, sizeof(f_uint64s_t), (void **) &destination->array, &destination->used, &destination->size); + if (F_status_is_error(status)) return status; status = private_f_uint64s_append_all(source, &destination->array[destination->used]); if (F_status_is_error(status)) return status; @@ -166,12 +126,8 @@ extern "C" { if (!source.used) return F_data_not; - f_status_t status = F_none; - - if (destination->used + source.used > destination->size) { - status = private_f_uint64ss_resize(destination->used + source.used, destination); - if (F_status_is_error(status)) return status; - } + f_status_t status = f_memory_array_increase_by(source.used, sizeof(f_uint64s_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->used) { @@ -188,55 +144,47 @@ extern "C" { #endif // _di_f_uint64ss_append_all_ #ifndef _di_f_uint64ss_decimate_by_ - f_status_t f_uint64ss_decimate_by(const f_number_unsigned_t amount, f_uint64ss_t * const uint64ss) { + f_status_t f_uint64ss_decimate_by(const f_number_unsigned_t amount, f_uint64ss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!uint64ss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - if (uint64ss->size - amount > 0) { - return private_f_uint64ss_adjust(uint64ss->size - amount, uint64ss); - } - - return private_f_uint64ss_adjust(0, uint64ss); + return private_f_uint64ss_adjust((structure->size - amount > 0) ? structure->size - amount : 0, structure); } #endif // _di_f_uint64ss_decimate_by_ #ifndef _di_f_uint64ss_decrease_by_ - f_status_t f_uint64ss_decrease_by(const f_number_unsigned_t amount, f_uint64ss_t * const uint64ss) { + f_status_t f_uint64ss_decrease_by(const f_number_unsigned_t amount, f_uint64ss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!uint64ss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - if (uint64ss->size - amount > 0) { - return private_f_uint64ss_resize(uint64ss->size - amount, uint64ss); - } - - return private_f_uint64ss_resize(0, uint64ss); + return private_f_uint64ss_resize((structure->size - amount > 0) ? structure->size - amount : 0, structure); } #endif // _di_f_uint64ss_decrease_by_ #ifndef _di_f_uint64ss_increase_ - f_status_t f_uint64ss_increase(const f_number_unsigned_t step, f_uint64ss_t * const uint64ss) { + f_status_t f_uint64ss_increase(const f_number_unsigned_t step, f_uint64ss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!uint64ss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (step && uint64ss->used + 1 > uint64ss->size) { - f_number_unsigned_t size = uint64ss->used + step; + if (step && structure->used + 1 > structure->size) { + if (structure->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + + f_number_unsigned_t length = structure->used + step; - if (size > F_number_t_size_unsigned_d) { - if (uint64ss->used + 1 > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + if (length > F_number_t_size_unsigned_d) { + if (structure->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - size = F_number_t_size_unsigned_d; + length = F_number_t_size_unsigned_d; } - return private_f_uint64ss_resize(size, uint64ss); + return private_f_uint64ss_resize(length, structure); } return F_data_not; @@ -244,19 +192,21 @@ extern "C" { #endif // _di_f_uint64ss_increase_ #ifndef _di_f_uint64ss_increase_by_ - f_status_t f_uint64ss_increase_by(const f_number_unsigned_t amount, f_uint64ss_t * const uint64ss) { + f_status_t f_uint64ss_increase_by(const f_number_unsigned_t amount, f_uint64ss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!uint64ss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; + if (amount) { + if (structure->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - if (uint64ss->used + amount > uint64ss->size) { - if (uint64ss->used + amount > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + const f_number_unsigned_t length = structure->used + amount; - return private_f_uint64ss_resize(uint64ss->used + amount, uint64ss); + if (length > structure->size) { + if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + + return private_f_uint64ss_resize(structure->used + amount, structure); + } } return F_data_not; @@ -264,12 +214,12 @@ extern "C" { #endif // _di_f_uint64ss_increase_by_ #ifndef _di_f_uint64ss_resize_ - f_status_t f_uint64ss_resize(const f_number_unsigned_t length, f_uint64ss_t * const uint64ss) { + f_status_t f_uint64ss_resize(const f_number_unsigned_t length, f_uint64ss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!uint64ss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_uint64ss_resize(length, uint64ss); + return private_f_uint64ss_resize(length, structure); } #endif // _di_f_uint64ss_resize_ diff --git a/level_0/f_type_array/c/type_array/uint64.h b/level_0/f_type_array/c/type_array/uint64.h index 8780a21..c477fab 100644 --- a/level_0/f_type_array/c/type_array/uint64.h +++ b/level_0/f_type_array/c/type_array/uint64.h @@ -21,7 +21,7 @@ extern "C" { * * @param length * The new size to use. - * @param uint64s + * @param structure * The string uint64s array to resize. * * @return @@ -29,10 +29,12 @@ extern "C" { * * 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_array_adjust(). + * + * @see f_memory_array_adjust() */ #ifndef _di_f_uint64s_adjust_ - extern f_status_t f_uint64s_adjust(const f_number_unsigned_t length, f_uint64s_t * const uint64s); + extern f_status_t f_uint64s_adjust(const f_number_unsigned_t length, f_uint64s_t * const structure); #endif // _di_f_uint64s_adjust_ /** @@ -49,7 +51,9 @@ extern "C" { * * 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(). + * + * @see f_memory_array_increase() */ #ifndef _di_f_uint64s_append_ extern f_status_t f_uint64s_append(const uint64_t source, f_uint64s_t * const destination); @@ -69,7 +73,9 @@ extern "C" { * * 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() */ #ifndef _di_f_uint64s_append_all_ extern f_status_t f_uint64s_append_all(const f_uint64s_t source, f_uint64s_t * const destination); @@ -84,7 +90,7 @@ extern "C" { * * @param amount * A positive number representing how much to decimate the size by. - * @param uint64s + * @param structure * The string uint64s array to resize. * * @return @@ -93,10 +99,12 @@ extern "C" { * * 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_array_decimate_by(). + * + * @see f_memory_array_decimate_by() */ #ifndef _di_f_uint64s_decimate_by_ - extern f_status_t f_uint64s_decimate_by(const f_number_unsigned_t amount, f_uint64s_t * const uint64s); + extern f_status_t f_uint64s_decimate_by(const f_number_unsigned_t amount, f_uint64s_t * const structure); #endif // _di_f_uint64s_decimate_by_ /** @@ -108,7 +116,7 @@ extern "C" { * * @param amount * A positive number representing how much to decrease the size by. - * @param uint64s + * @param structure * The string uint64s array to resize. * * @return @@ -117,10 +125,12 @@ extern "C" { * * 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_decrease_by(). + * + * @see f_memory_array_decrease_by() */ #ifndef _di_f_uint64s_decrease_by_ - extern f_status_t f_uint64s_decrease_by(const f_number_unsigned_t amount, f_uint64s_t * const uint64s); + extern f_status_t f_uint64s_decrease_by(const f_number_unsigned_t amount, f_uint64s_t * const structure); #endif // _di_f_uint64s_decrease_by_ /** @@ -132,7 +142,7 @@ extern "C" { * @param step * The allocation step to use. * Must be greater than 0. - * @param uint64s + * @param structure * The string uint64s array to resize. * * @return @@ -142,10 +152,12 @@ extern "C" { * F_array_too_large (with error bit) if the new array length is too large. * 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(). + * + * @see f_memory_array_increase() */ #ifndef _di_f_uint64s_increase_ - extern f_status_t f_uint64s_increase(const f_number_unsigned_t step, f_uint64s_t * const uint64s); + extern f_status_t f_uint64s_increase(const f_number_unsigned_t step, f_uint64s_t * const structure); #endif // _di_f_uint64s_increase_ /** @@ -157,7 +169,7 @@ extern "C" { * * @param amount * A positive number representing how much to increase the size by. - * @param uint64s + * @param structure * The string uint64s array to resize. * * @return @@ -167,10 +179,12 @@ extern "C" { * F_array_too_large (with error bit) if the new array length is too large. * 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() */ #ifndef _di_f_uint64s_increase_by_ - extern f_status_t f_uint64s_increase_by(const f_number_unsigned_t amount, f_uint64s_t * const uint64s); + extern f_status_t f_uint64s_increase_by(const f_number_unsigned_t amount, f_uint64s_t * const structure); #endif // _di_f_uint64s_increase_by_ /** @@ -178,7 +192,7 @@ extern "C" { * * @param length * The new size to use. - * @param uint64s + * @param structure * The string uint64s array to adjust. * * @return @@ -186,10 +200,12 @@ extern "C" { * * 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(). + * + * @see f_memory_array_resize() */ #ifndef _di_f_uint64s_resize_ - extern f_status_t f_uint64s_resize(const f_number_unsigned_t length, f_uint64s_t * const uint64s); + extern f_status_t f_uint64s_resize(const f_number_unsigned_t length, f_uint64s_t * const structure); #endif // _di_f_uint64s_resize_ /** @@ -197,7 +213,7 @@ extern "C" { * * @param length * The new size to use. - * @param uint64ss + * @param structure * The string uint64ss array to resize. * * @return @@ -205,11 +221,12 @@ extern "C" { * * 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() */ #ifndef _di_f_uint64ss_adjust_ - extern f_status_t f_uint64ss_adjust(const f_number_unsigned_t length, f_uint64ss_t * const uint64ss); + extern f_status_t f_uint64ss_adjust(const f_number_unsigned_t length, f_uint64ss_t * const structure); #endif // _di_f_uint64ss_adjust_ /** @@ -226,7 +243,11 @@ extern "C" { * * 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(). + * Errors (with error bit) from: f_memory_array_increase_by(). + * + * @see f_memory_array_increase() + * @see f_memory_array_increase_by() */ #ifndef _di_f_uint64ss_append_ extern f_status_t f_uint64ss_append(const f_uint64s_t source, f_uint64ss_t * const destination); @@ -246,7 +267,9 @@ extern "C" { * * 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() */ #ifndef _di_f_uint64ss_append_all_ extern f_status_t f_uint64ss_append_all(const f_uint64ss_t source, f_uint64ss_t * const destination); @@ -261,20 +284,20 @@ extern "C" { * * @param amount * A positive number representing how much to decimate the size by. - * @param uint64ss + * @param structure * The string uint64ss array to resize. * * @return * F_none on success. - * F_data_not if amount is 0. * * 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() */ #ifndef _di_f_uint64ss_decimate_by_ - extern f_status_t f_uint64ss_decimate_by(const f_number_unsigned_t amount, f_uint64ss_t * const uint64ss); + extern f_status_t f_uint64ss_decimate_by(const f_number_unsigned_t amount, f_uint64ss_t * const structure); #endif // _di_f_uint64ss_decimate_by_ /** @@ -286,20 +309,20 @@ extern "C" { * * @param amount * A positive number representing how much to decrease the size by. - * @param uint64ss + * @param structure * The string uint64ss array to resize. * * @return * F_none on success. - * F_data_not if amount is 0. * * 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() */ #ifndef _di_f_uint64ss_decrease_by_ - extern f_status_t f_uint64ss_decrease_by(const f_number_unsigned_t amount, f_uint64ss_t * const uint64ss); + extern f_status_t f_uint64ss_decrease_by(const f_number_unsigned_t amount, f_uint64ss_t * const structure); #endif // _di_f_uint64ss_decrease_by_ /** @@ -311,7 +334,7 @@ extern "C" { * @param step * The allocation step to use. * Must be greater than 0. - * @param uint64ss + * @param structure * The string uint64ss array to resize. * * @return @@ -321,10 +344,12 @@ extern "C" { * F_array_too_large (with error bit) if the new array length is too large. * 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(). + * + * @see f_memory_array_resize() */ #ifndef _di_f_uint64ss_increase_ - extern f_status_t f_uint64ss_increase(const f_number_unsigned_t step, f_uint64ss_t * const uint64ss); + extern f_status_t f_uint64ss_increase(const f_number_unsigned_t step, f_uint64ss_t * const structure); #endif // _di_f_uint64ss_increase_ /** @@ -336,7 +361,7 @@ extern "C" { * * @param amount * A positive number representing how much to increase the size by. - * @param uint64ss + * @param structure * The string uint64ss array to resize. * * @return @@ -346,10 +371,12 @@ extern "C" { * F_array_too_large (with error bit) if the new array length is too large. * 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(). + * + * @see f_memory_array_resize() */ #ifndef _di_f_uint64ss_increase_by_ - extern f_status_t f_uint64ss_increase_by(const f_number_unsigned_t amount, f_uint64ss_t * const uint64ss); + extern f_status_t f_uint64ss_increase_by(const f_number_unsigned_t amount, f_uint64ss_t * const structure); #endif // _di_f_uint64ss_increase_by_ /** @@ -357,7 +384,7 @@ extern "C" { * * @param length * The new size to use. - * @param uint64ss + * @param structure * The string uint64ss array to adjust. * * @return @@ -365,11 +392,12 @@ extern "C" { * * 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() */ #ifndef _di_f_uint64ss_resize_ - extern f_status_t f_uint64ss_resize(const f_number_unsigned_t length, f_uint64ss_t * const uint64ss); + extern f_status_t f_uint64ss_resize(const f_number_unsigned_t length, f_uint64ss_t * const structure); #endif // _di_f_uint64ss_resize_ #ifdef __cplusplus diff --git a/level_0/f_type_array/c/type_array/uint8.c b/level_0/f_type_array/c/type_array/uint8.c index 9ae8a74..4441883 100644 --- a/level_0/f_type_array/c/type_array/uint8.c +++ b/level_0/f_type_array/c/type_array/uint8.c @@ -7,12 +7,12 @@ extern "C" { #endif #ifndef _di_f_uint8s_adjust_ - f_status_t f_uint8s_adjust(const f_number_unsigned_t length, f_uint8s_t * const uint8s) { + f_status_t f_uint8s_adjust(const f_number_unsigned_t length, f_uint8s_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!uint8s) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_uint8s_adjust(length, uint8s); + return f_memory_array_adjust(length, sizeof(uint8_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_uint8s_adjust_ @@ -39,98 +39,62 @@ extern "C" { #endif // _di_f_uint8s_append_all_ #ifndef _di_f_uint8s_decimate_by_ - f_status_t f_uint8s_decimate_by(const f_number_unsigned_t amount, f_uint8s_t * const uint8s) { + f_status_t f_uint8s_decimate_by(const f_number_unsigned_t amount, f_uint8s_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!uint8s) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; - - if (uint8s->size - amount > 0) { - return private_f_uint8s_adjust(uint8s->size - amount, uint8s); - } - - return private_f_uint8s_adjust(0, uint8s); + return f_memory_array_decimate_by(amount, sizeof(uint8_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_uint8s_decimate_by_ #ifndef _di_f_uint8s_decrease_by_ - f_status_t f_uint8s_decrease_by(const f_number_unsigned_t amount, f_uint8s_t * const uint8s) { + f_status_t f_uint8s_decrease_by(const f_number_unsigned_t amount, f_uint8s_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!uint8s) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; - - if (uint8s->size - amount > 0) { - return private_f_uint8s_resize(uint8s->size - amount, uint8s); - } - - return private_f_uint8s_resize(0, uint8s); + return f_memory_array_decrease_by(amount, sizeof(uint8_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_uint8s_decrease_by_ #ifndef _di_f_uint8s_increase_ - f_status_t f_uint8s_increase(const f_number_unsigned_t step, f_uint8s_t * const uint8s) { + f_status_t f_uint8s_increase(const f_number_unsigned_t step, f_uint8s_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!uint8s) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (step && uint8s->used + 1 > uint8s->size) { - f_number_unsigned_t size = uint8s->used + step; - - if (size > F_number_t_size_unsigned_d) { - if (uint8s->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_uint8s_resize(size, uint8s); - } - - return F_data_not; + return f_memory_array_increase(step, sizeof(uint8_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_uint8s_increase_ #ifndef _di_f_uint8s_increase_by_ - f_status_t f_uint8s_increase_by(const f_number_unsigned_t amount, f_uint8s_t * const uint8s) { + f_status_t f_uint8s_increase_by(const f_number_unsigned_t amount, f_uint8s_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!uint8s) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; - - if (uint8s->used + amount > uint8s->size) { - if (uint8s->used + amount > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } - - return private_f_uint8s_resize(uint8s->used + amount, uint8s); - } - - return F_data_not; + return f_memory_array_increase_by(amount, sizeof(uint8_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_uint8s_increase_by_ #ifndef _di_f_uint8s_resize_ - f_status_t f_uint8s_resize(const f_number_unsigned_t length, f_uint8s_t * const uint8s) { + f_status_t f_uint8s_resize(const f_number_unsigned_t length, f_uint8s_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!uint8s) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_uint8s_resize(length, uint8s); + return f_memory_array_resize(length, sizeof(uint8_t), (void **) &structure->array, &structure->used, &structure->size); } #endif // _di_f_uint8s_resize_ #ifndef _di_f_uint8ss_adjust_ - f_status_t f_uint8ss_adjust(const f_number_unsigned_t length, f_uint8ss_t * const uint8ss) { + f_status_t f_uint8ss_adjust(const f_number_unsigned_t length, f_uint8ss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!uint8ss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_uint8ss_adjust(length, uint8ss); + return private_f_uint8ss_adjust(length, structure); } #endif // _di_f_uint8ss_adjust_ @@ -142,12 +106,8 @@ extern "C" { if (!source.used) return F_data_not; - f_status_t status = F_none; - - if (destination->used + 1 > destination->size) { - status = private_f_uint8ss_resize(destination->used + F_memory_default_allocation_small_d, destination); - if (F_status_is_error(status)) return status; - } + f_status_t status = f_memory_array_increase(F_memory_default_allocation_small_d, sizeof(f_uint8s_t), (void **) &destination->array, &destination->used, &destination->size); + if (F_status_is_error(status)) return status; status = private_f_uint8s_append_all(source, &destination->array[destination->used]); if (F_status_is_error(status)) return status; @@ -166,12 +126,8 @@ extern "C" { if (!source.used) return F_data_not; - f_status_t status = F_none; - - if (destination->used + source.used > destination->size) { - status = private_f_uint8ss_resize(destination->used + source.used, destination); - if (F_status_is_error(status)) return status; - } + f_status_t status = f_memory_array_increase_by(source.used, sizeof(f_uint8s_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->used) { @@ -188,55 +144,47 @@ extern "C" { #endif // _di_f_uint8ss_append_all_ #ifndef _di_f_uint8ss_decimate_by_ - f_status_t f_uint8ss_decimate_by(const f_number_unsigned_t amount, f_uint8ss_t * const uint8ss) { + f_status_t f_uint8ss_decimate_by(const f_number_unsigned_t amount, f_uint8ss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!uint8ss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - if (uint8ss->size - amount > 0) { - return private_f_uint8ss_adjust(uint8ss->size - amount, uint8ss); - } - - return private_f_uint8ss_adjust(0, uint8ss); + return private_f_uint8ss_adjust((structure->size - amount > 0) ? structure->size - amount : 0, structure); } #endif // _di_f_uint8ss_decimate_by_ #ifndef _di_f_uint8ss_decrease_by_ - f_status_t f_uint8ss_decrease_by(const f_number_unsigned_t amount, f_uint8ss_t * const uint8ss) { + f_status_t f_uint8ss_decrease_by(const f_number_unsigned_t amount, f_uint8ss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!uint8ss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - if (uint8ss->size - amount > 0) { - return private_f_uint8ss_resize(uint8ss->size - amount, uint8ss); - } - - return private_f_uint8ss_resize(0, uint8ss); + return private_f_uint8ss_resize((structure->size - amount > 0) ? structure->size - amount : 0, structure); } #endif // _di_f_uint8ss_decrease_by_ #ifndef _di_f_uint8ss_increase_ - f_status_t f_uint8ss_increase(const f_number_unsigned_t step, f_uint8ss_t * const uint8ss) { + f_status_t f_uint8ss_increase(const f_number_unsigned_t step, f_uint8ss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!uint8ss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (step && uint8ss->used + 1 > uint8ss->size) { - f_number_unsigned_t size = uint8ss->used + step; + if (step && structure->used + 1 > structure->size) { + if (structure->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + + f_number_unsigned_t length = structure->used + step; - if (size > F_number_t_size_unsigned_d) { - if (uint8ss->used + 1 > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + if (length > F_number_t_size_unsigned_d) { + if (structure->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - size = F_number_t_size_unsigned_d; + length = F_number_t_size_unsigned_d; } - return private_f_uint8ss_resize(size, uint8ss); + return private_f_uint8ss_resize(length, structure); } return F_data_not; @@ -244,19 +192,21 @@ extern "C" { #endif // _di_f_uint8ss_increase_ #ifndef _di_f_uint8ss_increase_by_ - f_status_t f_uint8ss_increase_by(const f_number_unsigned_t amount, f_uint8ss_t * const uint8ss) { + f_status_t f_uint8ss_increase_by(const f_number_unsigned_t amount, f_uint8ss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!uint8ss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; + if (amount) { + if (structure->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - if (uint8ss->used + amount > uint8ss->size) { - if (uint8ss->used + amount > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + const f_number_unsigned_t length = structure->used + amount; - return private_f_uint8ss_resize(uint8ss->used + amount, uint8ss); + if (length > structure->size) { + if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + + return private_f_uint8ss_resize(structure->used + amount, structure); + } } return F_data_not; @@ -264,12 +214,12 @@ extern "C" { #endif // _di_f_uint8ss_increase_by_ #ifndef _di_f_uint8ss_resize_ - f_status_t f_uint8ss_resize(const f_number_unsigned_t length, f_uint8ss_t * const uint8ss) { + f_status_t f_uint8ss_resize(const f_number_unsigned_t length, f_uint8ss_t * const structure) { #ifndef _di_level_0_parameter_checking_ - if (!uint8ss) return F_status_set_error(F_parameter); + if (!structure) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_uint8ss_resize(length, uint8ss); + return private_f_uint8ss_resize(length, structure); } #endif // _di_f_uint8ss_resize_ diff --git a/level_0/f_type_array/c/type_array/uint8.h b/level_0/f_type_array/c/type_array/uint8.h index e7637f2..9dc7dee 100644 --- a/level_0/f_type_array/c/type_array/uint8.h +++ b/level_0/f_type_array/c/type_array/uint8.h @@ -21,7 +21,7 @@ extern "C" { * * @param length * The new size to use. - * @param uint8s + * @param structure * The string uint8s array to resize. * * @return @@ -29,10 +29,12 @@ extern "C" { * * 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_array_adjust(). + * + * @see f_memory_array_adjust() */ #ifndef _di_f_uint8s_adjust_ - extern f_status_t f_uint8s_adjust(const f_number_unsigned_t length, f_uint8s_t * const uint8s); + extern f_status_t f_uint8s_adjust(const f_number_unsigned_t length, f_uint8s_t * const structure); #endif // _di_f_uint8s_adjust_ /** @@ -49,7 +51,9 @@ extern "C" { * * 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(). + * + * @see f_memory_array_increase() */ #ifndef _di_f_uint8s_append_ extern f_status_t f_uint8s_append(const uint8_t source, f_uint8s_t * const destination); @@ -69,7 +73,9 @@ extern "C" { * * 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() */ #ifndef _di_f_uint8s_append_all_ extern f_status_t f_uint8s_append_all(const f_uint8s_t source, f_uint8s_t * const destination); @@ -84,7 +90,7 @@ extern "C" { * * @param amount * A positive number representing how much to decimate the size by. - * @param uint8s + * @param structure * The string uint8s array to resize. * * @return @@ -93,10 +99,12 @@ extern "C" { * * 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_array_decimate_by(). + * + * @see f_memory_array_decimate_by() */ #ifndef _di_f_uint8s_decimate_by_ - extern f_status_t f_uint8s_decimate_by(const f_number_unsigned_t amount, f_uint8s_t * const uint8s); + extern f_status_t f_uint8s_decimate_by(const f_number_unsigned_t amount, f_uint8s_t * const structure); #endif // _di_f_uint8s_decimate_by_ /** @@ -108,7 +116,7 @@ extern "C" { * * @param amount * A positive number representing how much to decrease the size by. - * @param uint8s + * @param structure * The string uint8s array to resize. * * @return @@ -117,10 +125,12 @@ extern "C" { * * 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_decrease_by(). + * + * @see f_memory_array_decrease_by() */ #ifndef _di_f_uint8s_decrease_by_ - extern f_status_t f_uint8s_decrease_by(const f_number_unsigned_t amount, f_uint8s_t * const uint8s); + extern f_status_t f_uint8s_decrease_by(const f_number_unsigned_t amount, f_uint8s_t * const structure); #endif // _di_f_uint8s_decrease_by_ /** @@ -132,7 +142,7 @@ extern "C" { * @param step * The allocation step to use. * Must be greater than 0. - * @param uint8s + * @param structure * The string uint8s array to resize. * * @return @@ -142,10 +152,12 @@ extern "C" { * F_array_too_large (with error bit) if the new array length is too large. * 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(). + * + * @see f_memory_array_increase() */ #ifndef _di_f_uint8s_increase_ - extern f_status_t f_uint8s_increase(const f_number_unsigned_t step, f_uint8s_t * const uint8s); + extern f_status_t f_uint8s_increase(const f_number_unsigned_t step, f_uint8s_t * const structure); #endif // _di_f_uint8s_increase_ /** @@ -157,7 +169,7 @@ extern "C" { * * @param amount * A positive number representing how much to increase the size by. - * @param uint8s + * @param structure * The string uint8s array to resize. * * @return @@ -167,10 +179,12 @@ extern "C" { * F_array_too_large (with error bit) if the new array length is too large. * 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() */ #ifndef _di_f_uint8s_increase_by_ - extern f_status_t f_uint8s_increase_by(const f_number_unsigned_t amount, f_uint8s_t * const uint8s); + extern f_status_t f_uint8s_increase_by(const f_number_unsigned_t amount, f_uint8s_t * const structure); #endif // _di_f_uint8s_increase_by_ /** @@ -178,7 +192,7 @@ extern "C" { * * @param length * The new size to use. - * @param uint8s + * @param structure * The string uint8s array to adjust. * * @return @@ -186,10 +200,12 @@ extern "C" { * * 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(). + * + * @see f_memory_array_resize() */ #ifndef _di_f_uint8s_resize_ - extern f_status_t f_uint8s_resize(const f_number_unsigned_t length, f_uint8s_t * const uint8s); + extern f_status_t f_uint8s_resize(const f_number_unsigned_t length, f_uint8s_t * const structure); #endif // _di_f_uint8s_resize_ /** @@ -197,7 +213,7 @@ extern "C" { * * @param length * The new size to use. - * @param uint8ss + * @param structure * The string uint8ss array to resize. * * @return @@ -205,11 +221,12 @@ extern "C" { * * 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() */ #ifndef _di_f_uint8ss_adjust_ - extern f_status_t f_uint8ss_adjust(const f_number_unsigned_t length, f_uint8ss_t * const uint8ss); + extern f_status_t f_uint8ss_adjust(const f_number_unsigned_t length, f_uint8ss_t * const structure); #endif // _di_f_uint8ss_adjust_ /** @@ -226,7 +243,11 @@ extern "C" { * * 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(). + * Errors (with error bit) from: f_memory_array_increase_by(). + * + * @see f_memory_array_increase() + * @see f_memory_array_increase_by() */ #ifndef _di_f_uint8ss_append_ extern f_status_t f_uint8ss_append(const f_uint8s_t source, f_uint8ss_t * const destination); @@ -246,7 +267,9 @@ extern "C" { * * 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() */ #ifndef _di_f_uint8ss_append_all_ extern f_status_t f_uint8ss_append_all(const f_uint8ss_t source, f_uint8ss_t * const destination); @@ -261,20 +284,20 @@ extern "C" { * * @param amount * A positive number representing how much to decimate the size by. - * @param uint8ss + * @param structure * The string uint8ss array to resize. * * @return * F_none on success. - * F_data_not if amount is 0. * * 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() */ #ifndef _di_f_uint8ss_decimate_by_ - extern f_status_t f_uint8ss_decimate_by(const f_number_unsigned_t amount, f_uint8ss_t * const uint8ss); + extern f_status_t f_uint8ss_decimate_by(const f_number_unsigned_t amount, f_uint8ss_t * const structure); #endif // _di_f_uint8ss_decimate_by_ /** @@ -286,20 +309,20 @@ extern "C" { * * @param amount * A positive number representing how much to decrease the size by. - * @param uint8ss + * @param structure * The string uint8ss array to resize. * * @return * F_none on success. - * F_data_not if amount is 0. * * 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() */ #ifndef _di_f_uint8ss_decrease_by_ - extern f_status_t f_uint8ss_decrease_by(const f_number_unsigned_t amount, f_uint8ss_t * const uint8ss); + extern f_status_t f_uint8ss_decrease_by(const f_number_unsigned_t amount, f_uint8ss_t * const structure); #endif // _di_f_uint8ss_decrease_by_ /** @@ -311,7 +334,7 @@ extern "C" { * @param step * The allocation step to use. * Must be greater than 0. - * @param uint8ss + * @param structure * The string uint8ss array to resize. * * @return @@ -321,10 +344,12 @@ extern "C" { * F_array_too_large (with error bit) if the new array length is too large. * 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(). + * + * @see f_memory_array_resize() */ #ifndef _di_f_uint8ss_increase_ - extern f_status_t f_uint8ss_increase(const f_number_unsigned_t step, f_uint8ss_t * const uint8ss); + extern f_status_t f_uint8ss_increase(const f_number_unsigned_t step, f_uint8ss_t * const structure); #endif // _di_f_uint8ss_increase_ /** @@ -336,7 +361,7 @@ extern "C" { * * @param amount * A positive number representing how much to increase the size by. - * @param uint8ss + * @param structure * The string uint8ss array to resize. * * @return @@ -346,10 +371,12 @@ extern "C" { * F_array_too_large (with error bit) if the new array length is too large. * 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(). + * + * @see f_memory_array_resize() */ #ifndef _di_f_uint8ss_increase_by_ - extern f_status_t f_uint8ss_increase_by(const f_number_unsigned_t amount, f_uint8ss_t * const uint8ss); + extern f_status_t f_uint8ss_increase_by(const f_number_unsigned_t amount, f_uint8ss_t * const structure); #endif // _di_f_uint8ss_increase_by_ /** @@ -357,7 +384,7 @@ extern "C" { * * @param length * The new size to use. - * @param uint8ss + * @param structure * The string uint8ss array to adjust. * * @return @@ -365,11 +392,12 @@ extern "C" { * * 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() */ #ifndef _di_f_uint8ss_resize_ - extern f_status_t f_uint8ss_resize(const f_number_unsigned_t length, f_uint8ss_t * const uint8ss); + extern f_status_t f_uint8ss_resize(const f_number_unsigned_t length, f_uint8ss_t * const structure); #endif // _di_f_uint8ss_resize_ #ifdef __cplusplus diff --git a/level_0/f_utf/c/utf/dynamic.c b/level_0/f_utf/c/utf/dynamic.c index 7825141..bf63336 100644 --- a/level_0/f_utf/c/utf/dynamic.c +++ b/level_0/f_utf/c/utf/dynamic.c @@ -151,17 +151,17 @@ extern "C" { #endif // _di_level_0_parameter_checking_ if (step && dynamic->used + 1 > dynamic->size) { - f_number_unsigned_t size = dynamic->used + step; + f_number_unsigned_t length = dynamic->used + step; - if (size > F_string_t_size_d) { + if (length > F_string_t_size_d) { if (dynamic->used + 1 > F_string_t_size_d) { return F_status_set_error(F_string_too_large); } - size = F_string_t_size_d; + length = F_string_t_size_d; } - return private_f_utf_string_dynamic_resize(size, dynamic); + return private_f_utf_string_dynamic_resize(length, dynamic); } 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 8de484c..aa7d900 100644 --- a/level_0/f_utf/c/utf/dynamics.c +++ b/level_0/f_utf/c/utf/dynamics.c @@ -84,17 +84,17 @@ extern "C" { if (!step) return F_data_not; if (dynamics->used + 1 > dynamics->size) { - f_number_unsigned_t size = dynamics->used + step; + f_number_unsigned_t length = dynamics->used + step; - if (size > F_number_t_size_unsigned_d) { + if (length > F_number_t_size_unsigned_d) { if (dynamics->used + 1 > F_number_t_size_unsigned_d) { return F_status_set_error(F_array_too_large); } - size = F_number_t_size_unsigned_d; + length = F_number_t_size_unsigned_d; } - return private_f_utf_string_dynamics_resize(size, dynamics); + 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 d086606..ff53e46 100644 --- a/level_0/f_utf/c/utf/dynamicss.c +++ b/level_0/f_utf/c/utf/dynamicss.c @@ -118,17 +118,17 @@ extern "C" { if (!step) return F_data_not; if (dynamicss->used + 1 > dynamicss->size) { - f_number_unsigned_t size = dynamicss->used + step; + f_number_unsigned_t length = dynamicss->used + step; - if (size > F_number_t_size_unsigned_d) { + if (length > F_number_t_size_unsigned_d) { if (dynamicss->used + 1 > F_number_t_size_unsigned_d) { return F_status_set_error(F_array_too_large); } - size = F_number_t_size_unsigned_d; + length = F_number_t_size_unsigned_d; } - return private_f_utf_string_dynamicss_resize(size, dynamicss); + 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 1db192b..ba56853 100644 --- a/level_0/f_utf/c/utf/map_multis.c +++ b/level_0/f_utf/c/utf/map_multis.c @@ -102,17 +102,17 @@ extern "C" { #endif // _di_level_0_parameter_checking_ if (step && map_multis->used + 1 > map_multis->size) { - f_number_unsigned_t size = map_multis->used + step; + f_number_unsigned_t length = map_multis->used + step; - if (size > F_number_t_size_unsigned_d) { + if (length > F_number_t_size_unsigned_d) { if (map_multis->used + 1 > F_number_t_size_unsigned_d) { return F_status_set_error(F_array_too_large); } - size = F_number_t_size_unsigned_d; + length = F_number_t_size_unsigned_d; } - return private_f_utf_string_map_multis_resize(size, map_multis); + 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_multiss.c b/level_0/f_utf/c/utf/map_multiss.c index c757197..59eda3c 100644 --- a/level_0/f_utf/c/utf/map_multiss.c +++ b/level_0/f_utf/c/utf/map_multiss.c @@ -117,17 +117,17 @@ extern "C" { #endif // _di_level_0_parameter_checking_ if (step && map_multiss->used + 1 > map_multiss->size) { - f_number_unsigned_t size = map_multiss->used + step; + f_number_unsigned_t length = map_multiss->used + step; - if (size > F_number_t_size_unsigned_d) { + if (length > F_number_t_size_unsigned_d) { if (map_multiss->used + 1 > F_number_t_size_unsigned_d) { return F_status_set_error(F_array_too_large); } - size = F_number_t_size_unsigned_d; + length = F_number_t_size_unsigned_d; } - return private_f_utf_string_map_multiss_resize(size, map_multiss); + return private_f_utf_string_map_multiss_resize(length, map_multiss); } return F_data_not; diff --git a/level_0/f_utf/c/utf/maps.c b/level_0/f_utf/c/utf/maps.c index dda7f5a..6b493c8 100644 --- a/level_0/f_utf/c/utf/maps.c +++ b/level_0/f_utf/c/utf/maps.c @@ -100,17 +100,17 @@ extern "C" { #endif // _di_level_0_parameter_checking_ if (step && maps->used + 1 > maps->size) { - f_number_unsigned_t size = maps->used + step; + f_number_unsigned_t length = maps->used + step; - if (size > F_number_t_size_unsigned_d) { + if (length > F_number_t_size_unsigned_d) { if (maps->used + 1 > F_number_t_size_unsigned_d) { return F_status_set_error(F_array_too_large); } - size = F_number_t_size_unsigned_d; + length = F_number_t_size_unsigned_d; } - return private_f_utf_string_maps_resize(size, maps); + return private_f_utf_string_maps_resize(length, maps); } return F_data_not; diff --git a/level_0/f_utf/c/utf/mapss.c b/level_0/f_utf/c/utf/mapss.c index a281a0d..c911950 100644 --- a/level_0/f_utf/c/utf/mapss.c +++ b/level_0/f_utf/c/utf/mapss.c @@ -114,17 +114,17 @@ extern "C" { #endif // _di_level_0_parameter_checking_ if (step && mapss->used + 1 > mapss->size) { - f_number_unsigned_t size = mapss->used + step; + f_number_unsigned_t length = mapss->used + step; - if (size > F_number_t_size_unsigned_d) { + if (length > F_number_t_size_unsigned_d) { if (mapss->used + 1 > F_number_t_size_unsigned_d) { return F_status_set_error(F_array_too_large); } - size = F_number_t_size_unsigned_d; + length = F_number_t_size_unsigned_d; } - return private_f_utf_string_mapss_resize(size, mapss); + return private_f_utf_string_mapss_resize(length, mapss); } 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 5b7e190..0121aeb 100644 --- a/level_0/f_utf/c/utf/triples.c +++ b/level_0/f_utf/c/utf/triples.c @@ -133,17 +133,17 @@ extern "C" { #endif // _di_level_0_parameter_checking_ if (step && triples->used + 1 > triples->size) { - f_number_unsigned_t size = triples->used + F_memory_default_allocation_small_d; + f_number_unsigned_t length = triples->used + F_memory_default_allocation_small_d; - if (size > F_number_t_size_unsigned_d) { + if (length > F_number_t_size_unsigned_d) { if (triples->used + 1 > F_number_t_size_unsigned_d) { return F_status_set_error(F_array_too_large); } - size = F_number_t_size_unsigned_d; + length = F_number_t_size_unsigned_d; } - return private_f_utf_string_triples_resize(size, triples); + return private_f_utf_string_triples_resize(length, triples); } return F_data_not; diff --git a/level_0/f_utf/c/utf/tripless.c b/level_0/f_utf/c/utf/tripless.c index b4f37fc..ff4e31b 100644 --- a/level_0/f_utf/c/utf/tripless.c +++ b/level_0/f_utf/c/utf/tripless.c @@ -114,17 +114,17 @@ extern "C" { #endif // _di_level_0_parameter_checking_ if (step && tripless->used + 1 > tripless->size) { - f_number_unsigned_t size = tripless->used + step; + f_number_unsigned_t length = tripless->used + step; - if (size > F_number_t_size_unsigned_d) { + if (length > F_number_t_size_unsigned_d) { if (tripless->used + 1 > F_number_t_size_unsigned_d) { return F_status_set_error(F_array_too_large); } - size = F_number_t_size_unsigned_d; + length = F_number_t_size_unsigned_d; } - return private_f_utf_string_tripless_resize(size, tripless); + return private_f_utf_string_tripless_resize(length, tripless); } return F_data_not; diff --git a/level_3/controller/c/common/private-process.c b/level_3/controller/c/common/private-process.c index cf3b21c..0406a6e 100644 --- a/level_3/controller/c/common/private-process.c +++ b/level_3/controller/c/common/private-process.c @@ -9,17 +9,17 @@ extern "C" { f_status_t controller_pids_increase(controller_pids_t * const pids) { if (pids->used + 1 > pids->size) { - f_number_unsigned_t size = pids->used + controller_common_allocation_small_d; + f_number_unsigned_t length = pids->used + controller_common_allocation_small_d; - if (size > F_number_t_size_unsigned_d) { + if (length > F_number_t_size_unsigned_d) { if (pids->used + 1 > F_number_t_size_unsigned_d) { return F_status_set_error(F_array_too_large); } - size = F_number_t_size_unsigned_d; + length = F_number_t_size_unsigned_d; } - return controller_pids_resize(size, pids); + return controller_pids_resize(length, pids); } return F_data_not; @@ -79,17 +79,17 @@ extern "C" { f_status_t controller_processs_increase(controller_processs_t * const processs) { if (processs->used + 1 > processs->size) { - f_number_unsigned_t size = processs->used + controller_common_allocation_small_d; + f_number_unsigned_t length = processs->used + controller_common_allocation_small_d; - if (size > F_number_t_size_unsigned_d) { + if (length > F_number_t_size_unsigned_d) { if (processs->used + 1 > F_number_t_size_unsigned_d) { return F_status_set_error(F_array_too_large); } - size = F_number_t_size_unsigned_d; + length = F_number_t_size_unsigned_d; } - return controller_processs_resize(size, processs); + return controller_processs_resize(length, processs); } 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 1bc9296..6532bbb 100644 --- a/level_3/controller/c/common/private-rule.c +++ b/level_3/controller/c/common/private-rule.c @@ -133,17 +133,17 @@ extern "C" { f_status_t controller_rule_ons_increase(controller_rule_ons_t * const ons) { if (ons->used + 1 > ons->size) { - f_number_unsigned_t size = ons->used + controller_common_allocation_small_d; + f_number_unsigned_t length = ons->used + controller_common_allocation_small_d; - if (size > F_number_t_size_unsigned_d) { + if (length > F_number_t_size_unsigned_d) { if (ons->used + 1 > F_number_t_size_unsigned_d) { return F_status_set_error(F_array_too_large); } - size = F_number_t_size_unsigned_d; + length = F_number_t_size_unsigned_d; } - return controller_rule_ons_resize(size, ons); + return controller_rule_ons_resize(length, ons); } return F_data_not; @@ -181,17 +181,17 @@ extern "C" { f_status_t controller_rules_increase(controller_rules_t * const rules) { if (rules->used + 1 > rules->size) { - f_number_unsigned_t size = rules->used + controller_common_allocation_small_d; + f_number_unsigned_t length = rules->used + controller_common_allocation_small_d; - if (size > F_number_t_size_unsigned_d) { + if (length > F_number_t_size_unsigned_d) { if (rules->used + 1 > F_number_t_size_unsigned_d) { return F_status_set_error(F_array_too_large); } - size = F_number_t_size_unsigned_d; + length = F_number_t_size_unsigned_d; } - return controller_rules_resize(size, rules); + return controller_rules_resize(length, rules); } return F_data_not;