From: Kevin Day Date: Fri, 25 Feb 2022 04:10:04 +0000 (-0600) Subject: Update: Return F_data_not when amount or size is 0 in memory allocation functions... X-Git-Tag: 0.5.8~11 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=3a625f6eaee5118e829f8184ddd18152600ada3f;p=fll Update: Return F_data_not when amount or size is 0 in memory allocation functions and add missing F_string_tripless_t. Return F_data_not rather than return F_parameter (with error bit set). This allows for more possibilities where a set of data may be calculated without worrying about an error that is not really an error. If you want to allocate nothing, then nothing is allocated (and the same for deallocated). The resize and adjust functions still use a length of 0 as synonymous to deleting the data. The array of an array of F_triple_t is no longer missing. All appropriate allocation functions are defined. --- diff --git a/level_0/f_account/c/private-account.h b/level_0/f_account/c/private-account.h index 2ec37ff..7b9be9e 100644 --- a/level_0/f_account/c/private-account.h +++ b/level_0/f_account/c/private-account.h @@ -32,11 +32,9 @@ extern "C" { * @return * F_none on success. * - * Errors (with error bit) from macro_f_string_dynamic_t_resize(). + * Errors (with error bit) from f_string_dynamic_resize(). * - * @see f_account_by_name() - * @see f_account_by_id() - * @see macro_f_string_dynamic_t_resize() + * @see f_string_dynamic_resize() */ #if !defined(_di_f_account_by_name_) || !defined(_di_f_account_by_id_) extern f_status_t private_f_account_from_passwd(const struct passwd password, const f_array_length_t password_length, f_account_t * const account) F_attribute_visibility_internal_d; diff --git a/level_0/f_fss/c/fss/named.c b/level_0/f_fss/c/fss/named.c index 3070c5e..cf5ee1b 100644 --- a/level_0/f_fss/c/fss/named.c +++ b/level_0/f_fss/c/fss/named.c @@ -18,10 +18,13 @@ extern "C" { #ifndef _di_f_fss_named_decimate_by_ f_status_t f_fss_named_decimate_by(const f_array_length_t amount, f_fss_named_t * const named) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!named) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (named->objects.size - amount > 0) { return private_f_fss_named_adjust(named->objects.size - amount, named); } @@ -33,10 +36,13 @@ extern "C" { #ifndef _di_f_fss_named_decrease_by_ f_status_t f_fss_named_decrease_by(const f_array_length_t amount, f_fss_named_t * const named) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!named) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (named->objects.size - amount > 0) { return private_f_fss_named_resize(named->objects.size - amount, named); } @@ -48,11 +54,10 @@ extern "C" { #ifndef _di_f_fss_named_increase_ f_status_t f_fss_named_increase(const f_array_length_t step, f_fss_named_t * const named) { #ifndef _di_level_0_parameter_checking_ - if (!step) return F_status_set_error(F_parameter); if (!named) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (named->objects.used + 1 > named->objects.size) { + if (step && named->objects.used + 1 > named->objects.size) { f_array_length_t size = named->objects.used + step; if (size > F_array_length_t_size_d) { @@ -73,10 +78,13 @@ extern "C" { #ifndef _di_f_fss_named_increase_by_ f_status_t f_fss_named_increase_by(const f_array_length_t amount, f_fss_named_t * const named) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!named) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (named->objects.used + amount > named->objects.size) { if (named->objects.used + amount > F_array_length_t_size_d) { return F_status_set_error(F_array_too_large); @@ -112,10 +120,13 @@ extern "C" { #ifndef _di_f_fss_nameds_decimate_by_ f_status_t f_fss_nameds_decimate_by(const f_array_length_t amount, f_fss_nameds_t * const nameds) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!nameds) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (nameds->size - amount > 0) { return private_f_fss_nameds_adjust(nameds->size - amount, nameds); } @@ -127,10 +138,13 @@ extern "C" { #ifndef _di_f_fss_nameds_decrease_by_ f_status_t f_fss_nameds_decrease_by(const f_array_length_t amount, f_fss_nameds_t * const nameds) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!nameds) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (nameds->size - amount > 0) { return private_f_fss_nameds_resize(nameds->size - amount, nameds); } @@ -142,11 +156,10 @@ extern "C" { #ifndef _di_f_fss_nameds_increase_ f_status_t f_fss_nameds_increase(const f_array_length_t step, f_fss_nameds_t * const nameds) { #ifndef _di_level_0_parameter_checking_ - if (!step) return F_status_set_error(F_parameter); if (!nameds) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (nameds->used + 1 > nameds->size) { + if (step && nameds->used + 1 > nameds->size) { f_array_length_t size = nameds->used + step; if (size > F_array_length_t_size_d) { @@ -167,10 +180,13 @@ extern "C" { #ifndef _di_f_fss_nameds_increase_by_ f_status_t f_fss_nameds_increase_by(const f_array_length_t amount, f_fss_nameds_t * const nameds) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!nameds) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (nameds->used + amount > nameds->size) { if (nameds->used + amount > F_array_length_t_size_d) { return F_status_set_error(F_array_too_large); diff --git a/level_0/f_fss/c/fss/named.h b/level_0/f_fss/c/fss/named.h index b505175..db5f04d 100644 --- a/level_0/f_fss/c/fss/named.h +++ b/level_0/f_fss/c/fss/named.h @@ -119,6 +119,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. @@ -141,6 +142,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. diff --git a/level_0/f_fss/c/fss/nest.c b/level_0/f_fss/c/fss/nest.c index c760ec7..56e0e0a 100644 --- a/level_0/f_fss/c/fss/nest.c +++ b/level_0/f_fss/c/fss/nest.c @@ -18,10 +18,13 @@ extern "C" { #ifndef _di_f_fss_items_decimate_by_ f_status_t f_fss_items_decimate_by(const f_array_length_t amount, f_fss_items_t * const items) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!items) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (items->size - amount > 0) { return private_f_fss_items_adjust(items->size - amount, items); } @@ -33,10 +36,13 @@ extern "C" { #ifndef _di_f_fss_items_decrease_by_ f_status_t f_fss_items_decrease_by(const f_array_length_t amount, f_fss_items_t * const items) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!items) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (items->size - amount > 0) { return private_f_fss_items_resize(items->size - amount, items); } @@ -48,11 +54,10 @@ extern "C" { #ifndef _di_f_fss_items_increase_ f_status_t f_fss_items_increase(const f_array_length_t step, f_fss_items_t * const items) { #ifndef _di_level_0_parameter_checking_ - if (!step) return F_status_set_error(F_parameter); if (!items) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (items->used + 1 > items->size) { + if (step && items->used + 1 > items->size) { f_array_length_t size = items->used + step; if (size > F_array_length_t_size_d) { @@ -73,10 +78,13 @@ extern "C" { #ifndef _di_f_fss_items_increase_by_ f_status_t f_fss_items_increase_by(const f_array_length_t amount, f_fss_items_t * const items) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!items) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (items->used + amount > items->size) { if (items->used + amount > F_array_length_t_size_d) { return F_status_set_error(F_array_too_large); @@ -112,10 +120,13 @@ extern "C" { #ifndef _di_f_fss_nest_decimate_by_ f_status_t f_fss_nest_decimate_by(const f_array_length_t amount, f_fss_nest_t * const nest) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!nest) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (nest->size - amount > 0) { return private_f_fss_nest_adjust(nest->size - amount, nest); } @@ -127,10 +138,13 @@ extern "C" { #ifndef _di_f_fss_nest_decrease_by_ f_status_t f_fss_nest_decrease_by(const f_array_length_t amount, f_fss_nest_t * const nest) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!nest) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (nest->size - amount > 0) { return private_f_fss_nest_resize(nest->size - amount, nest); } @@ -142,11 +156,10 @@ extern "C" { #ifndef _di_f_fss_nest_increase_ f_status_t f_fss_nest_increase(const f_array_length_t step, f_fss_nest_t * const nest) { #ifndef _di_level_0_parameter_checking_ - if (!step) return F_status_set_error(F_parameter); if (!nest) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (nest->used + 1 > nest->size) { + if (step && nest->used + 1 > nest->size) { f_array_length_t size = nest->used + step; if (size > F_array_length_t_size_d) { @@ -167,10 +180,13 @@ extern "C" { #ifndef _di_f_fss_nest_increase_by_ f_status_t f_fss_nest_increase_by(const f_array_length_t amount, f_fss_nest_t * const nest) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!nest) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (nest->used + amount > nest->size) { if (nest->used + amount > F_array_length_t_size_d) { return F_status_set_error(F_array_too_large); @@ -206,10 +222,13 @@ extern "C" { #ifndef _di_f_fss_nests_decimate_by_ f_status_t f_fss_nests_decimate_by(const f_array_length_t amount, f_fss_nests_t * const nests) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!nests) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (nests->size - amount > 0) { return private_f_fss_nests_adjust(nests->size - amount, nests); } @@ -221,7 +240,6 @@ extern "C" { #ifndef _di_f_fss_nests_decrease_by_ f_status_t f_fss_nests_decrease_by(const f_array_length_t amount, f_fss_nests_t * const nests) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!nests) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -236,11 +254,10 @@ extern "C" { #ifndef _di_f_fss_nests_increase_ f_status_t f_fss_nests_increase(const f_array_length_t step, f_fss_nests_t * const nests) { #ifndef _di_level_0_parameter_checking_ - if (!step) return F_status_set_error(F_parameter); if (!nests) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (nests->used + 1 > nests->size) { + if (step && nests->used + 1 > nests->size) { f_array_length_t size = nests->used + step; if (size > F_array_length_t_size_d) { @@ -261,10 +278,13 @@ extern "C" { #ifndef _di_f_fss_nests_increase_by_ f_status_t f_fss_nests_increase_by(const f_array_length_t amount, f_fss_nests_t * const nests) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!nests) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (nests->used + amount > nests->size) { if (nests->used + amount > F_array_length_t_size_d) { return F_status_set_error(F_array_too_large); diff --git a/level_0/f_fss/c/fss/nest.h b/level_0/f_fss/c/fss/nest.h index c89c857..b6b48e3 100644 --- a/level_0/f_fss/c/fss/nest.h +++ b/level_0/f_fss/c/fss/nest.h @@ -209,6 +209,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. @@ -337,6 +338,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. diff --git a/level_0/f_fss/c/fss/set.c b/level_0/f_fss/c/fss/set.c index 09f524d..65ace05 100644 --- a/level_0/f_fss/c/fss/set.c +++ b/level_0/f_fss/c/fss/set.c @@ -18,10 +18,13 @@ extern "C" { #ifndef _di_f_fss_set_decimate_by_ f_status_t f_fss_set_decimate_by(const f_array_length_t amount, f_fss_set_t * const set) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!set) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (set->objects.size - amount > 0) { return private_f_fss_set_adjust(set->objects.size - amount, set); } @@ -33,10 +36,13 @@ extern "C" { #ifndef _di_f_fss_set_decrease_by_ f_status_t f_fss_set_decrease_by(const f_array_length_t amount, f_fss_set_t * const set) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!set) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (set->objects.size - amount > 0) { return private_f_fss_set_resize(set->objects.size - amount, set); } @@ -48,11 +54,10 @@ extern "C" { #ifndef _di_f_fss_set_increase_ f_status_t f_fss_set_increase(const f_array_length_t step, f_fss_set_t * const set) { #ifndef _di_level_0_parameter_checking_ - if (!step) return F_status_set_error(F_parameter); if (!set) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (set->objects.used + 1 > set->objects.size) { + if (step && set->objects.used + 1 > set->objects.size) { f_array_length_t size = set->objects.used + step; if (size > F_array_length_t_size_d) { @@ -73,10 +78,13 @@ extern "C" { #ifndef _di_f_fss_set_increase_by_ f_status_t f_fss_set_increase_by(const f_array_length_t amount, f_fss_set_t * const set) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!set) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (set->objects.used + amount > set->objects.size) { if (set->objects.used + amount > F_array_length_t_size_d) { return F_status_set_error(F_array_too_large); @@ -112,10 +120,13 @@ extern "C" { #ifndef _di_f_fss_set_quote_decimate_by_ f_status_t f_fss_set_quote_decimate_by(const f_array_length_t amount, f_fss_set_quote_t * const set_quote) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!set_quote) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (set_quote->objects.size - amount > 0) { return private_f_fss_set_quote_adjust(set_quote->objects.size - amount, set_quote); } @@ -127,10 +138,13 @@ extern "C" { #ifndef _di_f_fss_set_quote_decrease_by_ f_status_t f_fss_set_quote_decrease_by(const f_array_length_t amount, f_fss_set_quote_t * const set_quote) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!set_quote) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (set_quote->objects.size - amount > 0) { return private_f_fss_set_quote_resize(set_quote->objects.size - amount, set_quote); } @@ -142,11 +156,10 @@ extern "C" { #ifndef _di_f_fss_set_quote_increase_ f_status_t f_fss_set_quote_increase(const f_array_length_t step, f_fss_set_quote_t * const set_quote) { #ifndef _di_level_0_parameter_checking_ - if (!step) return F_status_set_error(F_parameter); if (!set_quote) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (set_quote->objects.used + 1 > set_quote->objects.size) { + if (step && set_quote->objects.used + 1 > set_quote->objects.size) { f_array_length_t size = set_quote->objects.used + step; if (size > F_array_length_t_size_d) { @@ -167,10 +180,13 @@ extern "C" { #ifndef _di_f_fss_set_quote_increase_by_ f_status_t f_fss_set_quote_increase_by(const f_array_length_t amount, f_fss_set_quote_t * const set_quote) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!set_quote) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (set_quote->objects.used + amount > set_quote->objects.size) { if (set_quote->objects.used + amount > F_array_length_t_size_d) { return F_status_set_error(F_array_too_large); @@ -206,10 +222,13 @@ extern "C" { #ifndef _di_f_fss_set_quotes_decimate_by_ f_status_t f_fss_set_quotes_decimate_by(const f_array_length_t amount, f_fss_set_quotes_t * const set_quotes) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!set_quotes) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (set_quotes->size - amount > 0) { return private_f_fss_set_quotes_adjust(set_quotes->size - amount, set_quotes); } @@ -221,10 +240,13 @@ extern "C" { #ifndef _di_f_fss_set_quotes_decrease_by_ f_status_t f_fss_set_quotes_decrease_by(const f_array_length_t amount, f_fss_set_quotes_t * const set_quotes) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!set_quotes) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (set_quotes->size - amount > 0) { return private_f_fss_set_quotes_resize(set_quotes->size - amount, set_quotes); } @@ -236,11 +258,10 @@ extern "C" { #ifndef _di_f_fss_set_quotes_increase_ f_status_t f_fss_set_quotes_increase(const f_array_length_t step, f_fss_set_quotes_t * const set_quotes) { #ifndef _di_level_0_parameter_checking_ - if (!step) return F_status_set_error(F_parameter); if (!set_quotes) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (set_quotes->used + 1 > set_quotes->size) { + if (step && set_quotes->used + 1 > set_quotes->size) { f_array_length_t size = set_quotes->used + step; if (size > F_array_length_t_size_d) { @@ -261,10 +282,13 @@ extern "C" { #ifndef _di_f_fss_set_quotes_increase_by_ f_status_t f_fss_set_quotes_increase_by(const f_array_length_t amount, f_fss_set_quotes_t * const set_quotes) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!set_quotes) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (set_quotes->used + amount > set_quotes->size) { if (set_quotes->used + amount > F_array_length_t_size_d) { return F_status_set_error(F_array_too_large); @@ -300,10 +324,13 @@ extern "C" { #ifndef _di_f_fss_sets_decimate_by_ f_status_t f_fss_sets_decimate_by(const f_array_length_t amount, f_fss_sets_t * const sets) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!sets) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (sets->size - amount > 0) { return private_f_fss_sets_adjust(sets->size - amount, sets); } @@ -315,10 +342,13 @@ extern "C" { #ifndef _di_f_fss_sets_decrease_by_ f_status_t f_fss_sets_decrease_by(const f_array_length_t amount, f_fss_sets_t * const sets) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!sets) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (sets->size - amount > 0) { return private_f_fss_sets_resize(sets->size - amount, sets); } @@ -330,11 +360,10 @@ extern "C" { #ifndef _di_f_fss_sets_increase_ f_status_t f_fss_sets_increase(const f_array_length_t step, f_fss_sets_t * const sets) { #ifndef _di_level_0_parameter_checking_ - if (!step) return F_status_set_error(F_parameter); if (!sets) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (sets->used + 1 > sets->size) { + if (step && sets->used + 1 > sets->size) { f_array_length_t size = sets->used + step; if (size > F_array_length_t_size_d) { @@ -355,10 +384,13 @@ extern "C" { #ifndef _di_f_fss_sets_increase_by_ f_status_t f_fss_sets_increase_by(const f_array_length_t amount, f_fss_sets_t * const sets) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!sets) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (sets->used + amount > sets->size) { if (sets->used + amount > F_array_length_t_size_d) { return F_status_set_error(F_array_too_large); diff --git a/level_0/f_fss/c/fss/set.h b/level_0/f_fss/c/fss/set.h index 7533165..f67dd4e 100644 --- a/level_0/f_fss/c/fss/set.h +++ b/level_0/f_fss/c/fss/set.h @@ -183,6 +183,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. @@ -311,6 +312,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. @@ -439,6 +441,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. @@ -567,6 +570,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. diff --git a/level_0/f_iki/c/iki/common.c b/level_0/f_iki/c/iki/common.c index 2bfc0cc..6fc4869 100644 --- a/level_0/f_iki/c/iki/common.c +++ b/level_0/f_iki/c/iki/common.c @@ -103,6 +103,11 @@ extern "C" { for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { + destination->array[destination->used].content.used = 0; + destination->array[destination->used].delimits.used = 0; + destination->array[destination->used].variable.used = 0; + destination->array[destination->used].vocabulary.used = 0; + status = f_string_ranges_append(source.array[i].content, &destination->array[destination->used].content); if (F_status_is_error(status)) return status; @@ -123,10 +128,13 @@ extern "C" { #ifndef _di_f_iki_datas_decimate_by_ f_status_t f_iki_datas_decimate_by(const f_array_length_t amount, f_iki_datas_t *datas) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!datas) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (datas->size - amount > 0) { return private_f_iki_datas_adjust(datas->size - amount, datas); } @@ -138,10 +146,13 @@ extern "C" { #ifndef _di_f_iki_datas_decrease_by_ f_status_t f_iki_datas_decrease_by(const f_array_length_t amount, f_iki_datas_t *datas) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!datas) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (datas->size - amount > 0) { return private_f_iki_datas_resize(datas->size - amount, datas); } @@ -153,11 +164,10 @@ extern "C" { #ifndef _di_f_iki_datas_increase_ f_status_t f_iki_datas_increase(const f_array_length_t step, f_iki_datas_t *datas) { #ifndef _di_level_0_parameter_checking_ - if (!step) return F_status_set_error(F_parameter); if (!datas) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (datas->used + 1 > datas->size) { + if (step && datas->used + 1 > datas->size) { f_array_length_t size = datas->used + step; if (size > F_array_length_t_size_d) { @@ -178,10 +188,13 @@ extern "C" { #ifndef _di_f_iki_datas_increase_by_ f_status_t f_iki_datas_increase_by(const f_array_length_t amount, f_iki_datas_t *datas) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!datas) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (datas->used + amount > datas->size) { if (datas->used + amount > F_array_length_t_size_d) { return F_status_set_error(F_array_too_large); diff --git a/level_0/f_iki/c/iki/common.h b/level_0/f_iki/c/iki/common.h index 387f00b..fb564ff 100644 --- a/level_0/f_iki/c/iki/common.h +++ b/level_0/f_iki/c/iki/common.h @@ -424,6 +424,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_parameter (with error bit) if a parameter is invalid. * @@ -447,6 +448,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_parameter (with error bit) if a parameter is invalid. * diff --git a/level_0/f_string/c/private-string.c b/level_0/f_string/c/private-string.c index 28c4132..cb17f2e 100644 --- a/level_0/f_string/c/private-string.c +++ b/level_0/f_string/c/private-string.c @@ -950,6 +950,64 @@ extern "C" { } #endif // !defined(_di_f_string_triples_decrease_) || !defined(_di_f_string_triples_decrease_by_) || !defined(_di_f_string_triples_increase_) || !defined(_di_f_string_triples_increase_by_) || !defined(_di_f_string_triples_terminate_) || !defined(_di_f_string_triples_terminate_after_) +#if !defined(_di_f_string_tripless_adjust_) || !defined(_di_f_string_tripless_decimate_by_) + f_status_t private_f_string_tripless_adjust(const f_array_length_t length, f_string_tripless_t * const tripless) { + + if (tripless->used + length > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + f_status_t status = F_none; + + for (f_array_length_t i = length; i < tripless->size; ++i) { + + status = private_f_string_triples_adjust(0, &tripless->array[i]); + if (F_status_is_error(status)) return status; + } // for + + status = f_memory_adjust(tripless->size, length, sizeof(f_string_triples_t), (void **) & tripless->array); + + if (F_status_is_error_not(status)) { + tripless->size = length; + + if (tripless->used > tripless->size) { + tripless->used = length; + } + } + + return status; + } +#endif // !defined(_di_f_string_tripless_adjust_) || !defined(_di_f_string_tripless_decimate_by_) + +#if !defined(_di_f_string_tripless_decrease_) || !defined(_di_f_string_tripless_decrease_by_) || !defined(_di_f_string_tripless_increase_) || !defined(_di_f_string_tripless_increase_by_) || !defined(_di_f_string_tripless_terminate_) || !defined(_di_f_string_tripless_terminate_after_) + f_status_t private_f_string_tripless_resize(const f_array_length_t length, f_string_tripless_t * const tripless) { + + if (tripless->used + length > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + f_status_t status = F_none; + + for (f_array_length_t i = length; i < tripless->size; ++i) { + + status = private_f_string_triples_resize(0, &tripless->array[i]); + if (F_status_is_error(status)) return status; + } // for + + status = f_memory_resize(tripless->size, length, sizeof(f_string_triples_t), (void **) & tripless->array); + + if (F_status_is_error_not(status)) { + tripless->size = length; + + if (tripless->used > tripless->size) { + tripless->used = length; + } + } + + return status; + } +#endif // !defined(_di_f_string_tripless_decrease_) || !defined(_di_f_string_tripless_decrease_by_) || !defined(_di_f_string_tripless_increase_) || !defined(_di_f_string_tripless_increase_by_) || !defined(_di_f_string_tripless_terminate_) || !defined(_di_f_string_tripless_terminate_after_) + #ifdef __cplusplus } // extern "C" #endif diff --git a/level_0/f_string/c/private-string.h b/level_0/f_string/c/private-string.h index 607f75f..0b13cab 100644 --- a/level_0/f_string/c/private-string.h +++ b/level_0/f_string/c/private-string.h @@ -968,6 +968,59 @@ extern "C" { extern f_status_t private_f_string_triples_resize(const f_array_length_t length, f_string_triples_t * const triples) F_attribute_visibility_internal_d; #endif // !defined(_di_f_string_triples_decrease_by_) || !defined(_di_f_string_triples_increase_) || !defined(_di_f_string_triples_increase_by_) || !defined(_di_f_string_triples_terminate_) || !defined(_di_f_string_triples_terminate_after_) +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param tripless + * The tripless to adjust. + * + * @return + * F_none on success. + * + * F_array_too_large (with error bit) if the combined array is too large. + * + * Errors (with error bit) from: f_memory_adjust(). + * + * @see f_memory_adjust() + * @see f_string_tripless_adjust() + * @see f_string_tripless_decimate_by() + */ +#if !defined(_di_f_string_tripless_adjust_) || !defined(_di_f_string_tripless_decimate_by_) + extern f_status_t private_f_string_tripless_adjust(const f_array_length_t length, f_string_tripless_t * const tripless) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_string_tripless_adjust_) || !defined(_di_f_string_tripless_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 tripless + * The tripless to resize. + * + * @return + * F_none on success. + * + * F_array_too_large (with error bit) if the combined array is too large. + * + * Errors (with error bit) from: f_memory_resize(). + * + * @see f_memory_resize() + * @see f_string_tripless_decrease_by() + * @see f_string_tripless_increase() + * @see f_string_tripless_increase_by() + * @see f_string_tripless_terminate() + * @see f_string_tripless_terminate_after() + */ +#if !defined(_di_f_string_tripless_decrease_by_) || !defined(_di_f_string_tripless_increase_) || !defined(_di_f_string_tripless_increase_by_) || !defined(_di_f_string_tripless_terminate_) || !defined(_di_f_string_tripless_terminate_after_) + extern f_status_t private_f_string_tripless_resize(const f_array_length_t length, f_string_tripless_t * const tripless) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_string_tripless_decrease_by_) || !defined(_di_f_string_tripless_increase_) || !defined(_di_f_string_tripless_increase_by_) || !defined(_di_f_string_tripless_terminate_) || !defined(_di_f_string_tripless_terminate_after_) + #ifdef __cplusplus } // extern "C" #endif diff --git a/level_0/f_string/c/string/dynamic.c b/level_0/f_string/c/string/dynamic.c index c0ed0bb..2a1eed1 100644 --- a/level_0/f_string/c/string/dynamic.c +++ b/level_0/f_string/c/string/dynamic.c @@ -132,10 +132,13 @@ extern "C" { #ifndef _di_f_string_dynamic_decimate_by_ f_status_t f_string_dynamic_decimate_by(const f_array_length_t amount, f_string_dynamic_t * const dynamic) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!dynamic) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (dynamic->size - amount > 0) { return private_f_string_dynamic_adjust(dynamic->size - amount, dynamic); } @@ -147,10 +150,13 @@ extern "C" { #ifndef _di_f_string_dynamic_decrease_by_ f_status_t f_string_dynamic_decrease_by(const f_array_length_t amount, f_string_dynamic_t * const dynamic) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!dynamic) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (dynamic->size - amount > 0) { return private_f_string_dynamic_resize(dynamic->size - amount, dynamic); } @@ -162,11 +168,10 @@ extern "C" { #ifndef _di_f_string_dynamic_increase_ f_status_t f_string_dynamic_increase(const f_array_length_t step, f_string_dynamic_t * const dynamic) { #ifndef _di_level_0_parameter_checking_ - if (!step) return F_status_set_error(F_parameter); if (!dynamic) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (dynamic->used + 1 > dynamic->size) { + if (step && dynamic->used + 1 > dynamic->size) { f_array_length_t size = dynamic->used + step; if (size > F_string_t_size_d) { @@ -190,6 +195,10 @@ extern "C" { if (!dynamic) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + return private_f_string_dynamic_increase_by(amount, dynamic); } #endif // _di_f_string_dynamic_increase_by_ @@ -908,10 +917,13 @@ extern "C" { #ifndef _di_f_string_dynamics_decimate_by_ f_status_t f_string_dynamics_decimate_by(const f_array_length_t amount, f_string_dynamics_t * const dynamics) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!dynamics) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (dynamics->size - amount > 0) { return private_f_string_dynamics_adjust(dynamics->size - amount, dynamics); } @@ -923,10 +935,13 @@ extern "C" { #ifndef _di_f_string_dynamics_decrease_by_ f_status_t f_string_dynamics_decrease_by(const f_array_length_t amount, f_string_dynamics_t * const dynamics) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!dynamics) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (dynamics->size - amount > 0) { return private_f_string_dynamics_resize(dynamics->size - amount, dynamics); } @@ -938,10 +953,13 @@ extern "C" { #ifndef _di_f_string_dynamics_increase_ f_status_t f_string_dynamics_increase(const f_array_length_t step, f_string_dynamics_t * const dynamics) { #ifndef _di_level_0_parameter_checking_ - if (!step) return F_status_set_error(F_parameter); if (!dynamics) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!step) { + return F_data_not; + } + if (dynamics->used + 1 > dynamics->size) { f_array_length_t size = dynamics->used + step; @@ -1015,10 +1033,13 @@ extern "C" { #ifndef _di_f_string_dynamicss_decimate_by_ f_status_t f_string_dynamicss_decimate_by(const f_array_length_t amount, f_string_dynamicss_t * const dynamicss) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!dynamicss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (dynamicss->size - amount > 0) { return private_f_string_dynamicss_adjust(dynamicss->size - amount, dynamicss); } @@ -1030,10 +1051,13 @@ extern "C" { #ifndef _di_f_string_dynamicss_decrease_by_ f_status_t f_string_dynamicss_decrease_by(const f_array_length_t amount, f_string_dynamicss_t * const dynamicss) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!dynamicss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (dynamicss->size - amount > 0) { return private_f_string_dynamicss_resize(dynamicss->size - amount, dynamicss); } @@ -1045,10 +1069,13 @@ extern "C" { #ifndef _di_f_string_dynamicss_increase_ f_status_t f_string_dynamicss_increase(const f_array_length_t step, f_string_dynamicss_t * const dynamicss) { #ifndef _di_level_0_parameter_checking_ - if (!step) return F_status_set_error(F_parameter); if (!dynamicss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!step) { + return F_data_not; + } + if (dynamicss->used + 1 > dynamicss->size) { f_array_length_t size = dynamicss->used + step; @@ -1073,6 +1100,10 @@ extern "C" { if (!dynamicss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (dynamicss->used + amount > dynamicss->size) { if (dynamicss->used + amount > F_array_length_t_size_d) { return F_status_set_error(F_array_too_large); diff --git a/level_0/f_string/c/string/dynamic.h b/level_0/f_string/c/string/dynamic.h index ffd5097..41e0efb 100644 --- a/level_0/f_string/c/string/dynamic.h +++ b/level_0/f_string/c/string/dynamic.h @@ -219,6 +219,32 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. + * + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_string_dynamic_decimate_by_ + extern f_status_t f_string_dynamic_decimate_by(const f_array_length_t amount, f_string_dynamic_t * const dynamic); +#endif // _di_f_string_dynamic_decimate_by_ + +/** + * Resize the dynamic string to a smaller size. + * + * This will resize making the string smaller based on (size - given length). + * If the given length is too small, then the resize will fail. + * This will not shrink the size to less than 0. + * + * @param amount + * A positive number representing how much to decrease the size by. + * @param dynamic + * The string to resize. + * + * @return + * F_none on success. + * F_data_not if amount is 0. * * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if the combined string is too large. @@ -244,7 +270,7 @@ extern "C" { * * @return * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + 1 <= size). + * F_data_not on success, but there is no reason to increase size (used + 1 <= size) (or step is 0). * * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if the combined string is too large. @@ -1009,7 +1035,7 @@ extern "C" { * * @return * F_none on success. - * F_data_not on success, but there is no reason to increase size (size == 0). + * F_data_not on success, but there is no reason to increase size (size == 0) (or amount is 0). * * F_parameter (with error bit) if a parameter is invalid. * @@ -1033,7 +1059,7 @@ extern "C" { * * @return * F_none on success. - * F_data_not on success, but there is no reason to increase size (size == 0). + * F_data_not on success, but there is no reason to increase size (size == 0) (or amount is 0). * * F_parameter (with error bit) if a parameter is invalid. * @@ -1166,7 +1192,7 @@ extern "C" { * * @return * F_none on success. - * F_data_not on success, but there is no reason to increase size (size == 0). + * F_data_not on success, but there is no reason to increase size (size == 0) (or amount is 0). * * F_parameter (with error bit) if a parameter is invalid. * @@ -1190,7 +1216,7 @@ extern "C" { * * @return * F_none on success. - * F_data_not on success, but there is no reason to increase size (size == 0). + * F_data_not on success, but there is no reason to increase size (size == 0) (or amount is 0). * * F_parameter (with error bit) if a parameter is invalid. * diff --git a/level_0/f_string/c/string/map.c b/level_0/f_string/c/string/map.c index 8e9eae3..94d0be9 100644 --- a/level_0/f_string/c/string/map.c +++ b/level_0/f_string/c/string/map.c @@ -51,10 +51,13 @@ extern "C" { #ifndef _di_f_string_map_multis_decimate_by_ f_status_t f_string_map_multis_decimate_by(const f_array_length_t amount, f_string_map_multis_t * const map_multis) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!map_multis) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (map_multis->size - amount > 0) { return private_f_string_map_multis_adjust(map_multis->size - amount, map_multis); } @@ -66,10 +69,13 @@ extern "C" { #ifndef _di_f_string_map_multis_decrease_by_ f_status_t f_string_map_multis_decrease_by(const f_array_length_t amount, f_string_map_multis_t * const map_multis) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!map_multis) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (map_multis->size - amount > 0) { return private_f_string_map_multis_resize(map_multis->size - amount, map_multis); } @@ -81,11 +87,10 @@ extern "C" { #ifndef _di_f_string_map_multis_increase_ f_status_t f_string_map_multis_increase(const f_array_length_t step, f_string_map_multis_t * const map_multis) { #ifndef _di_level_0_parameter_checking_ - if (!step) return F_status_set_error(F_parameter); if (!map_multis) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (map_multis->used + 1 > map_multis->size) { + if (step && map_multis->used + 1 > map_multis->size) { f_array_length_t size = map_multis->used + step; if (size > F_array_length_t_size_d) { @@ -106,10 +111,13 @@ extern "C" { #ifndef _di_f_string_map_multis_increase_by_ f_status_t f_string_map_multis_increase_by(const f_array_length_t amount, f_string_map_multis_t * const map_multis) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!map_multis) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (map_multis->used + amount > map_multis->size) { if (map_multis->used + amount > F_array_length_t_size_d) { return F_status_set_error(F_array_too_large); @@ -172,10 +180,13 @@ extern "C" { #ifndef _di_f_string_map_multiss_decimate_by_ f_status_t f_string_map_multiss_decimate_by(const f_array_length_t amount, f_string_map_multiss_t * const map_multiss) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!map_multiss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (map_multiss->size - amount > 0) { return private_f_string_map_multiss_adjust(map_multiss->size - amount, map_multiss); } @@ -187,10 +198,13 @@ extern "C" { #ifndef _di_f_string_map_multiss_decrease_by_ f_status_t f_string_map_multiss_decrease_by(const f_array_length_t amount, f_string_map_multiss_t * const map_multiss) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!map_multiss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (map_multiss->size - amount > 0) { return private_f_string_map_multiss_resize(map_multiss->size - amount, map_multiss); } @@ -202,11 +216,10 @@ extern "C" { #ifndef _di_f_string_map_multiss_increase_ f_status_t f_string_map_multiss_increase(const f_array_length_t step, f_string_map_multiss_t * const map_multiss) { #ifndef _di_level_0_parameter_checking_ - if (!step) return F_status_set_error(F_parameter); if (!map_multiss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (map_multiss->used + 1 > map_multiss->size) { + if (step && map_multiss->used + 1 > map_multiss->size) { f_array_length_t size = map_multiss->used + step; if (size > F_array_length_t_size_d) { @@ -227,10 +240,13 @@ extern "C" { #ifndef _di_f_string_map_multiss_increase_by_ f_status_t f_string_map_multiss_increase_by(const f_array_length_t amount, f_string_map_multiss_t * const map_multiss) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!map_multiss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (map_multiss->used + amount > map_multiss->size) { if (map_multiss->used + amount > F_array_length_t_size_d) { return F_status_set_error(F_array_too_large); @@ -278,10 +294,13 @@ extern "C" { #ifndef _di_f_string_maps_decimate_by_ f_status_t f_string_maps_decimate_by(const f_array_length_t amount, f_string_maps_t * const maps) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!maps) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (maps->size - amount > 0) { return private_f_string_maps_adjust(maps->size - amount, maps); } @@ -293,10 +312,13 @@ extern "C" { #ifndef _di_f_string_maps_decrease_by_ f_status_t f_string_maps_decrease_by(const f_array_length_t amount, f_string_maps_t * const maps) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!maps) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (maps->size - amount > 0) { return private_f_string_maps_resize(maps->size - amount, maps); } @@ -308,11 +330,10 @@ extern "C" { #ifndef _di_f_string_maps_increase_ f_status_t f_string_maps_increase(const f_array_length_t step, f_string_maps_t * const maps) { #ifndef _di_level_0_parameter_checking_ - if (!step) return F_status_set_error(F_parameter); if (!maps) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (maps->used + 1 > maps->size) { + if (step && maps->used + 1 > maps->size) { f_array_length_t size = maps->used + step; if (size > F_array_length_t_size_d) { @@ -333,10 +354,13 @@ extern "C" { #ifndef _di_f_string_maps_increase_by_ f_status_t f_string_maps_increase_by(const f_array_length_t amount, f_string_maps_t * const maps) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!maps) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (maps->used + amount > maps->size) { if (maps->used + amount > F_array_length_t_size_d) { return F_status_set_error(F_array_too_large); @@ -401,10 +425,13 @@ extern "C" { #ifndef _di_f_string_mapss_decimate_by_ f_status_t f_string_mapss_decimate_by(const f_array_length_t amount, f_string_mapss_t * const mapss) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!mapss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (mapss->size - amount > 0) { return private_f_string_mapss_adjust(mapss->size - amount, mapss); } @@ -416,10 +443,13 @@ extern "C" { #ifndef _di_f_string_mapss_decrease_by_ f_status_t f_string_mapss_decrease_by(const f_array_length_t amount, f_string_mapss_t * const mapss) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!mapss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (mapss->size - amount > 0) { return private_f_string_mapss_resize(mapss->size - amount, mapss); } @@ -431,11 +461,10 @@ extern "C" { #ifndef _di_f_string_mapss_increase_ f_status_t f_string_mapss_increase(const f_array_length_t step, f_string_mapss_t * const mapss) { #ifndef _di_level_0_parameter_checking_ - if (!step) return F_status_set_error(F_parameter); if (!mapss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (mapss->used + 1 > mapss->size) { + if (step && mapss->used + 1 > mapss->size) { f_array_length_t size = mapss->used + step; if (size > F_array_length_t_size_d) { @@ -456,10 +485,13 @@ extern "C" { #ifndef _di_f_string_mapss_increase_by_ f_status_t f_string_mapss_increase_by(const f_array_length_t amount, f_string_mapss_t * const mapss) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!mapss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (mapss->used + amount > mapss->size) { if (mapss->used + amount > F_array_length_t_size_d) { return F_status_set_error(F_array_too_large); diff --git a/level_0/f_string/c/string/map.h b/level_0/f_string/c/string/map.h index 452dd6b..8e814a0 100644 --- a/level_0/f_string/c/string/map.h +++ b/level_0/f_string/c/string/map.h @@ -248,6 +248,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_parameter (with error bit) if a parameter is invalid. * @@ -403,6 +404,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_parameter (with error bit) if a parameter is invalid. * @@ -558,6 +560,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_parameter (with error bit) if a parameter is invalid. * @@ -581,6 +584,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_parameter (with error bit) if a parameter is invalid. * @@ -604,7 +608,7 @@ extern "C" { * * @return * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + 1 <= size). + * F_data_not on success, but there is no reason to increase size (used + 1 <= size) (or step is 0). * * 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. diff --git a/level_0/f_string/c/string/quantity.c b/level_0/f_string/c/string/quantity.c index 573a6d8..a192300 100644 --- a/level_0/f_string/c/string/quantity.c +++ b/level_0/f_string/c/string/quantity.c @@ -45,10 +45,13 @@ extern "C" { #ifndef _di_f_string_quantitys_decimate_by_ f_status_t f_string_quantitys_decimate_by(const f_array_length_t amount, f_string_quantitys_t * const quantitys) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!quantitys) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (quantitys->size - amount > 0) { return private_f_string_quantitys_adjust(quantitys->size - amount, quantitys); } @@ -60,10 +63,13 @@ extern "C" { #ifndef _di_f_string_quantitys_decrease_by_ f_status_t f_string_quantitys_decrease_by(const f_array_length_t amount, f_string_quantitys_t * const quantitys) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!quantitys) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (quantitys->size - amount > 0) { return private_f_string_quantitys_resize(quantitys->size - amount, quantitys); } @@ -75,11 +81,10 @@ extern "C" { #ifndef _di_f_string_quantitys_increase_ f_status_t f_string_quantitys_increase(const f_array_length_t step, f_string_quantitys_t * const quantitys) { #ifndef _di_level_0_parameter_checking_ - if (!step) return F_status_set_error(F_parameter); if (!quantitys) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (quantitys->used + 1 > quantitys->size) { + if (step && quantitys->used + 1 > quantitys->size) { f_array_length_t size = quantitys->used + step; if (size > F_array_length_t_size_d) { @@ -100,10 +105,13 @@ extern "C" { #ifndef _di_f_string_quantitys_increase_by_ f_status_t f_string_quantitys_increase_by(const f_array_length_t amount, f_string_quantitys_t * const quantitys) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!quantitys) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (quantitys->used + amount > quantitys->size) { if (quantitys->used + amount > F_array_length_t_size_d) { return F_status_set_error(F_array_too_large); @@ -139,10 +147,13 @@ extern "C" { #ifndef _di_f_string_quantityss_decimate_by_ f_status_t f_string_quantityss_decimate_by(const f_array_length_t amount, f_string_quantityss_t * const quantityss) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!quantityss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (quantityss->size - amount > 0) { return private_f_string_quantityss_adjust(quantityss->size - amount, quantityss); } @@ -154,10 +165,13 @@ extern "C" { #ifndef _di_f_string_quantityss_decrease_by_ f_status_t f_string_quantityss_decrease_by(const f_array_length_t amount, f_string_quantityss_t * const quantityss) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!quantityss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (quantityss->size - amount > 0) { return private_f_string_quantityss_resize(quantityss->size - amount, quantityss); } @@ -169,11 +183,10 @@ extern "C" { #ifndef _di_f_string_quantityss_increase_ f_status_t f_string_quantityss_increase(const f_array_length_t step, f_string_quantityss_t * const quantityss) { #ifndef _di_level_0_parameter_checking_ - if (!step) return F_status_set_error(F_parameter); if (!quantityss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (quantityss->used + 1 > quantityss->size) { + if (step && quantityss->used + 1 > quantityss->size) { f_array_length_t size = quantityss->used + step; if (size > F_array_length_t_size_d) { @@ -194,10 +207,13 @@ extern "C" { #ifndef _di_f_string_quantityss_increase_by_ f_status_t f_string_quantityss_increase_by(const f_array_length_t amount, f_string_quantityss_t * const quantityss) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!quantityss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (quantityss->used + amount > quantityss->size) { if (quantityss->used + amount > F_array_length_t_size_d) { return F_status_set_error(F_array_too_large); diff --git a/level_0/f_string/c/string/quantity.h b/level_0/f_string/c/string/quantity.h index 94346d0..8d36d77 100644 --- a/level_0/f_string/c/string/quantity.h +++ b/level_0/f_string/c/string/quantity.h @@ -152,6 +152,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_parameter (with error bit) if a parameter is invalid. * @@ -284,6 +285,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_parameter (with error bit) if a parameter is invalid. * diff --git a/level_0/f_string/c/string/range.c b/level_0/f_string/c/string/range.c index 79aa751..8daf267 100644 --- a/level_0/f_string/c/string/range.c +++ b/level_0/f_string/c/string/range.c @@ -45,10 +45,13 @@ extern "C" { #ifndef _di_f_string_ranges_decimate_by_ f_status_t f_string_ranges_decimate_by(const f_array_length_t amount, f_string_ranges_t * const ranges) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!ranges) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (ranges->size - amount > 0) { return private_f_string_ranges_adjust(ranges->size - amount, ranges); } @@ -60,10 +63,13 @@ extern "C" { #ifndef _di_f_string_ranges_decrease_by_ f_status_t f_string_ranges_decrease_by(const f_array_length_t amount, f_string_ranges_t * const ranges) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!ranges) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (ranges->size - amount > 0) { return private_f_string_ranges_resize(ranges->size - amount, ranges); } @@ -75,11 +81,10 @@ extern "C" { #ifndef _di_f_string_ranges_increase_ f_status_t f_string_ranges_increase(const f_array_length_t step, f_string_ranges_t * const ranges) { #ifndef _di_level_0_parameter_checking_ - if (!step) return F_status_set_error(F_parameter); if (!ranges) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (ranges->used + 1 > ranges->size) { + if (step && ranges->used + 1 > ranges->size) { f_array_length_t size = ranges->used + step; if (size > F_array_length_t_size_d) { @@ -100,10 +105,13 @@ extern "C" { #ifndef _di_f_string_ranges_increase_by_ f_status_t f_string_ranges_increase_by(const f_array_length_t amount, f_string_ranges_t * const ranges) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!ranges) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (ranges->used + amount > ranges->size) { if (ranges->used + amount > F_array_length_t_size_d) { return F_status_set_error(F_array_too_large); @@ -139,10 +147,13 @@ extern "C" { #ifndef _di_f_string_rangess_decimate_by_ f_status_t f_string_rangess_decimate_by(const f_array_length_t amount, f_string_rangess_t * const rangess) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!rangess) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (rangess->size - amount > 0) { return private_f_string_rangess_adjust(rangess->size - amount, rangess); } @@ -154,10 +165,13 @@ extern "C" { #ifndef _di_f_string_rangess_decrease_by_ f_status_t f_string_rangess_decrease_by(const f_array_length_t amount, f_string_rangess_t * const rangess) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!rangess) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (rangess->size - amount > 0) { return private_f_string_rangess_resize(rangess->size - amount, rangess); } @@ -169,11 +183,10 @@ extern "C" { #ifndef _di_f_string_rangess_increase_ f_status_t f_string_rangess_increase(const f_array_length_t step, f_string_rangess_t * const rangess) { #ifndef _di_level_0_parameter_checking_ - if (!step) return F_status_set_error(F_parameter); if (!rangess) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (rangess->used + 1 > rangess->size) { + if (step && rangess->used + 1 > rangess->size) { f_array_length_t size = rangess->used + step; if (size > F_array_length_t_size_d) { @@ -194,10 +207,13 @@ extern "C" { #ifndef _di_f_string_rangess_increase_by_ f_status_t f_string_rangess_increase_by(const f_array_length_t amount, f_string_rangess_t * const rangess) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!rangess) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (rangess->used + amount > rangess->size) { if (rangess->used + amount > F_array_length_t_size_d) { return F_status_set_error(F_array_too_large); diff --git a/level_0/f_string/c/string/range.h b/level_0/f_string/c/string/range.h index 1ae647c..78366b4 100644 --- a/level_0/f_string/c/string/range.h +++ b/level_0/f_string/c/string/range.h @@ -156,6 +156,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_parameter (with error bit) if a parameter is invalid. * @@ -179,6 +180,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_parameter (with error bit) if a parameter is invalid. * @@ -290,6 +292,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_parameter (with error bit) if a parameter is invalid. * @@ -313,6 +316,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_parameter (with error bit) if a parameter is invalid. * diff --git a/level_0/f_string/c/string/triple.c b/level_0/f_string/c/string/triple.c index eac16b8..d2ba928 100644 --- a/level_0/f_string/c/string/triple.c +++ b/level_0/f_string/c/string/triple.c @@ -76,10 +76,13 @@ extern "C" { #ifndef _di_f_string_triples_decrease_by_ f_status_t f_string_triples_decrease_by(const f_array_length_t amount, f_string_triples_t * const triples) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!triples) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (triples->size - amount > 0) { return private_f_string_triples_resize(triples->size - amount, triples); } @@ -91,11 +94,10 @@ extern "C" { #ifndef _di_f_string_triples_increase_ f_status_t f_string_triples_increase(const f_array_length_t step, f_string_triples_t * const triples) { #ifndef _di_level_0_parameter_checking_ - if (!step) return F_status_set_error(F_parameter); if (!triples) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (triples->used + 1 > triples->size) { + if (step && triples->used + 1 > triples->size) { f_array_length_t size = triples->used + F_memory_default_allocation_small_d; if (size > F_array_length_t_size_d) { @@ -116,10 +118,13 @@ extern "C" { #ifndef _di_f_string_triples_increase_by_ f_status_t f_string_triples_increase_by(const f_array_length_t amount, f_string_triples_t * const triples) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!triples) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (triples->used + amount > triples->size) { if (triples->used + amount > F_array_length_t_size_d) { return F_status_set_error(F_array_too_large); @@ -142,6 +147,108 @@ extern "C" { } #endif // _di_f_string_triples_resize_ +#ifndef _di_f_string_tripless_adjust_ + f_status_t f_string_tripless_adjust(const f_array_length_t length, f_string_tripless_t * const tripless) { + #ifndef _di_level_0_parameter_checking_ + if (!tripless) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_string_tripless_adjust(length, tripless); + } +#endif // _di_f_string_tripless_adjust_ + +#ifndef _di_f_string_tripless_decimate_by_ + f_status_t f_string_tripless_decimate_by(const f_array_length_t amount, f_string_tripless_t * const tripless) { + #ifndef _di_level_0_parameter_checking_ + if (!tripless) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!amount) { + return F_data_not; + } + + if (tripless->size - amount > 0) { + return private_f_string_tripless_adjust(tripless->size - amount, tripless); + } + + return private_f_string_tripless_adjust(0, tripless); + } +#endif // _di_f_string_tripless_decimate_by_ + +#ifndef _di_f_string_tripless_decrease_by_ + f_status_t f_string_tripless_decrease_by(const f_array_length_t amount, f_string_tripless_t * const tripless) { + #ifndef _di_level_0_parameter_checking_ + if (!tripless) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!amount) { + return F_data_not; + } + + if (tripless->size - amount > 0) { + return private_f_string_tripless_resize(tripless->size - amount, tripless); + } + + return private_f_string_tripless_resize(0, tripless); + } +#endif // _di_f_string_tripless_decrease_by_ + +#ifndef _di_f_string_tripless_increase_ + f_status_t f_string_tripless_increase(const f_array_length_t step, f_string_tripless_t * const tripless) { + #ifndef _di_level_0_parameter_checking_ + if (!tripless) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (step && tripless->used + 1 > tripless->size) { + f_array_length_t size = tripless->used + step; + + if (size > F_array_length_t_size_d) { + if (tripless->used + 1 > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + size = F_array_length_t_size_d; + } + + return private_f_string_tripless_resize(size, tripless); + } + + return F_data_not; + } +#endif // _di_f_string_tripless_increase_ + +#ifndef _di_f_string_tripless_increase_by_ + f_status_t f_string_tripless_increase_by(const f_array_length_t amount, f_string_tripless_t * const tripless) { + #ifndef _di_level_0_parameter_checking_ + if (!tripless) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!amount) { + return F_data_not; + } + + if (tripless->used + amount > tripless->size) { + if (tripless->used + amount > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + return private_f_string_tripless_resize(tripless->used + amount, tripless); + } + + return F_data_not; + } +#endif // _di_f_string_tripless_increase_by_ + +#ifndef _di_f_string_tripless_resize_ + f_status_t f_string_tripless_resize(const f_array_length_t length, f_string_tripless_t * const tripless) { + #ifndef _di_level_0_parameter_checking_ + if (!tripless) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_string_tripless_resize(length, tripless); + } +#endif // _di_f_string_tripless_resize_ + #ifdef __cplusplus } // extern "C" #endif diff --git a/level_0/f_string/c/string/triple.h b/level_0/f_string/c/string/triple.h index b5c2570..417792b 100644 --- a/level_0/f_string/c/string/triple.h +++ b/level_0/f_string/c/string/triple.h @@ -86,6 +86,37 @@ extern "C" { #endif // _di_f_string_triples_t_ /** + * An array of string tripless. + * + * array: The array of string triples. + * size: Total amount of allocated space. + * used: Total number of allocated spaces used. + */ +#ifndef _di_f_string_tripless_t_ + typedef struct { + f_string_triples_t *array; + + f_array_length_t size; + f_array_length_t used; + } f_string_tripless_t; + + #define f_string_tripless_t_initialize f_string_statics_t_initialize + + #define macro_f_string_tripless_t_clear(tripless) macro_f_memory_structure_clear(tripless) + + #define macro_f_string_tripless_t_resize(status, tripless, length) status = f_string_tripless_resize(length, &tripless); + #define macro_f_string_tripless_t_adjust(status, tripless, length) status = f_string_tripless_adjust(length, &tripless); + + #define macro_f_string_tripless_t_delete_simple(tripless) f_string_tripless_resize(0, &tripless); + #define macro_f_string_tripless_t_destroy_simple(tripless) f_string_tripless_adjust(0, &tripless); + + #define macro_f_string_tripless_t_increase(status, step, tripless) status = f_string_tripless_increase(step, tripless); + #define macro_f_string_tripless_t_increase_by(status, tripless, amount) status = f_string_tripless_increase_by(amount, tripless); + #define macro_f_string_tripless_t_decrease_by(status, tripless, amount) status = f_string_tripless_decrease_by(amount, tripless); + #define macro_f_string_tripless_t_decimate_by(status, tripless, amount) status = f_string_tripless_decimate_by(amount, tripless); +#endif // _di_f_string_tripless_t_ + +/** * Resize the string triples array. * * @param length @@ -138,6 +169,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_parameter (with error bit) if a parameter is invalid. * @@ -161,6 +193,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_parameter (with error bit) if a parameter is invalid. * @@ -239,6 +272,162 @@ extern "C" { extern f_status_t f_string_triples_resize(const f_array_length_t length, f_string_triples_t * const triples); #endif // _di_f_string_triples_resize_ +/** + * Resize the string tripless array. + * + * @param length + * The new size to use. + * @param tripless + * The string tripless array to resize. + * + * @return + * F_none on success. + * + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + */ +#ifndef _di_f_string_tripless_adjust_ + extern f_status_t f_string_tripless_adjust(const f_array_length_t length, f_string_tripless_t * const tripless); +#endif // _di_f_string_tripless_adjust_ + +/** + * Append the source tripless onto the destination. + * + * @param source + * The source tripless to append. + * @param destination + * The destination tripless the source is appended onto. + * + * @return + * F_none on success. + * F_data_not on success, but there is no reason to increase size (size == 0). + * + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_string_tripless_append_ + extern f_status_t f_string_tripless_append(const f_string_tripless_t source, f_string_tripless_t * const destination); +#endif // _di_f_string_tripless_append_ + +/** + * Resize the string tripless 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. + * This will not shrink the size to less than 0. + * + * @param amount + * A positive number representing how much to decimate the size by. + * @param tripless + * The string tripless 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(). + */ +#ifndef _di_f_string_tripless_decimate_by_ + extern f_status_t f_string_tripless_decimate_by(const f_array_length_t amount, f_string_tripless_t * const tripless); +#endif // _di_f_string_tripless_decimate_by_ + +/** + * Resize the string tripless 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. + * This will not shrink the size to less than 0. + * + * @param amount + * A positive number representing how much to decrease the size by. + * @param tripless + * The string tripless 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(). + */ +#ifndef _di_f_string_tripless_decrease_by_ + extern f_status_t f_string_tripless_decrease_by(const f_array_length_t amount, f_string_tripless_t * const tripless); +#endif // _di_f_string_tripless_decrease_by_ + +/** + * Increase the size of the string tripless array, but only if necessary. + * + * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d). + * If already set to the maximum buffer size, then the resize will fail. + * + * @param step + * The allocation step to use. + * Must be greater than 0. + * @param tripless + * The string tripless array to resize. + * + * @return + * F_none on success. + * F_data_not on success, but there is no reason to increase size (used + 1 <= size). + * + * F_array_too_large (with error bit) if the new array length is too large. + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_string_tripless_increase_ + extern f_status_t f_string_tripless_increase(const f_array_length_t step, f_string_tripless_t * const tripless); +#endif // _di_f_string_tripless_increase_ + +/** + * Resize the string tripless array to a larger size. + * + * This will resize making the string larger based on the given length. + * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d). + * If already set to the maximum buffer size, then the resize will fail. + * + * @param amount + * A positive number representing how much to increase the size by. + * @param tripless + * The string tripless 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_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_string_tripless_increase_by_ + extern f_status_t f_string_tripless_increase_by(const f_array_length_t amount, f_string_tripless_t * const tripless); +#endif // _di_f_string_tripless_increase_by_ + +/** + * Resize the string tripless array. + * + * @param length + * The new size to use. + * @param tripless + * The string tripless 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(). + */ +#ifndef _di_f_string_tripless_resize_ + extern f_status_t f_string_tripless_resize(const f_array_length_t length, f_string_tripless_t * const tripless); +#endif // _di_f_string_tripless_resize_ + #ifdef __cplusplus } // extern "C" #endif diff --git a/level_0/f_thread/c/thread.c b/level_0/f_thread/c/thread.c index 2e58960..a4cc6be 100644 --- a/level_0/f_thread/c/thread.c +++ b/level_0/f_thread/c/thread.c @@ -523,10 +523,13 @@ extern "C" { #ifndef _di_f_thread_attributes_decrease_by_ f_status_t f_thread_attributes_decrease_by(const f_array_length_t amount, f_thread_attributes_t * const attributes) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!attributes) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (attributes->size - amount > 0) { return private_f_thread_attributes_resize(attributes->size - amount, attributes); } @@ -538,11 +541,10 @@ extern "C" { #ifndef _di_f_thread_attributes_increase_ f_status_t f_thread_attributes_increase(const f_array_length_t step, f_thread_attributes_t * const attributes) { #ifndef _di_level_0_parameter_checking_ - if (!step) return F_status_set_error(F_parameter); if (!attributes) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (attributes->used + 1 > attributes->size) { + if (step && attributes->used + 1 > attributes->size) { f_array_length_t size = attributes->used + step; if (size > F_array_length_t_size_d) { @@ -563,10 +565,13 @@ extern "C" { #ifndef _di_f_thread_attributes_increase_by_ f_status_t f_thread_attributes_increase_by(const f_array_length_t amount, f_thread_attributes_t * const attributes) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!attributes) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (attributes->used + amount > attributes->size) { if (attributes->used + amount > F_array_length_t_size_d) { return F_status_set_error(F_array_too_large); @@ -660,10 +665,13 @@ extern "C" { #ifndef _di_f_thread_barrier_attributes_decimate_by_ f_status_t f_thread_barrier_attributes_decimate_by(const f_array_length_t amount, f_thread_barrier_attributes_t * const attributes) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!attributes) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (attributes->size - amount > 0) { return private_f_thread_barrier_attributes_adjust(attributes->size - amount, attributes); } @@ -675,10 +683,13 @@ extern "C" { #ifndef _di_f_thread_barrier_attributes_decrease_by_ f_status_t f_thread_barrier_attributes_decrease_by(const f_array_length_t amount, f_thread_barrier_attributes_t * const attributes) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!attributes) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (attributes->size - amount > 0) { return private_f_thread_barrier_attributes_resize(attributes->size - amount, attributes); } @@ -690,11 +701,10 @@ extern "C" { #ifndef _di_f_thread_barrier_attributes_increase_ f_status_t f_thread_barrier_attributes_increase(const f_array_length_t step, f_thread_barrier_attributes_t * const attributes) { #ifndef _di_level_0_parameter_checking_ - if (!step) return F_status_set_error(F_parameter); if (!attributes) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (attributes->used + 1 > attributes->size) { + if (step && attributes->used + 1 > attributes->size) { f_array_length_t size = attributes->used + step; if (size > F_array_length_t_size_d) { @@ -715,10 +725,13 @@ extern "C" { #ifndef _di_f_thread_barrier_attributes_increase_by_ f_status_t f_thread_barrier_attributes_increase_by(const f_array_length_t amount, f_thread_barrier_attributes_t * const attributes) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!attributes) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (attributes->used + amount > attributes->size) { if (attributes->used + amount > F_array_length_t_size_d) { return F_status_set_error(F_array_too_large); @@ -796,10 +809,13 @@ extern "C" { #ifndef _di_f_thread_barriers_decimate_by_ f_status_t f_thread_barriers_decimate_by(const f_array_length_t amount, f_thread_barriers_t * const barriers) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!barriers) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (barriers->size - amount > 0) { return private_f_thread_barriers_adjust(barriers->size - amount, barriers); } @@ -811,10 +827,13 @@ extern "C" { #ifndef _di_f_thread_barriers_decrease_by_ f_status_t f_thread_barriers_decrease_by(const f_array_length_t amount, f_thread_barriers_t * const barriers) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!barriers) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (barriers->size - amount > 0) { return private_f_thread_barriers_resize(barriers->size - amount, barriers); } @@ -826,11 +845,10 @@ extern "C" { #ifndef _di_f_thread_barriers_increase_ f_status_t f_thread_barriers_increase(const f_array_length_t step, f_thread_barriers_t * const barriers) { #ifndef _di_level_0_parameter_checking_ - if (!step) return F_status_set_error(F_parameter); if (!barriers) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (barriers->used + 1 > barriers->size) { + if (step && barriers->used + 1 > barriers->size) { f_array_length_t size = barriers->used + step; if (size > F_array_length_t_size_d) { @@ -851,10 +869,13 @@ extern "C" { #ifndef _di_f_thread_barriers_increase_by_ f_status_t f_thread_barriers_increase_by(const f_array_length_t amount, f_thread_barriers_t * const barriers) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!barriers) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (barriers->used + amount > barriers->size) { if (barriers->used + amount > F_array_length_t_size_d) { return F_status_set_error(F_array_too_large); @@ -1044,10 +1065,13 @@ extern "C" { #ifndef _di_f_thread_condition_attributes_decimate_by_ f_status_t f_thread_condition_attributes_decimate_by(const f_array_length_t amount, f_thread_condition_attributes_t * const attributes) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!attributes) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (attributes->size - amount > 0) { return private_f_thread_condition_attributes_adjust(attributes->size - amount, attributes); } @@ -1059,10 +1083,13 @@ extern "C" { #ifndef _di_f_thread_condition_attributes_decrease_by_ f_status_t f_thread_condition_attributes_decrease_by(const f_array_length_t amount, f_thread_condition_attributes_t * const attributes) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!attributes) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (attributes->size - amount > 0) { return private_f_thread_condition_attributes_resize(attributes->size - amount, attributes); } @@ -1074,11 +1101,10 @@ extern "C" { #ifndef _di_f_thread_condition_attributes_increase_ f_status_t f_thread_condition_attributes_increase(const f_array_length_t step, f_thread_condition_attributes_t * const attributes) { #ifndef _di_level_0_parameter_checking_ - if (!step) return F_status_set_error(F_parameter); if (!attributes) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (attributes->used + 1 > attributes->size) { + if (step && attributes->used + 1 > attributes->size) { f_array_length_t size = attributes->used + step; if (size > F_array_length_t_size_d) { @@ -1099,10 +1125,13 @@ extern "C" { #ifndef _di_f_thread_condition_attributes_increase_by_ f_status_t f_thread_condition_attributes_increase_by(const f_array_length_t amount, f_thread_condition_attributes_t * const attributes) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!attributes) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (attributes->used + amount > attributes->size) { if (attributes->used + amount > F_array_length_t_size_d) { return F_status_set_error(F_array_too_large); @@ -1265,10 +1294,13 @@ extern "C" { #ifndef _di_f_thread_conditions_decrease_by_ f_status_t f_thread_conditions_decrease_by(const f_array_length_t amount, f_thread_conditions_t * const conditions) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!conditions) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (conditions->size - amount > 0) { return private_f_thread_conditions_resize(conditions->size - amount, conditions); } @@ -1280,11 +1312,10 @@ extern "C" { #ifndef _di_f_thread_conditions_increase_ f_status_t f_thread_conditions_increase(const f_array_length_t step, f_thread_conditions_t * const conditions) { #ifndef _di_level_0_parameter_checking_ - if (!step) return F_status_set_error(F_parameter); if (!conditions) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (conditions->used + 1 > conditions->size) { + if (step && conditions->used + 1 > conditions->size) { f_array_length_t size = conditions->used + step; if (size > F_array_length_t_size_d) { @@ -1305,10 +1336,13 @@ extern "C" { #ifndef _di_f_thread_conditions_increase_by_ f_status_t f_thread_conditions_increase_by(const f_array_length_t amount, f_thread_conditions_t * const conditions) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!conditions) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (conditions->used + amount > conditions->size) { if (conditions->used + amount > F_array_length_t_size_d) { return F_status_set_error(F_array_too_large); @@ -1510,10 +1544,13 @@ extern "C" { #ifndef _di_f_thread_keys_decimate_by_ f_status_t f_thread_keys_decimate_by(const f_array_length_t amount, f_thread_keys_t * const keys) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!keys) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (keys->size - amount > 0) { return private_f_thread_keys_adjust(keys->size - amount, keys); } @@ -1525,10 +1562,13 @@ extern "C" { #ifndef _di_f_thread_keys_decrease_by_ f_status_t f_thread_keys_decrease_by(const f_array_length_t amount, f_thread_keys_t * const keys) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!keys) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (keys->size - amount > 0) { return private_f_thread_keys_resize(keys->size - amount, keys); } @@ -1540,11 +1580,10 @@ extern "C" { #ifndef _di_f_thread_keys_increase_ f_status_t f_thread_keys_increase(const f_array_length_t step, f_thread_keys_t * const keys) { #ifndef _di_level_0_parameter_checking_ - if (!step) return F_status_set_error(F_parameter); if (!keys) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (keys->used + 1 > keys->size) { + if (step && keys->used + 1 > keys->size) { f_array_length_t size = keys->used + step; if (size > F_array_length_t_size_d) { @@ -1565,10 +1604,13 @@ extern "C" { #ifndef _di_f_thread_keys_increase_by_ f_status_t f_thread_keys_increase_by(const f_array_length_t amount, f_thread_keys_t * const keys) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!keys) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (keys->used + amount > keys->size) { if (keys->used + amount > F_array_length_t_size_d) { return F_status_set_error(F_array_too_large); @@ -1599,7 +1641,6 @@ extern "C" { const int error = pthread_rwlockattr_init(attribute); - // @todo figure out the error codes and update accordingly. if (error) { if (error == EAGAIN) return F_status_set_error(F_resource_not); if (error == EBUSY) return F_status_set_error(F_busy); @@ -1670,10 +1711,13 @@ extern "C" { #ifndef _di_f_thread_lock_attributes_decimate_by_ f_status_t f_thread_lock_attributes_decimate_by(const f_array_length_t amount, f_thread_lock_attributes_t * const attributes) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!attributes) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (attributes->size - amount > 0) { return private_f_thread_lock_attributes_adjust(attributes->size - amount, attributes); } @@ -1685,10 +1729,13 @@ extern "C" { #ifndef _di_f_thread_lock_attributes_decrease_by_ f_status_t f_thread_lock_attributes_decrease_by(const f_array_length_t amount, f_thread_lock_attributes_t * const attributes) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!attributes) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (attributes->size - amount > 0) { return private_f_thread_lock_attributes_resize(attributes->size - amount, attributes); } @@ -1700,11 +1747,10 @@ extern "C" { #ifndef _di_f_thread_lock_attributes_increase_ f_status_t f_thread_lock_attributes_increase(const f_array_length_t step, f_thread_lock_attributes_t * const attributes) { #ifndef _di_level_0_parameter_checking_ - if (!step) return F_status_set_error(F_parameter); if (!attributes) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (attributes->used + 1 > attributes->size) { + if (step && attributes->used + 1 > attributes->size) { f_array_length_t size = attributes->used + step; if (size > F_array_length_t_size_d) { @@ -1725,10 +1771,13 @@ extern "C" { #ifndef _di_f_thread_lock_attributes_increase_by_ f_status_t f_thread_lock_attributes_increase_by(const f_array_length_t amount, f_thread_lock_attributes_t * const attributes) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!attributes) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (attributes->used + amount > attributes->size) { if (attributes->used + amount > F_array_length_t_size_d) { return F_status_set_error(F_array_too_large); @@ -1917,10 +1966,13 @@ extern "C" { #ifndef _di_f_thread_locks_decimate_by_ f_status_t f_thread_locks_decimate_by(const f_array_length_t amount, f_thread_locks_t * const locks) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!locks) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (locks->size - amount > 0) { return private_f_thread_locks_adjust(locks->size - amount, locks); } @@ -1932,10 +1984,13 @@ extern "C" { #ifndef _di_f_thread_locks_decrease_by_ f_status_t f_thread_locks_decrease_by(const f_array_length_t amount, f_thread_locks_t * const locks) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!locks) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (locks->size - amount > 0) { return private_f_thread_locks_resize(locks->size - amount, locks); } @@ -1947,11 +2002,10 @@ extern "C" { #ifndef _di_f_thread_locks_increase_ f_status_t f_thread_locks_increase(const f_array_length_t step, f_thread_locks_t * const locks) { #ifndef _di_level_0_parameter_checking_ - if (!step) return F_status_set_error(F_parameter); if (!locks) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (locks->used + 1 > locks->size) { + if (step && locks->used + 1 > locks->size) { f_array_length_t size = locks->used + step; if (size > F_array_length_t_size_d) { @@ -1972,10 +2026,13 @@ extern "C" { #ifndef _di_f_thread_locks_increase_by_ f_status_t f_thread_locks_increase_by(const f_array_length_t amount, f_thread_locks_t * const locks) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!locks) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (locks->used + amount > locks->size) { if (locks->used + amount > F_array_length_t_size_d) { return F_status_set_error(F_array_too_large); @@ -2006,7 +2063,6 @@ extern "C" { const int error = pthread_mutexattr_init(attribute); - // @todo figure out the error codes and update accordingly. if (error) { if (error == EAGAIN) return F_status_set_error(F_resource_not); if (error == EBUSY) return F_status_set_error(F_busy); @@ -2189,10 +2245,13 @@ extern "C" { #ifndef _di_f_thread_mutex_attributes_decimate_by_ f_status_t f_thread_mutex_attributes_decimate_by(const f_array_length_t amount, f_thread_mutex_attributes_t * const attributes) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!attributes) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (attributes->size - amount > 0) { return private_f_thread_mutex_attributes_adjust(attributes->size - amount, attributes); } @@ -2204,10 +2263,13 @@ extern "C" { #ifndef _di_f_thread_mutex_attributes_decrease_by_ f_status_t f_thread_mutex_attributes_decrease_by(const f_array_length_t amount, f_thread_mutex_attributes_t * const attributes) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!attributes) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (attributes->size - amount > 0) { return private_f_thread_mutex_attributes_resize(attributes->size - amount, attributes); } @@ -2219,11 +2281,10 @@ extern "C" { #ifndef _di_f_thread_mutex_attributes_increase_ f_status_t f_thread_mutex_attributes_increase(const f_array_length_t step, f_thread_mutex_attributes_t * const attributes) { #ifndef _di_level_0_parameter_checking_ - if (!step) return F_status_set_error(F_parameter); if (!attributes) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (attributes->used + 1 > attributes->size) { + if (step && attributes->used + 1 > attributes->size) { f_array_length_t size = attributes->used + step; if (size > F_array_length_t_size_d) { @@ -2244,10 +2305,13 @@ extern "C" { #ifndef _di_f_thread_mutex_attributes_increase_by_ f_status_t f_thread_mutex_attributes_increase_by(const f_array_length_t amount, f_thread_mutex_attributes_t * const attributes) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!attributes) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (attributes->used + amount > attributes->size) { if (attributes->used + amount > F_array_length_t_size_d) { return F_status_set_error(F_array_too_large); @@ -2620,10 +2684,13 @@ extern "C" { #ifndef _di_f_thread_mutexs_decimate_by_ f_status_t f_thread_mutexs_decimate_by(const f_array_length_t amount, f_thread_mutexs_t * const mutexs) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!mutexs) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (mutexs->size - amount > 0) { return private_f_thread_mutexs_adjust(mutexs->size - amount, mutexs); } @@ -2635,10 +2702,13 @@ extern "C" { #ifndef _di_f_thread_mutexs_decrease_by_ f_status_t f_thread_mutexs_decrease_by(const f_array_length_t amount, f_thread_mutexs_t * const mutexs) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!mutexs) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (mutexs->size - amount > 0) { return private_f_thread_mutexs_resize(mutexs->size - amount, mutexs); } @@ -2650,11 +2720,10 @@ extern "C" { #ifndef _di_f_thread_mutexs_increase_ f_status_t f_thread_mutexs_increase(const f_array_length_t step, f_thread_mutexs_t * const mutexs) { #ifndef _di_level_0_parameter_checking_ - if (!step) return F_status_set_error(F_parameter); if (!mutexs) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (mutexs->used + 1 > mutexs->size) { + if (step && mutexs->used + 1 > mutexs->size) { f_array_length_t size = mutexs->used + step; if (size > F_array_length_t_size_d) { @@ -2675,10 +2744,13 @@ extern "C" { #ifndef _di_f_thread_mutexs_increase_by_ f_status_t f_thread_mutexs_increase_by(const f_array_length_t amount, f_thread_mutexs_t * const mutexs) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!mutexs) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (mutexs->used + amount > mutexs->size) { if (mutexs->used + amount > F_array_length_t_size_d) { return F_status_set_error(F_array_too_large); @@ -2789,10 +2861,13 @@ extern "C" { #ifndef _di_f_thread_semaphores_decimate_by_ f_status_t f_thread_semaphores_decimate_by(const f_array_length_t amount, f_thread_semaphores_t * const semaphores) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!semaphores) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (semaphores->size - amount > 0) { return private_f_thread_semaphores_adjust(semaphores->size - amount, semaphores); } @@ -2804,10 +2879,13 @@ extern "C" { #ifndef _di_f_thread_semaphores_decrease_by_ f_status_t f_thread_semaphores_decrease_by(const f_array_length_t amount, f_thread_semaphores_t * const semaphores) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!semaphores) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (semaphores->size - amount > 0) { return private_f_thread_semaphores_resize(semaphores->size - amount, semaphores); } @@ -2819,11 +2897,10 @@ extern "C" { #ifndef _di_f_thread_semaphores_increase_ f_status_t f_thread_semaphores_increase(const f_array_length_t step, f_thread_semaphores_t * const semaphores) { #ifndef _di_level_0_parameter_checking_ - if (!step) return F_status_set_error(F_parameter); if (!semaphores) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (semaphores->used + 1 > semaphores->size) { + if (step && semaphores->used + 1 > semaphores->size) { f_array_length_t size = semaphores->used + step; if (size > F_array_length_t_size_d) { @@ -2844,10 +2921,13 @@ extern "C" { #ifndef _di_f_thread_semaphores_increase_by_ f_status_t f_thread_semaphores_increase_by(const f_array_length_t amount, f_thread_semaphores_t * const semaphores) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!semaphores) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (semaphores->used + amount > semaphores->size) { if (semaphores->used + amount > F_array_length_t_size_d) { return F_status_set_error(F_array_too_large); @@ -2883,10 +2963,13 @@ extern "C" { #ifndef _di_f_thread_sets_decimate_by_ f_status_t f_thread_sets_decimate_by(const f_array_length_t amount, f_thread_sets_t * const sets) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!sets) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (sets->size - amount > 0) { return private_f_thread_sets_adjust(sets->size - amount, sets); } @@ -2898,10 +2981,13 @@ extern "C" { #ifndef _di_f_thread_sets_decrease_by_ f_status_t f_thread_sets_decrease_by(const f_array_length_t amount, f_thread_sets_t * const sets) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!sets) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (sets->size - amount > 0) { return private_f_thread_sets_resize(sets->size - amount, sets); } @@ -2913,11 +2999,10 @@ extern "C" { #ifndef _di_f_thread_sets_increase_ f_status_t f_thread_sets_increase(const f_array_length_t step, f_thread_sets_t * const sets) { #ifndef _di_level_0_parameter_checking_ - if (!step) return F_status_set_error(F_parameter); if (!sets) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (sets->used + 1 > sets->size) { + if (step && sets->used + 1 > sets->size) { f_array_length_t size = sets->used + step; if (size > F_array_length_t_size_d) { @@ -2938,10 +3023,13 @@ extern "C" { #ifndef _di_f_thread_sets_increase_by_ f_status_t f_thread_sets_increase_by(const f_array_length_t amount, f_thread_sets_t * const sets) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!sets) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (sets->used + amount > sets->size) { if (sets->used + amount > F_array_length_t_size_d) { return F_status_set_error(F_array_too_large); @@ -3132,10 +3220,13 @@ extern "C" { #ifndef _di_f_thread_spins_decimate_by_ f_status_t f_thread_spins_decimate_by(const f_array_length_t amount, f_thread_spins_t * const spins) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!spins) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (spins->size - amount > 0) { return private_f_thread_spins_adjust(spins->size - amount, spins); } @@ -3147,10 +3238,13 @@ extern "C" { #ifndef _di_f_thread_spins_decrease_by_ f_status_t f_thread_spins_decrease_by(const f_array_length_t amount, f_thread_spins_t * const spins) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!spins) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (spins->size - amount > 0) { return private_f_thread_spins_resize(spins->size - amount, spins); } @@ -3162,11 +3256,10 @@ extern "C" { #ifndef _di_f_thread_spins_increase_ f_status_t f_thread_spins_increase(const f_array_length_t step, f_thread_spins_t * const spins) { #ifndef _di_level_0_parameter_checking_ - if (!step) return F_status_set_error(F_parameter); if (!spins) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (spins->used + 1 > spins->size) { + if (step && spins->used + 1 > spins->size) { f_array_length_t size = spins->used + step; if (size > F_array_length_t_size_d) { @@ -3187,10 +3280,13 @@ extern "C" { #ifndef _di_f_thread_spins_increase_by_ f_status_t f_thread_spins_increase_by(const f_array_length_t amount, f_thread_spins_t * const spins) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!spins) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (spins->used + amount > spins->size) { if (spins->used + amount > F_array_length_t_size_d) { return F_status_set_error(F_array_too_large); diff --git a/level_0/f_thread/c/thread.h b/level_0/f_thread/c/thread.h index 86247ab..8f57143 100644 --- a/level_0/f_thread/c/thread.h +++ b/level_0/f_thread/c/thread.h @@ -649,6 +649,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. @@ -671,6 +672,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. @@ -864,6 +866,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. @@ -886,6 +889,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. @@ -1057,6 +1061,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. @@ -1079,6 +1084,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. @@ -1402,6 +1408,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. @@ -1424,6 +1431,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. @@ -1671,6 +1679,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. @@ -1693,6 +1702,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. @@ -2048,6 +2058,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. @@ -2070,6 +2081,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. @@ -2264,6 +2276,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. @@ -2286,6 +2299,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. @@ -2589,6 +2603,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. @@ -2611,6 +2626,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. @@ -2930,6 +2946,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. @@ -2952,6 +2969,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. @@ -3258,6 +3276,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. @@ -3280,6 +3299,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. @@ -3734,6 +3754,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. @@ -3756,6 +3777,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. @@ -3862,6 +3884,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. @@ -3884,6 +3907,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. @@ -4182,6 +4206,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. @@ -4204,6 +4229,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. diff --git a/level_0/f_type_array/c/type_array/array_length.c b/level_0/f_type_array/c/type_array/array_length.c index 7697406..3479ab4 100644 --- a/level_0/f_type_array/c/type_array/array_length.c +++ b/level_0/f_type_array/c/type_array/array_length.c @@ -31,10 +31,13 @@ extern "C" { #ifndef _di_f_array_lengths_decimate_by_ f_status_t f_array_lengths_decimate_by(const f_array_length_t amount, f_array_lengths_t *lengths) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!lengths) 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_array_lengths_adjust(lengths->size - amount, lengths); } @@ -46,10 +49,13 @@ extern "C" { #ifndef _di_f_array_lengths_decrease_by_ f_status_t f_array_lengths_decrease_by(const f_array_length_t amount, f_array_lengths_t *lengths) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!lengths) 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_array_lengths_resize(lengths->size - amount, lengths); } @@ -61,11 +67,10 @@ extern "C" { #ifndef _di_f_array_lengths_increase_ f_status_t f_array_lengths_increase(const f_array_length_t step, f_array_lengths_t *lengths) { #ifndef _di_level_0_parameter_checking_ - if (!step) return F_status_set_error(F_parameter); if (!lengths) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (lengths->used + 1 > lengths->size) { + if (step && lengths->used + 1 > lengths->size) { f_array_length_t size = lengths->used + step; if (size > F_array_length_t_size_d) { @@ -86,10 +91,13 @@ extern "C" { #ifndef _di_f_array_lengths_increase_by_ f_status_t f_array_lengths_increase_by(const f_array_length_t amount, f_array_lengths_t *lengths) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!lengths) 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_array_length_t_size_d) { return F_status_set_error(F_array_too_large); @@ -149,10 +157,13 @@ extern "C" { #ifndef _di_f_array_lengthss_decimate_by_ f_status_t f_array_lengthss_decimate_by(const f_array_length_t amount, f_array_lengthss_t *lengthss) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!lengthss) 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_array_lengthss_adjust(lengthss->size - amount, lengthss); } @@ -164,10 +175,13 @@ extern "C" { #ifndef _di_f_array_lengthss_decrease_by_ f_status_t f_array_lengthss_decrease_by(const f_array_length_t amount, f_array_lengthss_t *lengthss) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!lengthss) 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_array_lengthss_resize(lengthss->size - amount, lengthss); } @@ -179,11 +193,10 @@ extern "C" { #ifndef _di_f_array_lengthss_increase_ f_status_t f_array_lengthss_increase(const f_array_length_t step, f_array_lengthss_t *lengthss) { #ifndef _di_level_0_parameter_checking_ - if (!step) return F_status_set_error(F_parameter); if (!lengthss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (lengthss->used + 1 > lengthss->size) { + if (step && lengthss->used + 1 > lengthss->size) { f_array_length_t size = lengthss->used + step; if (size > F_array_length_t_size_d) { @@ -204,10 +217,13 @@ extern "C" { #ifndef _di_f_array_lengthss_increase_by_ f_status_t f_array_lengthss_increase_by(const f_array_length_t amount, f_array_lengthss_t *lengthss) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!lengthss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (lengthss->used + amount > lengthss->size) { if (lengthss->used + amount > F_array_length_t_size_d) { return F_status_set_error(F_array_too_large); diff --git a/level_0/f_type_array/c/type_array/array_length.h b/level_0/f_type_array/c/type_array/array_length.h index 013182d..34c8873 100644 --- a/level_0/f_type_array/c/type_array/array_length.h +++ b/level_0/f_type_array/c/type_array/array_length.h @@ -244,6 +244,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_parameter (with error bit) if a parameter is invalid. * @@ -268,6 +269,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_parameter (with error bit) if a parameter is invalid. * 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 75938dd..d18372d 100644 --- a/level_0/f_type_array/c/type_array/cell.c +++ b/level_0/f_type_array/c/type_array/cell.c @@ -31,10 +31,13 @@ extern "C" { #ifndef _di_f_cells_decimate_by_ f_status_t f_cells_decimate_by(const f_array_length_t amount, f_cells_t *cells) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!cells) 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); } @@ -46,10 +49,13 @@ extern "C" { #ifndef _di_f_cells_decrease_by_ f_status_t f_cells_decrease_by(const f_array_length_t amount, f_cells_t *cells) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!cells) 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); } @@ -61,11 +67,10 @@ extern "C" { #ifndef _di_f_cells_increase_ f_status_t f_cells_increase(const f_array_length_t step, f_cells_t *cells) { #ifndef _di_level_0_parameter_checking_ - if (!step) return F_status_set_error(F_parameter); if (!cells) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (cells->used + 1 > cells->size) { + if (step && cells->used + 1 > cells->size) { f_array_length_t size = cells->used + step; if (size > F_array_length_t_size_d) { @@ -86,10 +91,13 @@ extern "C" { #ifndef _di_f_cells_increase_by_ f_status_t f_cells_increase_by(const f_array_length_t amount, f_cells_t *cells) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!cells) 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_array_length_t_size_d) { return F_status_set_error(F_array_too_large); @@ -149,10 +157,13 @@ extern "C" { #ifndef _di_f_cellss_decimate_by_ f_status_t f_cellss_decimate_by(const f_array_length_t amount, f_cellss_t *cellss) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!cellss) 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); } @@ -164,10 +175,13 @@ extern "C" { #ifndef _di_f_cellss_decrease_by_ f_status_t f_cellss_decrease_by(const f_array_length_t amount, f_cellss_t *cellss) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!cellss) 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); } @@ -179,11 +193,10 @@ extern "C" { #ifndef _di_f_cellss_increase_ f_status_t f_cellss_increase(const f_array_length_t step, f_cellss_t *cellss) { #ifndef _di_level_0_parameter_checking_ - if (!step) return F_status_set_error(F_parameter); if (!cellss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (cellss->used + 1 > cellss->size) { + if (step && cellss->used + 1 > cellss->size) { f_array_length_t size = cellss->used + step; if (size > F_array_length_t_size_d) { @@ -204,10 +217,13 @@ extern "C" { #ifndef _di_f_cellss_increase_by_ f_status_t f_cellss_increase_by(const f_array_length_t amount, f_cellss_t *cellss) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!cellss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (cellss->used + amount > cellss->size) { if (cellss->used + amount > F_array_length_t_size_d) { return F_status_set_error(F_array_too_large); 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 8323e63..034b617 100644 --- a/level_0/f_type_array/c/type_array/cell.h +++ b/level_0/f_type_array/c/type_array/cell.h @@ -69,6 +69,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_parameter (with error bit) if a parameter is invalid. * @@ -92,6 +93,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_parameter (with error bit) if a parameter is invalid. * 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 fa3cf8b..ddd25be 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 @@ -31,10 +31,13 @@ extern "C" { #ifndef _di_f_fll_ids_decimate_by_ f_status_t f_fll_ids_decimate_by(const f_array_length_t amount, f_fll_ids_t *ids) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!ids) 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); } @@ -46,10 +49,13 @@ extern "C" { #ifndef _di_f_fll_ids_decrease_by_ f_status_t f_fll_ids_decrease_by(const f_array_length_t amount, f_fll_ids_t *ids) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!ids) 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); } @@ -61,11 +67,10 @@ extern "C" { #ifndef _di_f_fll_ids_increase_ f_status_t f_fll_ids_increase(const f_array_length_t step, f_fll_ids_t *ids) { #ifndef _di_level_0_parameter_checking_ - if (!step) return F_status_set_error(F_parameter); if (!ids) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (ids->used + 1 > ids->size) { + if (step && ids->used + 1 > ids->size) { f_array_length_t size = ids->used + step; if (size > F_array_length_t_size_d) { @@ -86,10 +91,13 @@ extern "C" { #ifndef _di_f_fll_ids_increase_by_ f_status_t f_fll_ids_increase_by(const f_array_length_t amount, f_fll_ids_t *ids) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!ids) 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_array_length_t_size_d) { return F_status_set_error(F_array_too_large); @@ -149,10 +157,13 @@ extern "C" { #ifndef _di_f_fll_idss_decimate_by_ f_status_t f_fll_idss_decimate_by(const f_array_length_t amount, f_fll_idss_t *idss) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!idss) 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); } @@ -164,10 +175,13 @@ extern "C" { #ifndef _di_f_fll_idss_decrease_by_ f_status_t f_fll_idss_decrease_by(const f_array_length_t amount, f_fll_idss_t *idss) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!idss) 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); } @@ -179,11 +193,10 @@ extern "C" { #ifndef _di_f_fll_idss_increase_ f_status_t f_fll_idss_increase(const f_array_length_t step, f_fll_idss_t *idss) { #ifndef _di_level_0_parameter_checking_ - if (!step) return F_status_set_error(F_parameter); if (!idss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (idss->used + 1 > idss->size) { + if (step && idss->used + 1 > idss->size) { f_array_length_t size = idss->used + step; if (size > F_array_length_t_size_d) { @@ -204,10 +217,13 @@ extern "C" { #ifndef _di_f_fll_idss_increase_by_ f_status_t f_fll_idss_increase_by(const f_array_length_t amount, f_fll_idss_t *idss) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!idss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (idss->used + amount > idss->size) { if (idss->used + amount > F_array_length_t_size_d) { return F_status_set_error(F_array_too_large); 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 14cf1bd..6560a6a 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 @@ -69,6 +69,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_parameter (with error bit) if a parameter is invalid. * @@ -92,6 +93,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_parameter (with error bit) if a parameter is invalid. * 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 d2f2f26..59b1ee1 100644 --- a/level_0/f_type_array/c/type_array/int128.c +++ b/level_0/f_type_array/c/type_array/int128.c @@ -31,10 +31,13 @@ extern "C" { #ifndef _di_f_int128s_decimate_by_ f_status_t f_int128s_decimate_by(const f_array_length_t amount, f_int128s_t *int128s) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!int128s) 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); } @@ -46,10 +49,13 @@ extern "C" { #ifndef _di_f_int128s_decrease_by_ f_status_t f_int128s_decrease_by(const f_array_length_t amount, f_int128s_t *int128s) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!int128s) 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); } @@ -61,11 +67,10 @@ extern "C" { #ifndef _di_f_int128s_increase_ f_status_t f_int128s_increase(const f_array_length_t step, f_int128s_t *int128s) { #ifndef _di_level_0_parameter_checking_ - if (!step) return F_status_set_error(F_parameter); if (!int128s) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (int128s->used + 1 > int128s->size) { + if (step && int128s->used + 1 > int128s->size) { f_array_length_t size = int128s->used + step; if (size > F_array_length_t_size_d) { @@ -86,10 +91,13 @@ extern "C" { #ifndef _di_f_int128s_increase_by_ f_status_t f_int128s_increase_by(const f_array_length_t amount, f_int128s_t *int128s) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!int128s) 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_array_length_t_size_d) { return F_status_set_error(F_array_too_large); @@ -149,10 +157,13 @@ extern "C" { #ifndef _di_f_int128ss_decimate_by_ f_status_t f_int128ss_decimate_by(const f_array_length_t amount, f_int128ss_t *int128ss) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!int128ss) 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); } @@ -164,10 +175,13 @@ extern "C" { #ifndef _di_f_int128ss_decrease_by_ f_status_t f_int128ss_decrease_by(const f_array_length_t amount, f_int128ss_t *int128ss) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!int128ss) 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); } @@ -179,11 +193,10 @@ extern "C" { #ifndef _di_f_int128ss_increase_ f_status_t f_int128ss_increase(const f_array_length_t step, f_int128ss_t *int128ss) { #ifndef _di_level_0_parameter_checking_ - if (!step) return F_status_set_error(F_parameter); if (!int128ss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (int128ss->used + 1 > int128ss->size) { + if (step && int128ss->used + 1 > int128ss->size) { f_array_length_t size = int128ss->used + step; if (size > F_array_length_t_size_d) { @@ -204,10 +217,13 @@ extern "C" { #ifndef _di_f_int128ss_increase_by_ f_status_t f_int128ss_increase_by(const f_array_length_t amount, f_int128ss_t *int128ss) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!int128ss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (int128ss->used + amount > int128ss->size) { if (int128ss->used + amount > F_array_length_t_size_d) { return F_status_set_error(F_array_too_large); @@ -255,10 +271,13 @@ extern "C" { #ifndef _di_f_uint128s_decimate_by_ f_status_t f_uint128s_decimate_by(const f_array_length_t amount, f_uint128s_t *uint128s) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!uint128s) 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); } @@ -270,10 +289,13 @@ extern "C" { #ifndef _di_f_uint128s_decrease_by_ f_status_t f_uint128s_decrease_by(const f_array_length_t amount, f_uint128s_t *uint128s) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!uint128s) 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); } @@ -285,11 +307,10 @@ extern "C" { #ifndef _di_f_uint128s_increase_ f_status_t f_uint128s_increase(const f_array_length_t step, f_uint128s_t *uint128s) { #ifndef _di_level_0_parameter_checking_ - if (!step) return F_status_set_error(F_parameter); if (!uint128s) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (uint128s->used + 1 > uint128s->size) { + if (step && uint128s->used + 1 > uint128s->size) { f_array_length_t size = uint128s->used + step; if (size > F_array_length_t_size_d) { @@ -310,10 +331,13 @@ extern "C" { #ifndef _di_f_uint128s_increase_by_ f_status_t f_uint128s_increase_by(const f_array_length_t amount, f_uint128s_t *uint128s) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!uint128s) 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_array_length_t_size_d) { return F_status_set_error(F_array_too_large); @@ -373,10 +397,13 @@ extern "C" { #ifndef _di_f_uint128ss_decimate_by_ f_status_t f_uint128ss_decimate_by(const f_array_length_t amount, f_uint128ss_t *uint128ss) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!uint128ss) 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); } @@ -388,10 +415,13 @@ extern "C" { #ifndef _di_f_uint128ss_decrease_by_ f_status_t f_uint128ss_decrease_by(const f_array_length_t amount, f_uint128ss_t *uint128ss) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!uint128ss) 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); } @@ -403,11 +433,10 @@ extern "C" { #ifndef _di_f_uint128ss_increase_ f_status_t f_uint128ss_increase(const f_array_length_t step, f_uint128ss_t *uint128ss) { #ifndef _di_level_0_parameter_checking_ - if (!step) return F_status_set_error(F_parameter); if (!uint128ss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (uint128ss->used + 1 > uint128ss->size) { + if (step && uint128ss->used + 1 > uint128ss->size) { f_array_length_t size = uint128ss->used + step; if (size > F_array_length_t_size_d) { @@ -428,10 +457,13 @@ extern "C" { #ifndef _di_f_uint128ss_increase_by_ f_status_t f_uint128ss_increase_by(const f_array_length_t amount, f_uint128ss_t *uint128ss) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!uint128ss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (uint128ss->used + amount > uint128ss->size) { if (uint128ss->used + amount > F_array_length_t_size_d) { return F_status_set_error(F_array_too_large); 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 843773b..232ad7a 100644 --- a/level_0/f_type_array/c/type_array/int128.h +++ b/level_0/f_type_array/c/type_array/int128.h @@ -69,6 +69,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_parameter (with error bit) if a parameter is invalid. * @@ -92,6 +93,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_parameter (with error bit) if a parameter is invalid. * @@ -401,6 +403,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_parameter (with error bit) if a parameter is invalid. * @@ -424,6 +427,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_parameter (with error bit) if a parameter is invalid. * 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 d5f8857..48773a5 100644 --- a/level_0/f_type_array/c/type_array/int16.c +++ b/level_0/f_type_array/c/type_array/int16.c @@ -31,10 +31,13 @@ extern "C" { #ifndef _di_f_int16s_decimate_by_ f_status_t f_int16s_decimate_by(const f_array_length_t amount, f_int16s_t *int16s) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!int16s) 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); } @@ -46,10 +49,13 @@ extern "C" { #ifndef _di_f_int16s_decrease_by_ f_status_t f_int16s_decrease_by(const f_array_length_t amount, f_int16s_t *int16s) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!int16s) 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); } @@ -61,11 +67,10 @@ extern "C" { #ifndef _di_f_int16s_increase_ f_status_t f_int16s_increase(const f_array_length_t step, f_int16s_t *int16s) { #ifndef _di_level_0_parameter_checking_ - if (!step) return F_status_set_error(F_parameter); if (!int16s) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (int16s->used + 1 > int16s->size) { + if (step && int16s->used + 1 > int16s->size) { f_array_length_t size = int16s->used + step; if (size > F_array_length_t_size_d) { @@ -86,10 +91,13 @@ extern "C" { #ifndef _di_f_int16s_increase_by_ f_status_t f_int16s_increase_by(const f_array_length_t amount, f_int16s_t *int16s) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!int16s) 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_array_length_t_size_d) { return F_status_set_error(F_array_too_large); @@ -149,10 +157,13 @@ extern "C" { #ifndef _di_f_int16ss_decimate_by_ f_status_t f_int16ss_decimate_by(const f_array_length_t amount, f_int16ss_t *int16ss) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!int16ss) 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); } @@ -164,10 +175,13 @@ extern "C" { #ifndef _di_f_int16ss_decrease_by_ f_status_t f_int16ss_decrease_by(const f_array_length_t amount, f_int16ss_t *int16ss) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!int16ss) 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); } @@ -179,11 +193,10 @@ extern "C" { #ifndef _di_f_int16ss_increase_ f_status_t f_int16ss_increase(const f_array_length_t step, f_int16ss_t *int16ss) { #ifndef _di_level_0_parameter_checking_ - if (!step) return F_status_set_error(F_parameter); if (!int16ss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (int16ss->used + 1 > int16ss->size) { + if (step && int16ss->used + 1 > int16ss->size) { f_array_length_t size = int16ss->used + step; if (size > F_array_length_t_size_d) { @@ -204,10 +217,13 @@ extern "C" { #ifndef _di_f_int16ss_increase_by_ f_status_t f_int16ss_increase_by(const f_array_length_t amount, f_int16ss_t *int16ss) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!int16ss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (int16ss->used + amount > int16ss->size) { if (int16ss->used + amount > F_array_length_t_size_d) { return F_status_set_error(F_array_too_large); @@ -255,10 +271,13 @@ extern "C" { #ifndef _di_f_uint16s_decimate_by_ f_status_t f_uint16s_decimate_by(const f_array_length_t amount, f_uint16s_t *uint16s) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!uint16s) 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); } @@ -270,10 +289,13 @@ extern "C" { #ifndef _di_f_uint16s_decrease_by_ f_status_t f_uint16s_decrease_by(const f_array_length_t amount, f_uint16s_t *uint16s) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!uint16s) 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); } @@ -285,11 +307,10 @@ extern "C" { #ifndef _di_f_uint16s_increase_ f_status_t f_uint16s_increase(const f_array_length_t step, f_uint16s_t *uint16s) { #ifndef _di_level_0_parameter_checking_ - if (!step) return F_status_set_error(F_parameter); if (!uint16s) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (uint16s->used + 1 > uint16s->size) { + if (step && uint16s->used + 1 > uint16s->size) { f_array_length_t size = uint16s->used + step; if (size > F_array_length_t_size_d) { @@ -310,10 +331,13 @@ extern "C" { #ifndef _di_f_uint16s_increase_by_ f_status_t f_uint16s_increase_by(const f_array_length_t amount, f_uint16s_t *uint16s) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!uint16s) 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_array_length_t_size_d) { return F_status_set_error(F_array_too_large); @@ -373,10 +397,13 @@ extern "C" { #ifndef _di_f_uint16ss_decimate_by_ f_status_t f_uint16ss_decimate_by(const f_array_length_t amount, f_uint16ss_t *uint16ss) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!uint16ss) 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); } @@ -388,10 +415,13 @@ extern "C" { #ifndef _di_f_uint16ss_decrease_by_ f_status_t f_uint16ss_decrease_by(const f_array_length_t amount, f_uint16ss_t *uint16ss) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!uint16ss) 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); } @@ -403,11 +433,10 @@ extern "C" { #ifndef _di_f_uint16ss_increase_ f_status_t f_uint16ss_increase(const f_array_length_t step, f_uint16ss_t *uint16ss) { #ifndef _di_level_0_parameter_checking_ - if (!step) return F_status_set_error(F_parameter); if (!uint16ss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (uint16ss->used + 1 > uint16ss->size) { + if (step && uint16ss->used + 1 > uint16ss->size) { f_array_length_t size = uint16ss->used + step; if (size > F_array_length_t_size_d) { @@ -428,10 +457,13 @@ extern "C" { #ifndef _di_f_uint16ss_increase_by_ f_status_t f_uint16ss_increase_by(const f_array_length_t amount, f_uint16ss_t *uint16ss) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!uint16ss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (uint16ss->used + amount > uint16ss->size) { if (uint16ss->used + amount > F_array_length_t_size_d) { return F_status_set_error(F_array_too_large); 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 dfb00af..22b28f5 100644 --- a/level_0/f_type_array/c/type_array/int16.h +++ b/level_0/f_type_array/c/type_array/int16.h @@ -69,6 +69,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_parameter (with error bit) if a parameter is invalid. * @@ -92,6 +93,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_parameter (with error bit) if a parameter is invalid. * @@ -244,6 +246,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_parameter (with error bit) if a parameter is invalid. * @@ -268,6 +271,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_parameter (with error bit) if a parameter is invalid. * @@ -401,6 +405,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_parameter (with error bit) if a parameter is invalid. * @@ -576,6 +581,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_parameter (with error bit) if a parameter is invalid. * 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 e1a98d6..701349e 100644 --- a/level_0/f_type_array/c/type_array/int32.c +++ b/level_0/f_type_array/c/type_array/int32.c @@ -31,10 +31,13 @@ extern "C" { #ifndef _di_f_int32s_decimate_by_ f_status_t f_int32s_decimate_by(const f_array_length_t amount, f_int32s_t *int32s) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!int32s) 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); } @@ -46,10 +49,13 @@ extern "C" { #ifndef _di_f_int32s_decrease_by_ f_status_t f_int32s_decrease_by(const f_array_length_t amount, f_int32s_t *int32s) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!int32s) 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); } @@ -61,11 +67,10 @@ extern "C" { #ifndef _di_f_int32s_increase_ f_status_t f_int32s_increase(const f_array_length_t step, f_int32s_t *int32s) { #ifndef _di_level_0_parameter_checking_ - if (!step) return F_status_set_error(F_parameter); if (!int32s) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (int32s->used + 1 > int32s->size) { + if (step && int32s->used + 1 > int32s->size) { f_array_length_t size = int32s->used + step; if (size > F_array_length_t_size_d) { @@ -86,10 +91,13 @@ extern "C" { #ifndef _di_f_int32s_increase_by_ f_status_t f_int32s_increase_by(const f_array_length_t amount, f_int32s_t *int32s) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!int32s) 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_array_length_t_size_d) { return F_status_set_error(F_array_too_large); @@ -149,10 +157,13 @@ extern "C" { #ifndef _di_f_int32ss_decimate_by_ f_status_t f_int32ss_decimate_by(const f_array_length_t amount, f_int32ss_t *int32ss) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!int32ss) 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); } @@ -164,10 +175,13 @@ extern "C" { #ifndef _di_f_int32ss_decrease_by_ f_status_t f_int32ss_decrease_by(const f_array_length_t amount, f_int32ss_t *int32ss) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!int32ss) 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); } @@ -179,11 +193,10 @@ extern "C" { #ifndef _di_f_int32ss_increase_ f_status_t f_int32ss_increase(const f_array_length_t step, f_int32ss_t *int32ss) { #ifndef _di_level_0_parameter_checking_ - if (!step) return F_status_set_error(F_parameter); if (!int32ss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (int32ss->used + 1 > int32ss->size) { + if (step && int32ss->used + 1 > int32ss->size) { f_array_length_t size = int32ss->used + step; if (size > F_array_length_t_size_d) { @@ -204,10 +217,13 @@ extern "C" { #ifndef _di_f_int32ss_increase_by_ f_status_t f_int32ss_increase_by(const f_array_length_t amount, f_int32ss_t *int32ss) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!int32ss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (int32ss->used + amount > int32ss->size) { if (int32ss->used + amount > F_array_length_t_size_d) { return F_status_set_error(F_array_too_large); @@ -255,10 +271,13 @@ extern "C" { #ifndef _di_f_uint32s_decimate_by_ f_status_t f_uint32s_decimate_by(const f_array_length_t amount, f_uint32s_t *uint32s) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!uint32s) 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); } @@ -270,10 +289,13 @@ extern "C" { #ifndef _di_f_uint32s_decrease_by_ f_status_t f_uint32s_decrease_by(const f_array_length_t amount, f_uint32s_t *uint32s) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!uint32s) 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); } @@ -285,11 +307,10 @@ extern "C" { #ifndef _di_f_uint32s_increase_ f_status_t f_uint32s_increase(const f_array_length_t step, f_uint32s_t *uint32s) { #ifndef _di_level_0_parameter_checking_ - if (!step) return F_status_set_error(F_parameter); if (!uint32s) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (uint32s->used + 1 > uint32s->size) { + if (step && uint32s->used + 1 > uint32s->size) { f_array_length_t size = uint32s->used + step; if (size > F_array_length_t_size_d) { @@ -310,10 +331,13 @@ extern "C" { #ifndef _di_f_uint32s_increase_by_ f_status_t f_uint32s_increase_by(const f_array_length_t amount, f_uint32s_t *uint32s) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!uint32s) 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_array_length_t_size_d) { return F_status_set_error(F_array_too_large); @@ -373,10 +397,13 @@ extern "C" { #ifndef _di_f_uint32ss_decimate_by_ f_status_t f_uint32ss_decimate_by(const f_array_length_t amount, f_uint32ss_t *uint32ss) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!uint32ss) 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); } @@ -388,10 +415,13 @@ extern "C" { #ifndef _di_f_uint32ss_decrease_by_ f_status_t f_uint32ss_decrease_by(const f_array_length_t amount, f_uint32ss_t *uint32ss) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!uint32ss) 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); } @@ -403,11 +433,10 @@ extern "C" { #ifndef _di_f_uint32ss_increase_ f_status_t f_uint32ss_increase(const f_array_length_t step, f_uint32ss_t *uint32ss) { #ifndef _di_level_0_parameter_checking_ - if (!step) return F_status_set_error(F_parameter); if (!uint32ss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (uint32ss->used + 1 > uint32ss->size) { + if (step && uint32ss->used + 1 > uint32ss->size) { f_array_length_t size = uint32ss->used + step; if (size > F_array_length_t_size_d) { @@ -428,10 +457,13 @@ extern "C" { #ifndef _di_f_uint32ss_increase_by_ f_status_t f_uint32ss_increase_by(const f_array_length_t amount, f_uint32ss_t *uint32ss) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!uint32ss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (uint32ss->used + amount > uint32ss->size) { if (uint32ss->used + amount > F_array_length_t_size_d) { return F_status_set_error(F_array_too_large); 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 ea6aa1d..7ec1864 100644 --- a/level_0/f_type_array/c/type_array/int32.h +++ b/level_0/f_type_array/c/type_array/int32.h @@ -69,6 +69,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_parameter (with error bit) if a parameter is invalid. * @@ -244,6 +245,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_parameter (with error bit) if a parameter is invalid. * @@ -401,6 +403,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_parameter (with error bit) if a parameter is invalid. * @@ -576,6 +579,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_parameter (with error bit) if a parameter is invalid. * 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 3568eb6..687ad22 100644 --- a/level_0/f_type_array/c/type_array/int64.c +++ b/level_0/f_type_array/c/type_array/int64.c @@ -31,10 +31,13 @@ extern "C" { #ifndef _di_f_int64s_decimate_by_ f_status_t f_int64s_decimate_by(const f_array_length_t amount, f_int64s_t *int64s) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!int64s) 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); } @@ -46,10 +49,13 @@ extern "C" { #ifndef _di_f_int64s_decrease_by_ f_status_t f_int64s_decrease_by(const f_array_length_t amount, f_int64s_t *int64s) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!int64s) 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); } @@ -61,11 +67,10 @@ extern "C" { #ifndef _di_f_int64s_increase_ f_status_t f_int64s_increase(const f_array_length_t step, f_int64s_t *int64s) { #ifndef _di_level_0_parameter_checking_ - if (!step) return F_status_set_error(F_parameter); if (!int64s) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (int64s->used + 1 > int64s->size) { + if (step && int64s->used + 1 > int64s->size) { f_array_length_t size = int64s->used + step; if (size > F_array_length_t_size_d) { @@ -86,10 +91,13 @@ extern "C" { #ifndef _di_f_int64s_increase_by_ f_status_t f_int64s_increase_by(const f_array_length_t amount, f_int64s_t *int64s) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!int64s) 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_array_length_t_size_d) { return F_status_set_error(F_array_too_large); @@ -149,10 +157,13 @@ extern "C" { #ifndef _di_f_int64ss_decimate_by_ f_status_t f_int64ss_decimate_by(const f_array_length_t amount, f_int64ss_t *int64ss) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!int64ss) 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); } @@ -164,10 +175,13 @@ extern "C" { #ifndef _di_f_int64ss_decrease_by_ f_status_t f_int64ss_decrease_by(const f_array_length_t amount, f_int64ss_t *int64ss) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!int64ss) 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); } @@ -179,11 +193,10 @@ extern "C" { #ifndef _di_f_int64ss_increase_ f_status_t f_int64ss_increase(const f_array_length_t step, f_int64ss_t *int64ss) { #ifndef _di_level_0_parameter_checking_ - if (!step) return F_status_set_error(F_parameter); if (!int64ss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (int64ss->used + 1 > int64ss->size) { + if (step && int64ss->used + 1 > int64ss->size) { f_array_length_t size = int64ss->used + step; if (size > F_array_length_t_size_d) { @@ -204,10 +217,13 @@ extern "C" { #ifndef _di_f_int64ss_increase_by_ f_status_t f_int64ss_increase_by(const f_array_length_t amount, f_int64ss_t *int64ss) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!int64ss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (int64ss->used + amount > int64ss->size) { if (int64ss->used + amount > F_array_length_t_size_d) { return F_status_set_error(F_array_too_large); @@ -255,10 +271,13 @@ extern "C" { #ifndef _di_f_uint64s_decimate_by_ f_status_t f_uint64s_decimate_by(const f_array_length_t amount, f_uint64s_t *uint64s) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!uint64s) 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); } @@ -270,10 +289,13 @@ extern "C" { #ifndef _di_f_uint64s_decrease_by_ f_status_t f_uint64s_decrease_by(const f_array_length_t amount, f_uint64s_t *uint64s) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!uint64s) 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); } @@ -285,11 +307,10 @@ extern "C" { #ifndef _di_f_uint64s_increase_ f_status_t f_uint64s_increase(const f_array_length_t step, f_uint64s_t *uint64s) { #ifndef _di_level_0_parameter_checking_ - if (!step) return F_status_set_error(F_parameter); if (!uint64s) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (uint64s->used + 1 > uint64s->size) { + if (step && uint64s->used + 1 > uint64s->size) { f_array_length_t size = uint64s->used + step; if (size > F_array_length_t_size_d) { @@ -310,10 +331,13 @@ extern "C" { #ifndef _di_f_uint64s_increase_by_ f_status_t f_uint64s_increase_by(const f_array_length_t amount, f_uint64s_t *uint64s) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!uint64s) 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_array_length_t_size_d) { return F_status_set_error(F_array_too_large); @@ -373,10 +397,13 @@ extern "C" { #ifndef _di_f_uint64ss_decimate_by_ f_status_t f_uint64ss_decimate_by(const f_array_length_t amount, f_uint64ss_t *uint64ss) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!uint64ss) 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); } @@ -388,10 +415,13 @@ extern "C" { #ifndef _di_f_uint64ss_decrease_by_ f_status_t f_uint64ss_decrease_by(const f_array_length_t amount, f_uint64ss_t *uint64ss) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!uint64ss) 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); } @@ -403,11 +433,10 @@ extern "C" { #ifndef _di_f_uint64ss_increase_ f_status_t f_uint64ss_increase(const f_array_length_t step, f_uint64ss_t *uint64ss) { #ifndef _di_level_0_parameter_checking_ - if (!step) return F_status_set_error(F_parameter); if (!uint64ss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (uint64ss->used + 1 > uint64ss->size) { + if (step && uint64ss->used + 1 > uint64ss->size) { f_array_length_t size = uint64ss->used + step; if (size > F_array_length_t_size_d) { @@ -428,10 +457,13 @@ extern "C" { #ifndef _di_f_uint64ss_increase_by_ f_status_t f_uint64ss_increase_by(const f_array_length_t amount, f_uint64ss_t *uint64ss) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!uint64ss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (uint64ss->used + amount > uint64ss->size) { if (uint64ss->used + amount > F_array_length_t_size_d) { return F_status_set_error(F_array_too_large); 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 5bcacc3..21df242 100644 --- a/level_0/f_type_array/c/type_array/int64.h +++ b/level_0/f_type_array/c/type_array/int64.h @@ -69,6 +69,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_parameter (with error bit) if a parameter is invalid. * @@ -92,6 +93,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_parameter (with error bit) if a parameter is invalid. * @@ -244,6 +246,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_parameter (with error bit) if a parameter is invalid. * @@ -268,6 +271,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_parameter (with error bit) if a parameter is invalid. * @@ -401,6 +405,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_parameter (with error bit) if a parameter is invalid. * @@ -424,6 +429,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_parameter (with error bit) if a parameter is invalid. * @@ -576,6 +582,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_parameter (with error bit) if a parameter is invalid. * @@ -600,6 +607,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_parameter (with error bit) if a parameter is invalid. * 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 735d319..c23258f 100644 --- a/level_0/f_type_array/c/type_array/int8.c +++ b/level_0/f_type_array/c/type_array/int8.c @@ -31,10 +31,13 @@ extern "C" { #ifndef _di_f_int8s_decimate_by_ f_status_t f_int8s_decimate_by(const f_array_length_t amount, f_int8s_t *int8s) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!int8s) 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); } @@ -46,10 +49,13 @@ extern "C" { #ifndef _di_f_int8s_decrease_by_ f_status_t f_int8s_decrease_by(const f_array_length_t amount, f_int8s_t *int8s) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!int8s) 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); } @@ -61,11 +67,10 @@ extern "C" { #ifndef _di_f_int8s_increase_ f_status_t f_int8s_increase(const f_array_length_t step, f_int8s_t *int8s) { #ifndef _di_level_0_parameter_checking_ - if (!step) return F_status_set_error(F_parameter); if (!int8s) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (int8s->used + 1 > int8s->size) { + if (step && int8s->used + 1 > int8s->size) { f_array_length_t size = int8s->used + step; if (size > F_array_length_t_size_d) { @@ -86,10 +91,13 @@ extern "C" { #ifndef _di_f_int8s_increase_by_ f_status_t f_int8s_increase_by(const f_array_length_t amount, f_int8s_t *int8s) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!int8s) 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_array_length_t_size_d) { return F_status_set_error(F_array_too_large); @@ -149,10 +157,13 @@ extern "C" { #ifndef _di_f_int8ss_decimate_by_ f_status_t f_int8ss_decimate_by(const f_array_length_t amount, f_int8ss_t *int8ss) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!int8ss) 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); } @@ -164,10 +175,13 @@ extern "C" { #ifndef _di_f_int8ss_decrease_by_ f_status_t f_int8ss_decrease_by(const f_array_length_t amount, f_int8ss_t *int8ss) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!int8ss) 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); } @@ -179,11 +193,10 @@ extern "C" { #ifndef _di_f_int8ss_increase_ f_status_t f_int8ss_increase(const f_array_length_t step, f_int8ss_t *int8ss) { #ifndef _di_level_0_parameter_checking_ - if (!step) return F_status_set_error(F_parameter); if (!int8ss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (int8ss->used + 1 > int8ss->size) { + if (step && int8ss->used + 1 > int8ss->size) { f_array_length_t size = int8ss->used + step; if (size > F_array_length_t_size_d) { @@ -204,10 +217,13 @@ extern "C" { #ifndef _di_f_int8ss_increase_by_ f_status_t f_int8ss_increase_by(const f_array_length_t amount, f_int8ss_t *int8ss) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!int8ss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (int8ss->used + amount > int8ss->size) { if (int8ss->used + amount > F_array_length_t_size_d) { return F_status_set_error(F_array_too_large); @@ -255,10 +271,13 @@ extern "C" { #ifndef _di_f_uint8s_decimate_by_ f_status_t f_uint8s_decimate_by(const f_array_length_t amount, f_uint8s_t *uint8s) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!uint8s) 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); } @@ -270,10 +289,13 @@ extern "C" { #ifndef _di_f_uint8s_decrease_by_ f_status_t f_uint8s_decrease_by(const f_array_length_t amount, f_uint8s_t *uint8s) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!uint8s) 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); } @@ -285,11 +307,10 @@ extern "C" { #ifndef _di_f_uint8s_increase_ f_status_t f_uint8s_increase(const f_array_length_t step, f_uint8s_t *uint8s) { #ifndef _di_level_0_parameter_checking_ - if (!step) return F_status_set_error(F_parameter); if (!uint8s) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (uint8s->used + 1 > uint8s->size) { + if (step && uint8s->used + 1 > uint8s->size) { f_array_length_t size = uint8s->used + step; if (size > F_array_length_t_size_d) { @@ -310,10 +331,13 @@ extern "C" { #ifndef _di_f_uint8s_increase_by_ f_status_t f_uint8s_increase_by(const f_array_length_t amount, f_uint8s_t *uint8s) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!uint8s) 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_array_length_t_size_d) { return F_status_set_error(F_array_too_large); @@ -373,10 +397,13 @@ extern "C" { #ifndef _di_f_uint8ss_decimate_by_ f_status_t f_uint8ss_decimate_by(const f_array_length_t amount, f_uint8ss_t *uint8ss) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!uint8ss) 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); } @@ -388,10 +415,13 @@ extern "C" { #ifndef _di_f_uint8ss_decrease_by_ f_status_t f_uint8ss_decrease_by(const f_array_length_t amount, f_uint8ss_t *uint8ss) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!uint8ss) 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); } @@ -403,11 +433,10 @@ extern "C" { #ifndef _di_f_uint8ss_increase_ f_status_t f_uint8ss_increase(const f_array_length_t step, f_uint8ss_t *uint8ss) { #ifndef _di_level_0_parameter_checking_ - if (!step) return F_status_set_error(F_parameter); if (!uint8ss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (uint8ss->used + 1 > uint8ss->size) { + if (step && uint8ss->used + 1 > uint8ss->size) { f_array_length_t size = uint8ss->used + step; if (size > F_array_length_t_size_d) { @@ -428,10 +457,13 @@ extern "C" { #ifndef _di_f_uint8ss_increase_by_ f_status_t f_uint8ss_increase_by(const f_array_length_t amount, f_uint8ss_t *uint8ss) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!uint8ss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (uint8ss->used + amount > uint8ss->size) { if (uint8ss->used + amount > F_array_length_t_size_d) { return F_status_set_error(F_array_too_large); 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 6163da3..c88e49e 100644 --- a/level_0/f_type_array/c/type_array/int8.h +++ b/level_0/f_type_array/c/type_array/int8.h @@ -69,6 +69,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_parameter (with error bit) if a parameter is invalid. * @@ -92,6 +93,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_parameter (with error bit) if a parameter is invalid. * @@ -244,6 +246,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_parameter (with error bit) if a parameter is invalid. * @@ -268,6 +271,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_parameter (with error bit) if a parameter is invalid. * @@ -401,6 +405,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_parameter (with error bit) if a parameter is invalid. * @@ -424,6 +429,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_parameter (with error bit) if a parameter is invalid. * @@ -576,6 +582,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_parameter (with error bit) if a parameter is invalid. * @@ -600,6 +607,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_parameter (with error bit) if a parameter is invalid. * 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 9aa700e..d416b9b 100644 --- a/level_0/f_type_array/c/type_array/state.c +++ b/level_0/f_type_array/c/type_array/state.c @@ -31,10 +31,13 @@ extern "C" { #ifndef _di_f_states_decimate_by_ f_status_t f_states_decimate_by(const f_array_length_t amount, f_states_t *states) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!states) 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); } @@ -46,10 +49,13 @@ extern "C" { #ifndef _di_f_states_decrease_by_ f_status_t f_states_decrease_by(const f_array_length_t amount, f_states_t *states) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!states) 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); } @@ -61,11 +67,10 @@ extern "C" { #ifndef _di_f_states_increase_ f_status_t f_states_increase(const f_array_length_t step, f_states_t *states) { #ifndef _di_level_0_parameter_checking_ - if (!step) return F_status_set_error(F_parameter); if (!states) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (states->used + 1 > states->size) { + if (step && states->used + 1 > states->size) { f_array_length_t size = states->used + step; if (size > F_array_length_t_size_d) { @@ -86,10 +91,13 @@ extern "C" { #ifndef _di_f_states_increase_by_ f_status_t f_states_increase_by(const f_array_length_t amount, f_states_t *states) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!states) 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_array_length_t_size_d) { return F_status_set_error(F_array_too_large); @@ -149,10 +157,13 @@ extern "C" { #ifndef _di_f_statess_decimate_by_ f_status_t f_statess_decimate_by(const f_array_length_t amount, f_statess_t *statess) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!statess) 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); } @@ -164,10 +175,13 @@ extern "C" { #ifndef _di_f_statess_decrease_by_ f_status_t f_statess_decrease_by(const f_array_length_t amount, f_statess_t *statess) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!statess) 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); } @@ -179,11 +193,10 @@ extern "C" { #ifndef _di_f_statess_increase_ f_status_t f_statess_increase(const f_array_length_t step, f_statess_t *statess) { #ifndef _di_level_0_parameter_checking_ - if (!step) return F_status_set_error(F_parameter); if (!statess) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (statess->used + 1 > statess->size) { + if (step && statess->used + 1 > statess->size) { f_array_length_t size = statess->used + step; if (size > F_array_length_t_size_d) { @@ -204,10 +217,13 @@ extern "C" { #ifndef _di_f_statess_increase_by_ f_status_t f_statess_increase_by(const f_array_length_t amount, f_statess_t *statess) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!statess) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (statess->used + amount > statess->size) { if (statess->used + amount > F_array_length_t_size_d) { return F_status_set_error(F_array_too_large); 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 ddd1cb1..cf63b29 100644 --- a/level_0/f_type_array/c/type_array/state.h +++ b/level_0/f_type_array/c/type_array/state.h @@ -69,6 +69,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_parameter (with error bit) if a parameter is invalid. * @@ -92,6 +93,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_parameter (with error bit) if a parameter is invalid. * @@ -244,6 +246,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_parameter (with error bit) if a parameter is invalid. * @@ -268,6 +271,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_parameter (with error bit) if a parameter is invalid. * 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 d5ed45b..2eb4a37 100644 --- a/level_0/f_type_array/c/type_array/status.c +++ b/level_0/f_type_array/c/type_array/status.c @@ -31,10 +31,13 @@ extern "C" { #ifndef _di_f_statuss_decimate_by_ f_status_t f_statuss_decimate_by(const f_array_length_t amount, f_statuss_t *statuss) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!statuss) 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); } @@ -46,10 +49,13 @@ extern "C" { #ifndef _di_f_statuss_decrease_by_ f_status_t f_statuss_decrease_by(const f_array_length_t amount, f_statuss_t *statuss) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!statuss) 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); } @@ -61,11 +67,10 @@ extern "C" { #ifndef _di_f_statuss_increase_ f_status_t f_statuss_increase(const f_array_length_t step, f_statuss_t *statuss) { #ifndef _di_level_0_parameter_checking_ - if (!step) return F_status_set_error(F_parameter); if (!statuss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (statuss->used + 1 > statuss->size) { + if (step && statuss->used + 1 > statuss->size) { f_array_length_t size = statuss->used + step; if (size > F_array_length_t_size_d) { @@ -86,10 +91,13 @@ extern "C" { #ifndef _di_f_statuss_increase_by_ f_status_t f_statuss_increase_by(const f_array_length_t amount, f_statuss_t *statuss) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!statuss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (statuss->used + amount > statuss->size) { if (statuss->used + amount > F_array_length_t_size_d) { return F_status_set_error(F_array_too_large); @@ -149,10 +157,13 @@ extern "C" { #ifndef _di_f_statusss_decimate_by_ f_status_t f_statusss_decimate_by(const f_array_length_t amount, f_statusss_t *statusss) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!statusss) 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); } @@ -164,10 +175,13 @@ extern "C" { #ifndef _di_f_statusss_decrease_by_ f_status_t f_statusss_decrease_by(const f_array_length_t amount, f_statusss_t *statusss) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!statusss) 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); } @@ -179,11 +193,10 @@ extern "C" { #ifndef _di_f_statusss_increase_ f_status_t f_statusss_increase(const f_array_length_t step, f_statusss_t *statusss) { #ifndef _di_level_0_parameter_checking_ - if (!step) return F_status_set_error(F_parameter); if (!statusss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (statusss->used + 1 > statusss->size) { + if (step && statusss->used + 1 > statusss->size) { f_array_length_t size = statusss->used + step; if (size > F_array_length_t_size_d) { @@ -204,10 +217,13 @@ extern "C" { #ifndef _di_f_statusss_increase_by_ f_status_t f_statusss_increase_by(const f_array_length_t amount, f_statusss_t *statusss) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!statusss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (statusss->used + amount > statusss->size) { if (statusss->used + amount > F_array_length_t_size_d) { return F_status_set_error(F_array_too_large); 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 ff25306..196cabb 100644 --- a/level_0/f_type_array/c/type_array/status.h +++ b/level_0/f_type_array/c/type_array/status.h @@ -69,6 +69,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_parameter (with error bit) if a parameter is invalid. * @@ -92,6 +93,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_parameter (with error bit) if a parameter is invalid. * @@ -244,6 +246,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_parameter (with error bit) if a parameter is invalid. * @@ -268,6 +271,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_parameter (with error bit) if a parameter is invalid. * diff --git a/level_0/f_utf/c/utf/dynamic.h b/level_0/f_utf/c/utf/dynamic.h index d29e4d7..87d7c5a 100644 --- a/level_0/f_utf/c/utf/dynamic.h +++ b/level_0/f_utf/c/utf/dynamic.h @@ -1079,7 +1079,7 @@ extern "C" { * * @return * F_none on success. - * F_data_not on success, but there is no reason to increase size (size == 0). + * F_data_not if amount is 0. * * F_parameter (with error bit) if a parameter is invalid. * @@ -1103,7 +1103,7 @@ extern "C" { * * @return * F_none on success. - * F_data_not on success, but there is no reason to increase size (size == 0). + * F_data_not if amount is 0. * * F_parameter (with error bit) if a parameter is invalid. * diff --git a/level_0/f_utf/c/utf/map.h b/level_0/f_utf/c/utf/map.h index 6456177..c04bc30 100644 --- a/level_0/f_utf/c/utf/map.h +++ b/level_0/f_utf/c/utf/map.h @@ -186,6 +186,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_parameter (with error bit) if a parameter is invalid. * @@ -209,6 +210,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_parameter (with error bit) if a parameter is invalid. * @@ -341,6 +343,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_parameter (with error bit) if a parameter is invalid. * @@ -364,6 +367,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_parameter (with error bit) if a parameter is invalid. * diff --git a/level_0/f_utf/c/utf/triple.c b/level_0/f_utf/c/utf/triple.c index ddcd5b7..ce2320d 100644 --- a/level_0/f_utf/c/utf/triple.c +++ b/level_0/f_utf/c/utf/triple.c @@ -62,10 +62,13 @@ extern "C" { #ifndef _di_f_utf_string_triples_decimate_by_ f_status_t f_utf_string_triples_decimate_by(const f_array_length_t amount, f_utf_string_triples_t *triples) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!triples) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (triples->size - amount > 0) { return private_f_utf_string_triples_adjust(triples->size - amount, triples); } @@ -77,10 +80,13 @@ extern "C" { #ifndef _di_f_utf_string_triples_decrease_by_ f_status_t f_utf_string_triples_decrease_by(const f_array_length_t amount, f_utf_string_triples_t *triples) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!triples) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (triples->size - amount > 0) { return private_f_utf_string_triples_resize(triples->size - amount, triples); } @@ -92,11 +98,10 @@ extern "C" { #ifndef _di_f_utf_string_triples_increase_ f_status_t f_utf_string_triples_increase(const f_array_length_t step, f_utf_string_triples_t *triples) { #ifndef _di_level_0_parameter_checking_ - if (!step) return F_status_set_error(F_parameter); if (!triples) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (triples->used + 1 > triples->size) { + if (step && triples->used + 1 > triples->size) { f_array_length_t size = triples->used + step; if (size > F_array_length_t_size_d) { @@ -117,10 +122,13 @@ extern "C" { #ifndef _di_f_utf_string_triples_increase_by_ f_status_t f_utf_string_triples_increase_by(const f_array_length_t amount, f_utf_string_triples_t *triples) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!triples) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) { + return F_data_not; + } + if (triples->used + amount > triples->size) { if (triples->used + amount > F_array_length_t_size_d) { return F_status_set_error(F_array_too_large); diff --git a/level_0/f_utf/c/utf/triple.h b/level_0/f_utf/c/utf/triple.h index 5871a57..15a6891 100644 --- a/level_0/f_utf/c/utf/triple.h +++ b/level_0/f_utf/c/utf/triple.h @@ -138,6 +138,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_parameter (with error bit) if a parameter is invalid. * @@ -161,6 +162,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. * * F_parameter (with error bit) if a parameter is invalid. *