The pattern for handling the standard array structure is now well established.
Provide a memory array functionality for handling the most basic form.
This should reduce repeated code where possible.
It would be interesting if this reduces the size of the resulting binary but with inline optimizations it may be possible that this actually increases the size of the resulting binary.
Update the comments and tests.
There are a lot of files that will need to be updated to use these new functions.
Most of these are in the f_type_array project.
build_sources_library fss/private-item.c fss/private-named.c fss/private-nest.c fss/private-set.c fss/private-set_quote.c fss/private-simple_packet.c
build_sources_library iki.c iki/common.c iki/data.c private-iki.c iki/private-data.c
build_sources_library limit.c limit/set.c limit/value.c limit/private-set.c limit/private-value.c
-build_sources_library memory.c private-memory.c memory/structure.c
+build_sources_library memory.c memory/array.c memory/structure.c
+build_sources_library private-memory.c memory/private-array.c
build_sources_library network.c
build_sources_library parse.c parse/utf.c
build_sources_library path.c private-path.c path/common.c
build_sources_headers fss.h fss/common.h fss/item.h fss/named.h fss/nest.h fss/quote.h fss/set.h fss/set_quote.h fss/simple_packet.h
build_sources_headers iki.h iki/common.h iki/data.h
build_sources_headers limit.h limit/set.h limit/value.h
-build_sources_headers memory.h memory/structure.h memory/common.h
+build_sources_headers memory.h memory/array.h memory/common.h memory/structure.h
build_sources_headers network.h network/common.h
build_sources_headers parse.h parse/utf.h
build_sources_headers path.h path/common.h
build_sources_library level_0/fss/private-item.c level_0/fss/private-named.c level_0/fss/private-nest.c level_0/fss/private-set.c level_0/fss/private-set_quote.c level_0/fss/private-simple_packet.c
build_sources_library level_0/iki.c level_0/iki/common.c level_0/iki/data.c level_0/private-iki.c level_0/iki/private-data.c
build_sources_library level_0/limit.c level_0/limit/set.c level_0/limit/value.c level_0/limit/private-set.c level_0/limit/private-value.c
-build_sources_library level_0/memory.c level_0/private-memory.c level_0/memory/structure.c
+build_sources_library level_0/memory.c level_0/memory/array.c level_0/memory/structure.c
+build_sources_library level_0/private-memory.c level_0/memory/private-array.c
build_sources_library level_0/network.c
build_sources_library level_0/parse.c level_0/parse/utf.c
build_sources_library level_0/path.c level_0/private-path.c level_0/path/common.c
build_sources_headers level_0/fss.h level_0/fss/common.h level_0/fss/item.h level_0/fss/named.h level_0/fss/nest.h level_0/fss/quote.h level_0/fss/set.h level_0/fss/set_quote.h level_0/fss/simple_packet.h
build_sources_headers level_0/iki.h level_0/iki/common.h level_0/iki/data.h
build_sources_headers level_0/limit.h level_0/limit/set.h level_0/limit/value.h
-build_sources_headers level_0/memory.h level_0/memory/structure.h level_0/memory/common.h
+build_sources_headers level_0/memory.h level_0/memory/array.h level_0/memory/common.h level_0/memory/structure.h
build_sources_headers level_0/network.h level_0/network/common.h
build_sources_headers level_0/parse.h level_0/parse/utf.h
build_sources_headers level_0/path.h level_0/path/common.h
#define _di_f_fss_simple_packet_d_
#define _di_f_fss_simple_packet_identify_
#define _di_f_fss_simple_packet_ranges_adjust_
+#define _di_f_fss_simple_packet_ranges_append_
+#define _di_f_fss_simple_packet_ranges_append_all_
#define _di_f_fss_simple_packet_ranges_decimate_by_
#define _di_f_fss_simple_packet_ranges_decrease_by_
#define _di_f_fss_simple_packet_ranges_increase_
#define _di_f_fss_simple_packet_ranges_increase_by_
#define _di_f_fss_simple_packet_ranges_resize_
+#define _di_f_fss_simple_packet_rangess_adjust_
+#define _di_f_fss_simple_packet_rangess_append_
+#define _di_f_fss_simple_packet_rangess_append_all_
+#define _di_f_fss_simple_packet_rangess_decimate_by_
+#define _di_f_fss_simple_packet_rangess_decrease_by_
+#define _di_f_fss_simple_packet_rangess_increase_
+#define _di_f_fss_simple_packet_rangess_increase_by_
+#define _di_f_fss_simple_packet_rangess_resize_
+#define _di_f_fss_simple_packet_rangess_t_
#define _di_f_fss_simple_packet_ranges_t_
#define _di_f_fss_simple_packet_range_t_
//#define _di_f_fss_skip_past_delimit_
//#define _di_fl_print_warning_s_
#define _di_f_memory_adjust_
+#define _di_f_memory_array_adjust_
+#define _di_f_memory_array_decimate_by_
+#define _di_f_memory_array_decrease_by_
+#define _di_f_memory_array_increase_
+#define _di_f_memory_array_increase_by_
+#define _di_f_memory_array_resize_
//#define _di_f_memory_default_d_
//#define _di_f_memory_delete_
#define _di_f_memory_destroy_
extern "C" {
#endif
-#if !defined(_di_f_fss_simple_packet_ranges_adjust_) || !defined(_di_f_fss_simple_packet_ranges_decimate_by_)
- f_status_t private_f_fss_simple_packet_ranges_adjust(const f_number_unsigned_t length, f_fss_simple_packet_ranges_t * const simple_packet_ranges) {
+#if !defined(_di_f_fss_simple_packet_ranges_append_) || !defined(_di_f_fss_simple_packet_rangess_append_)
+ extern f_status_t private_f_fss_simple_packet_ranges_append(const f_fss_simple_packet_range_t source, f_fss_simple_packet_ranges_t *destination) {
- const f_status_t status = f_memory_adjust(simple_packet_ranges->size, length, sizeof(f_fss_simple_packet_range_t), (void **) & simple_packet_ranges->array);
+ const f_status_t status = f_memory_array_increase(F_memory_default_allocation_small_d, sizeof(f_fss_simple_packet_range_t), (void **) &destination->array, &destination->used, &destination->size);
if (F_status_is_error(status)) return status;
- simple_packet_ranges->size = length;
-
- if (simple_packet_ranges->used > simple_packet_ranges->size) {
- simple_packet_ranges->used = length;
- }
+ destination->array[destination->used++] = source;
return F_none;
}
-#endif // !defined(_di_f_fss_simple_packet_ranges_adjust_) || !defined(_di_f_fss_simple_packet_ranges_decimate_by_)
+#endif // !defined(_di_f_fss_simple_packet_ranges_append_) || !defined(_di_f_fss_simple_packet_rangess_append_)
-#if !defined(_di_f_fss_simple_packet_ranges_decrease_by_) || !defined(_di_f_fss_simple_packet_ranges_increase_) || !defined(_di_f_fss_simple_packet_ranges_increase_by_) || !defined(_di_f_fss_simple_packet_ranges_resize_)
- f_status_t private_f_fss_simple_packet_ranges_resize(const f_number_unsigned_t length, f_fss_simple_packet_ranges_t * const simple_packet_ranges) {
+#if !defined(_di_f_fss_simple_packet_ranges_append_) || !defined(_di_f_fss_simple_packet_ranges_append_all_) || !defined(_di_f_fss_simple_packet_rangess_append_all_)
+ extern f_status_t private_f_fss_simple_packet_ranges_append_all(const f_fss_simple_packet_ranges_t source, f_fss_simple_packet_ranges_t *destination) {
- const f_status_t status = f_memory_resize(simple_packet_ranges->size, length, sizeof(f_fss_simple_packet_range_t), (void **) & simple_packet_ranges->array);
+ const f_status_t status = f_memory_array_increase_by(source.used, sizeof(f_fss_simple_packet_range_t), (void **) &destination->array, &destination->used, &destination->size);
if (F_status_is_error(status)) return status;
- simple_packet_ranges->size = length;
-
- if (simple_packet_ranges->used > simple_packet_ranges->size) {
- simple_packet_ranges->used = length;
- }
+ for (f_number_unsigned_t i = 0; i < source.used; ++i) {
+ destination->array[destination->used++] = source.array[i];
+ } // for
return F_none;
}
-#endif // !defined(_di_f_fss_simple_packet_ranges_decrease_by_) || !defined(_di_f_fss_simple_packet_ranges_increase_) || !defined(_di_f_fss_simple_packet_ranges_increase_by_) || !defined(_di_f_fss_simple_packet_ranges_resize_)
+#endif // !defined(_di_f_fss_simple_packet_ranges_append_) || !defined(_di_f_fss_simple_packet_ranges_append_all_) || !defined(_di_f_fss_simple_packet_rangess_append_all_)
+
+#if !defined(_di_f_fss_simple_packet_rangess_adjust_) || !defined(_di_f_fss_simple_packet_rangess_decimate_by_)
+ f_status_t private_f_fss_simple_packet_rangess_adjust(const f_number_unsigned_t length, f_fss_simple_packet_rangess_t *rangess) {
+
+ f_status_t status = F_none;
+
+ for (f_number_unsigned_t i = length; i < rangess->size; ++i) {
+
+ status = f_memory_array_adjust(0, sizeof(f_fss_simple_packet_range_t), (void **) &rangess->array[i].array, &rangess->array[i].used, &rangess->array[i].size);
+ if (F_status_is_error(status)) return status;
+ } // for
+
+ return f_memory_array_adjust(length, sizeof(f_fss_simple_packet_ranges_t), (void **) &rangess->array, &rangess->used, &rangess->size);
+ }
+#endif // !defined(_di_f_fss_simple_packet_rangess_adjust_) || !defined(_di_f_fss_simple_packet_rangess_decimate_by_)
+
+#if !defined(_di_f_fss_simple_packet_rangess_decrease_by_) || !defined(_di_f_fss_simple_packet_rangess_increase_) || !defined(_di_f_fss_simple_packet_rangess_increase_by_) || !defined(_di_f_fss_simple_packet_rangess_resize_)
+ f_status_t private_f_fss_simple_packet_rangess_resize(const f_number_unsigned_t length, f_fss_simple_packet_rangess_t *rangess) {
+
+ f_status_t status = F_none;
+
+ for (f_number_unsigned_t i = length; i < rangess->size; ++i) {
+
+ status = f_memory_array_resize(0, sizeof(f_fss_simple_packet_range_t), (void **) &rangess->array[i].array, &rangess->array[i].used, &rangess->array[i].size);
+ if (F_status_is_error(status)) return status;
+ } // for
+
+ return f_memory_array_resize(length, sizeof(f_fss_simple_packet_ranges_t), (void **) &rangess->array, &rangess->used, &rangess->size);
+ }
+#endif // !defined(_di_f_fss_simple_packet_rangess_decrease_by_) || !defined(_di_f_fss_simple_packet_rangess_increase_) || !defined(_di_f_fss_simple_packet_rangess_increase_by_) || !defined(_di_f_fss_simple_packet_rangess_resize_)
#ifdef __cplusplus
} // extern "C"
#endif
/**
- * Private implementation for resizing.
+ * Private implementation for appending the range array.
+ *
+ * Intended to be shared to each of the different implementation variations.
+ *
+ * @param source
+ * The source range to append.
+ * @param destination
+ * The destination lengths the source is appended onto.
+ *
+ * @return
+ * F_none on success.
+ *
+ * Errors (with error bit) from: f_memory_resize().
+ *
+ * @see f_memory_resize()
+ * @see f_fss_simple_packet_ranges_append()
+ * @see f_fss_simple_packet_rangess_append()
+ */
+#if !defined(_di_f_fss_simple_packet_ranges_append_) || !defined(_di_f_fss_simple_packet_rangess_append_)
+ extern f_status_t private_f_fss_simple_packet_ranges_append(const f_fss_simple_packet_range_t source, f_fss_simple_packet_ranges_t *destination) F_attribute_visibility_internal_d;
+#endif // !defined(_di_f_fss_simple_packet_ranges_append_) || !defined(_di_f_fss_simple_packet_rangess_append_)
+
+/**
+ * Private implementation for appending the range array.
+ *
+ * Intended to be shared to each of the different implementation variations.
+ *
+ * @param source
+ * The source ranges to append.
+ * @param destination
+ * The destination lengths the source is appended onto.
+ *
+ * @return
+ * F_none on success.
+ *
+ * Errors (with error bit) from: f_memory_resize().
+ *
+ * @see f_memory_resize()
+ * @see f_fss_simple_packet_ranges_append_all()
+ * @see f_fss_simple_packet_rangess_append()
+ * @see f_fss_simple_packet_rangess_append_all()
+ */
+#if !defined(_di_f_fss_simple_packet_ranges_append_) || !defined(_di_f_fss_simple_packet_ranges_append_all_) || !defined(_di_f_fss_simple_packet_rangess_append_all_)
+ extern f_status_t private_f_fss_simple_packet_ranges_append_all(const f_fss_simple_packet_ranges_t source, f_fss_simple_packet_ranges_t *destination) F_attribute_visibility_internal_d;
+#endif // !defined(_di_f_fss_simple_packet_ranges_append_) || !defined(_di_f_fss_simple_packet_ranges_append_all_) || !defined(_di_f_fss_simple_packet_rangess_append_all_)
+
+/**
+ * Private implementation for resizing the rangess array.
*
* Intended to be shared to each of the different implementation variations.
*
* @param length
- * The new size to use.
- * @param simple_packet_ranges
- * The simple_packet_ranges to adjust.
+ * The length to adjust to.
+ * @param rangess
+ * The rangess array to adjust.
*
* @return
* F_none on success.
+ * F_data_not on success, but there is no reason to increase size (used + 1 <= size).
*
- * Errors (with error bit) from: macro_f_string_rangess_t_adjust().
- * Errors (with error bit) from: macro_f_string_ranges_t_adjust().
- * Errors (with error bit) from: macro_f_uint8s_t_adjust().
- * Errors (with error bit) from: macro_f_uint8ss_t_adjust().
- * Errors (with error bit) from: f_memory_adjust().
+ * F_array_too_large (with error bit) if new length is larger than max array length.
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
*
- * @see macro_f_string_rangess_t_adjust()
- * @see macro_f_string_ranges_t_adjust()
- * @see macro_f_uint8s_t_adjust()
- * @see macro_f_uint8ss_t_adjust()
+ * Errors (with error bit) from: f_memory_adjust().
+ * Errors (with error bit) from: f_memory_destroy().
*
- * @see f_fss_simple_packet_ranges_adjust()
- * @see f_fss_simple_packet_ranges_decimate_by()
- * @see f_memory_adjust()
+ * @see f_fss_simple_packet_rangess_adjust()
+ * @see f_fss_simple_packet_rangess_decimate_by()
*/
-#if !defined(_di_f_fss_simple_packet_ranges_adjust_) || !defined(_di_f_fss_simple_packet_ranges_decimate_by_)
- extern f_status_t private_f_fss_simple_packet_ranges_adjust(const f_number_unsigned_t length, f_fss_simple_packet_ranges_t * const simple_packet_ranges) F_attribute_visibility_internal_d;
-#endif // !defined(_di_f_fss_simple_packet_ranges_adjust_) || !defined(_di_f_fss_simple_packet_ranges_decimate_by_)
+#if !defined(_di_f_fss_simple_packet_rangess_adjust_) || !defined(_di_f_fss_simple_packet_rangess_decimate_by_)
+ extern f_status_t private_f_fss_simple_packet_rangess_adjust(const f_number_unsigned_t length, f_fss_simple_packet_rangess_t *rangess) F_attribute_visibility_internal_d;
+#endif // !defined(_di_f_fss_simple_packet_rangess_adjust_) || !defined(_di_f_fss_simple_packet_rangess_decimate_by_)
/**
- * Private implementation for resizing.
+ * Private implementation for resizing the rangess array.
*
* Intended to be shared to each of the different implementation variations.
*
* @param length
- * The new size to use.
- * @param simple_packet_ranges
- * The simple_packet_ranges to resize.
+ * The length to resize to.
+ * @param rangess
+ * The rangess array to resize.
*
* @return
* F_none on success.
+ * F_data_not on success, but there is no reason to increase size (used + 1 <= size).
*
- * Errors (with error bit) from: macro_f_string_rangess_t_resize().
- * Errors (with error bit) from: macro_f_string_ranges_t_resize().
- * Errors (with error bit) from: macro_f_uint8s_t_resize().
- * Errors (with error bit) from: macro_f_uint8ss_t_resize().
- * Errors (with error bit) from: f_memory_resize().
+ * F_array_too_large (with error bit) if new length is larger than max array length.
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
*
- * @see macro_f_string_rangess_t_resize()
- * @see macro_f_string_ranges_t_resize()
- * @see macro_f_uint8s_t_resize()
- * @see macro_f_uint8ss_t_resize()
+ * Errors (with error bit) from: f_memory_delete().
+ * Errors (with error bit) from: f_memory_resize().
*
- * @see f_fss_simple_packet_ranges_decrease_by()
- * @see f_fss_simple_packet_ranges_increase()
- * @see f_fss_simple_packet_ranges_increase_by()
- * @see f_fss_simple_packet_ranges_resize()
- * @see f_memory_resize()
+ * @see f_fss_simple_packet_rangess_decrease_by()
+ * @see f_fss_simple_packet_rangess_increase()
+ * @see f_fss_simple_packet_rangess_increase_by()
+ * @see f_fss_simple_packet_rangess_resize()
*/
-#if !defined(_di_f_fss_simple_packet_ranges_decrease_by_) || !defined(_di_f_fss_simple_packet_ranges_increase_) || !defined(_di_f_fss_simple_packet_ranges_increase_by_) || !defined(_di_f_fss_simple_packet_ranges_resize_)
- extern f_status_t private_f_fss_simple_packet_ranges_resize(const f_number_unsigned_t length, f_fss_simple_packet_ranges_t * const simple_packet_ranges) F_attribute_visibility_internal_d;
-#endif // !defined(_di_f_fss_simple_packet_ranges_decrease_by_) || !defined(_di_f_fss_simple_packet_ranges_increase_) || !defined(_di_f_fss_simple_packet_ranges_increase_by_) || !defined(_di_f_fss_simple_packet_ranges_resize_)
+#if !defined(_di_f_fss_simple_packet_rangess_decrease_by_) || !defined(_di_f_fss_simple_packet_rangess_increase_) || !defined(_di_f_fss_simple_packet_rangess_increase_by_) || !defined(_di_f_fss_simple_packet_rangess_resize_)
+ extern f_status_t private_f_fss_simple_packet_rangess_resize(const f_number_unsigned_t length, f_fss_simple_packet_rangess_t *rangess) F_attribute_visibility_internal_d;
+#endif // !defined(_di_f_fss_simple_packet_rangess_decrease_by_) || !defined(_di_f_fss_simple_packet_rangess_increase_) || !defined(_di_f_fss_simple_packet_rangess_increase_by_) || !defined(_di_f_fss_simple_packet_rangess_resize_)
#ifdef __cplusplus
} // extern "C"
#endif // _di_f_fss_simple_packet_identify_
#ifndef _di_f_fss_simple_packet_ranges_adjust_
- f_status_t f_fss_simple_packet_ranges_adjust(const f_number_unsigned_t length, f_fss_simple_packet_ranges_t * const simple_packet_ranges) {
+ f_status_t f_fss_simple_packet_ranges_adjust(const f_number_unsigned_t length, f_fss_simple_packet_ranges_t *ranges) {
#ifndef _di_level_0_parameter_checking_
- if (!simple_packet_ranges) return F_status_set_error(F_parameter);
+ if (!ranges) return F_status_set_error(F_parameter);
#endif // _di_level_0_parameter_checking_
- return private_f_fss_simple_packet_ranges_adjust(length, simple_packet_ranges);
+ return f_memory_array_adjust(length, sizeof(f_fss_simple_packet_range_t), (void **) &ranges->array, &ranges->used, &ranges->size);
}
#endif // _di_f_fss_simple_packet_ranges_adjust_
-#ifndef _di_f_fss_simple_packet_ranges_decimate_by_
- f_status_t f_fss_simple_packet_ranges_decimate_by(const f_number_unsigned_t amount, f_fss_simple_packet_ranges_t * const simple_packet_ranges) {
+#ifndef _di_f_fss_simple_packet_ranges_append_
+ f_status_t f_fss_simple_packet_ranges_append(const f_fss_simple_packet_range_t source, f_fss_simple_packet_ranges_t *destination) {
#ifndef _di_level_0_parameter_checking_
- if (!simple_packet_ranges) return F_status_set_error(F_parameter);
+ if (!destination) return F_status_set_error(F_parameter);
#endif // _di_level_0_parameter_checking_
- if (!amount) return F_data_not;
- if (simple_packet_ranges->size > amount) return private_f_fss_simple_packet_ranges_adjust(simple_packet_ranges->size - amount, simple_packet_ranges);
+ return private_f_fss_simple_packet_ranges_append(source, destination);
+ }
+#endif // _di_f_fss_simple_packet_ranges_append_
+
+#ifndef _di_f_fss_simple_packet_ranges_append_all_
+ f_status_t f_fss_simple_packet_ranges_append_all(const f_fss_simple_packet_ranges_t source, f_fss_simple_packet_ranges_t *destination) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!destination) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ if (!source.used) return F_data_not;
- return private_f_fss_simple_packet_ranges_adjust(0, simple_packet_ranges);
+ return private_f_fss_simple_packet_ranges_append_all(source, destination);
+ }
+#endif // _di_f_fss_simple_packet_ranges_append_all_
+
+#ifndef _di_f_fss_simple_packet_ranges_decimate_by_
+ f_status_t f_fss_simple_packet_ranges_decimate_by(const f_number_unsigned_t amount, f_fss_simple_packet_ranges_t *ranges) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!ranges) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ return f_memory_array_decimate_by(amount, sizeof(f_fss_simple_packet_range_t), (void **) &ranges->array, &ranges->used, &ranges->size);
}
#endif // _di_f_fss_simple_packet_ranges_decimate_by_
#ifndef _di_f_fss_simple_packet_ranges_decrease_by_
- f_status_t f_fss_simple_packet_ranges_decrease_by(const f_number_unsigned_t amount, f_fss_simple_packet_ranges_t * const simple_packet_ranges) {
+ f_status_t f_fss_simple_packet_ranges_decrease_by(const f_number_unsigned_t amount, f_fss_simple_packet_ranges_t *ranges) {
#ifndef _di_level_0_parameter_checking_
- if (!simple_packet_ranges) 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 (simple_packet_ranges->size > amount) return private_f_fss_simple_packet_ranges_resize(simple_packet_ranges->size - amount, simple_packet_ranges);
-
- return private_f_fss_simple_packet_ranges_resize(0, simple_packet_ranges);
+ return f_memory_array_decrease_by(amount, sizeof(f_fss_simple_packet_range_t), (void **) &ranges->array, &ranges->used, &ranges->size);
}
#endif // _di_f_fss_simple_packet_ranges_decrease_by_
#ifndef _di_f_fss_simple_packet_ranges_increase_
- f_status_t f_fss_simple_packet_ranges_increase(const f_number_unsigned_t step, f_fss_simple_packet_ranges_t * const simple_packet_ranges) {
+ f_status_t f_fss_simple_packet_ranges_increase(const f_number_unsigned_t step, f_fss_simple_packet_ranges_t *ranges) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!ranges) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ return f_memory_array_increase(step, sizeof(f_fss_simple_packet_range_t), (void **) &ranges->array, &ranges->used, &ranges->size);
+ }
+#endif // _di_f_fss_simple_packet_ranges_increase_
+
+#ifndef _di_f_fss_simple_packet_ranges_increase_by_
+ f_status_t f_fss_simple_packet_ranges_increase_by(const f_number_unsigned_t amount, f_fss_simple_packet_ranges_t *ranges) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!ranges) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ return f_memory_array_increase_by(amount, sizeof(f_fss_simple_packet_range_t), (void **) &ranges->array, &ranges->used, &ranges->size);
+ }
+#endif // _di_f_fss_simple_packet_ranges_increase_by_
+
+#ifndef _di_f_fss_simple_packet_ranges_resize_
+ f_status_t f_fss_simple_packet_ranges_resize(const f_number_unsigned_t length, f_fss_simple_packet_ranges_t *ranges) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!ranges) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ return f_memory_array_resize(length, sizeof(f_fss_simple_packet_range_t), (void **) &ranges->array, &ranges->used, &ranges->size);
+ }
+#endif // _di_f_fss_simple_packet_ranges_resize_
+
+#ifndef _di_f_fss_simple_packet_rangess_adjust_
+ f_status_t f_fss_simple_packet_rangess_adjust(const f_number_unsigned_t length, f_fss_simple_packet_rangess_t *rangess) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!rangess) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ return private_f_fss_simple_packet_rangess_adjust(length, rangess);
+ }
+#endif // _di_f_fss_simple_packet_rangess_adjust_
+
+#ifndef _di_f_fss_simple_packet_rangess_append_
+ f_status_t f_fss_simple_packet_rangess_append(const f_fss_simple_packet_ranges_t source, f_fss_simple_packet_rangess_t *destination) {
#ifndef _di_level_0_parameter_checking_
- if (!simple_packet_ranges) return F_status_set_error(F_parameter);
+ if (!destination) return F_status_set_error(F_parameter);
#endif // _di_level_0_parameter_checking_
- if (step && simple_packet_ranges->used + 1 > simple_packet_ranges->size) {
- f_number_unsigned_t size = simple_packet_ranges->used + step;
+ if (!source.used) return F_data_not;
+
+ f_status_t status = f_memory_array_increase(F_memory_default_allocation_small_d, sizeof(f_fss_simple_packet_ranges_t), (void **) &destination->array, &destination->used, &destination->size);
+ if (F_status_is_error(status)) return status;
+
+ status = private_f_fss_simple_packet_ranges_append_all(source, &destination->array[destination->used]);
+ if (F_status_is_error(status)) return status;
- if (size > F_number_t_size_unsigned_d) {
- if (simple_packet_ranges->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large);
+ ++destination->used;
- size = F_number_t_size_unsigned_d;
+ return F_none;
+ }
+#endif // _di_f_fss_simple_packet_rangess_append_
+
+#ifndef _di_f_fss_simple_packet_rangess_append_all_
+ f_status_t f_fss_simple_packet_rangess_append_all(const f_fss_simple_packet_rangess_t source, f_fss_simple_packet_rangess_t *destination) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!destination) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ if (!source.used) return F_data_not;
+
+ f_status_t status = f_memory_array_increase(source.used, sizeof(f_fss_simple_packet_ranges_t), (void **) &destination->array, &destination->used, &destination->size);
+ if (F_status_is_error(status)) return status;
+
+ for (f_number_unsigned_t i = 0; i < source.used; ++i, ++destination->used) {
+
+ destination->array[destination->used].used = 0;
+
+ if (source.array[i].used) {
+ status = private_f_fss_simple_packet_ranges_append_all(source.array[i], &destination->array[destination->used]);
+ if (F_status_is_error(status)) return status;
}
+ } // for
- return private_f_fss_simple_packet_ranges_resize(size, simple_packet_ranges);
- }
+ return F_none;
+ }
+#endif // _di_f_fss_simple_packet_rangess_append_all_
- return F_data_not;
+#ifndef _di_f_fss_simple_packet_rangess_decimate_by_
+ f_status_t f_fss_simple_packet_rangess_decimate_by(const f_number_unsigned_t amount, f_fss_simple_packet_rangess_t *rangess) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!rangess) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ if (!amount) return F_data_not;
+
+ return private_f_fss_simple_packet_rangess_adjust((rangess->size > amount) ? rangess->size - amount : 0, rangess);
}
-#endif // _di_f_fss_simple_packet_ranges_increase_
+#endif // _di_f_fss_simple_packet_rangess_decimate_by_
-#ifndef _di_f_fss_simple_packet_ranges_increase_by_
- f_status_t f_fss_simple_packet_ranges_increase_by(const f_number_unsigned_t amount, f_fss_simple_packet_ranges_t * const simple_packet_ranges) {
+#ifndef _di_f_fss_simple_packet_rangess_decrease_by_
+ f_status_t f_fss_simple_packet_rangess_decrease_by(const f_number_unsigned_t amount, f_fss_simple_packet_rangess_t *rangess) {
#ifndef _di_level_0_parameter_checking_
- if (!simple_packet_ranges) 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 (simple_packet_ranges->used + amount > simple_packet_ranges->size) {
- if (simple_packet_ranges->used + amount > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large);
+ return private_f_fss_simple_packet_rangess_resize((rangess->size > amount) ? rangess->size - amount : 0, rangess);
+ }
+#endif // _di_f_fss_simple_packet_rangess_decrease_by_
- return private_f_fss_simple_packet_ranges_resize(simple_packet_ranges->used + amount, simple_packet_ranges);
- }
+#ifndef _di_f_fss_simple_packet_rangess_increase_
+ f_status_t f_fss_simple_packet_rangess_increase(const f_number_unsigned_t step, f_fss_simple_packet_rangess_t *rangess) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!rangess) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
- return F_data_not;
+ return f_memory_array_increase(step, sizeof(f_fss_simple_packet_ranges_t), (void **) &rangess->array, &rangess->used, &rangess->size);
}
-#endif // _di_f_fss_simple_packet_ranges_increase_by_
+#endif // _di_f_fss_simple_packet_rangess_increase_
-#ifndef _di_f_fss_simple_packet_ranges_resize_
- f_status_t f_fss_simple_packet_ranges_resize(const f_number_unsigned_t length, f_fss_simple_packet_ranges_t * const simple_packet_ranges) {
+#ifndef _di_f_fss_simple_packet_rangess_increase_by_
+ f_status_t f_fss_simple_packet_rangess_increase_by(const f_number_unsigned_t amount, f_fss_simple_packet_rangess_t *rangess) {
#ifndef _di_level_0_parameter_checking_
- if (!simple_packet_ranges) return F_status_set_error(F_parameter);
+ if (!rangess) return F_status_set_error(F_parameter);
#endif // _di_level_0_parameter_checking_
- return private_f_fss_simple_packet_ranges_resize(length, simple_packet_ranges);
+ return f_memory_array_increase_by(amount, sizeof(f_fss_simple_packet_ranges_t), (void **) &rangess->array, &rangess->used, &rangess->size);
}
-#endif // _di_f_fss_simple_packet_ranges_resize_
+#endif // _di_f_fss_simple_packet_rangess_increase_by_
+
+#ifndef _di_f_fss_simple_packet_rangess_resize_
+ f_status_t f_fss_simple_packet_rangess_resize(const f_number_unsigned_t length, f_fss_simple_packet_rangess_t *rangess) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!rangess) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ return private_f_fss_simple_packet_rangess_resize(length, rangess);
+ }
+#endif // _di_f_fss_simple_packet_rangess_resize_
#ifdef __cplusplus
} // extern "C"
#endif // _di_f_fss_simple_packet_ranges_t_
/**
+ * This holds an array of f_fss_simple_packet_ranges_t.
+ *
+ * Properties:
+ * - array: An array of f_fss_simple_packet_ranges_t.
+ * - size: Total amount of allocated space.
+ * - used: Total number of allocated spaces used.
+ */
+#ifndef _di_f_fss_simple_packet_rangess_t_
+ typedef struct {
+ f_fss_simple_packet_ranges_t *array;
+
+ f_number_unsigned_t size;
+ f_number_unsigned_t used;
+ } f_fss_simple_packet_rangess_t;
+
+ #define f_fss_simple_packet_rangess_t_initialize { 0, 0, 0 }
+
+ #define macro_f_fss_simple_packet_rangess_t_initialize_1(array, size, used) { array, size, used }
+ #define macro_f_fss_simple_packet_rangess_t_initialize_2(array, length) { array, length, length }
+
+ #define macro_f_fss_simple_packet_rangess_t_clear(simple_packet_rangess) macro_f_memory_structure_t_clear(simple_packet_ranges.objects)
+
+ #define macro_f_fss_simple_packet_rangess_t_resize(status, simple_packet_rangess, length) status = f_fss_simple_packet_rangess_resize(length, &simple_packet_rangess);
+ #define macro_f_fss_simple_packet_rangess_t_adjust(status, simple_packet_rangess, length) status = f_fss_simple_packet_rangess_adjust(length, &simple_packet_rangess);
+
+ #define macro_f_fss_simple_packet_rangess_t_delete_simple(simple_packet_rangess) f_fss_simple_packet_rangess_resize(0, &simple_packet_rangess);
+ #define macro_f_fss_simple_packet_rangess_t_destroy_simple(simple_packet_rangess) f_fss_simple_packet_rangess_adjust(0, &simple_packet_rangess);
+
+ #define macro_f_fss_simple_packet_rangess_t_increase(status, step, simple_packet_rangess) status = f_fss_simple_packet_rangess_increase(step, &simple_packet_rangess);
+ #define macro_f_fss_simple_packet_rangess_t_increase_by(status, simple_packet_rangess, amount) status = f_fss_simple_packet_rangess_increase_by(amount, &simple_packet_rangess);
+ #define macro_f_fss_simple_packet_rangess_t_decrease_by(status, simple_packet_rangess, amount) status = f_fss_simple_packet_rangess_decrease_by(amount, &simple_packet_rangess);
+ #define macro_f_fss_simple_packet_rangess_t_decimate_by(status, simple_packet_rangess, amount) status = f_fss_simple_packet_rangess_decimate_by(amount, &simple_packet_rangess);
+#endif // _di_f_fss_simple_packet_rangess_t_
+
+/**
* Identify the ranges representing the different parts of the FSS-000F (Simple Packet).
*
* @param buffer
#endif // _di_f_fss_simple_packet_identify_
/**
- * Resize the simple_packet_range array.
+ * Resize the ranges array.
*
* @param length
* The new size to use.
- * @param simple_packet_ranges
- * The simple_packet_ranges array to resize.
+ * @param ranges
+ * The ranges array to resize.
*
* @return
- * F_none on success.
+ * Success from f_memory_array_resize().
*
- * F_memory_not (with error bit) on out of memory.
* F_parameter (with error bit) if a parameter is invalid.
+ *
+ * Errors (with error bit) from: f_memory_array_resize().
+ *
+ * @see f_memory_array_resize()
*/
#ifndef _di_f_fss_simple_packet_ranges_adjust_
- extern f_status_t f_fss_simple_packet_ranges_adjust(const f_number_unsigned_t length, f_fss_simple_packet_ranges_t * const simple_packet_ranges);
+ extern f_status_t f_fss_simple_packet_ranges_adjust(const f_number_unsigned_t length, f_fss_simple_packet_ranges_t *ranges);
#endif // _di_f_fss_simple_packet_ranges_adjust_
/**
- * Resize the simple_packet_range array to a smaller size.
+ * Append the single source range onto the destination.
+ *
+ * @param source
+ * The source range to append.
+ * @param destination
+ * The destination ranges the source is appended onto.
+ *
+ * @return
+ * F_none on success.
+ * F_data_not on success, but there is nothing to append (size == 0).
+ *
+ * Success from f_memory_array_resize().
+ *
+ * F_parameter (with error bit) if a parameter is invalid.
+ *
+ * Errors (with error bit) from: f_memory_array_increase_by().
+ * Errors (with error bit) from: f_memory_array_resize().
+ *
+ * @see f_memory_array_increase_by()
+ * @see f_memory_array_resize()
+ */
+#ifndef _di_f_fss_simple_packet_ranges_append_
+ extern f_status_t f_fss_simple_packet_ranges_append(const f_fss_simple_packet_range_t source, f_fss_simple_packet_ranges_t *destination);
+#endif // _di_f_fss_simple_packet_ranges_append_
+
+/**
+ * Append the source ranges onto the destination.
+ *
+ * @param source
+ * The source ranges to append.
+ * @param destination
+ * The destination ranges the source is appended onto.
+ *
+ * @return
+ * F_none on success.
+ * F_data_not on success, but there is nothing to append (size == 0).
+ *
+ * Success from f_memory_array_resize().
+ *
+ * F_parameter (with error bit) if a parameter is invalid.
+ *
+ * Errors (with error bit) from: f_memory_array_increase_by().
+ * Errors (with error bit) from: f_memory_array_resize().
+ *
+ * @see f_memory_array_increase_by()
+ * @see f_memory_array_resize()
+ */
+#ifndef _di_f_fss_simple_packet_ranges_append_all_
+ extern f_status_t f_fss_simple_packet_ranges_append_all(const f_fss_simple_packet_ranges_t source, f_fss_simple_packet_ranges_t *destination);
+#endif // _di_f_fss_simple_packet_ranges_append_all_
+
+/**
+ * Resize the ranges 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.
+ * This will not shrink the size to les than 0.
*
* @param amount
* A positive number representing how much to decimate the size by.
- * @param simple_packet_ranges
- * The simple_packet_ranges array to resize.
+ * @param ranges
+ * The ranges array to resize.
*
* @return
- * F_none on success.
+ * @return
+ * Success from f_memory_array_decimate_by().
*
- * F_memory_not (with error bit) on out of memory.
* F_parameter (with error bit) if a parameter is invalid.
+ *
+ * Errors (with error bit) from: f_memory_array_decimate_by().
+ *
+ * @see f_memory_array_decimate_by()
*/
#ifndef _di_f_fss_simple_packet_ranges_decimate_by_
- extern f_status_t f_fss_simple_packet_ranges_decimate_by(const f_number_unsigned_t amount, f_fss_simple_packet_ranges_t * const simple_packet_ranges);
+ extern f_status_t f_fss_simple_packet_ranges_decimate_by(const f_number_unsigned_t amount, f_fss_simple_packet_ranges_t *ranges);
#endif // _di_f_fss_simple_packet_ranges_decimate_by_
/**
- * Resize the simple_packet_range array to a smaller size.
+ * Resize the ranges 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.
+ * This will not shrink the size to les than 0.
*
* @param amount
* A positive number representing how much to decrease the size by.
- * @param simple_packet_ranges
- * The simple_packet_ranges array to resize.
+ * @param ranges
+ * The ranges array to resize.
*
* @return
- * F_none on success.
+ * Success from f_memory_array_decrease_by().
*
- * F_memory_not (with error bit) on out of memory.
* F_parameter (with error bit) if a parameter is invalid.
+ *
+ * Errors (with error bit) from: f_memory_array_decrease_by().
+ *
+ * @see f_memory_array_decrease_by()
*/
#ifndef _di_f_fss_simple_packet_ranges_decrease_by_
- extern f_status_t f_fss_simple_packet_ranges_decrease_by(const f_number_unsigned_t amount, f_fss_simple_packet_ranges_t * const simple_packet_ranges);
+ extern f_status_t f_fss_simple_packet_ranges_decrease_by(const f_number_unsigned_t amount, f_fss_simple_packet_ranges_t *ranges);
#endif // _di_f_fss_simple_packet_ranges_decrease_by_
/**
- * Increase the size of the simple_packet_ranges array, but only if necessary.
+ * Increase the size of the ranges array, but only if necesary.
*
- * If the given length is too large for the buffer, then attempt to set max buffer size (F_number_t_size_unsigned_d).
- * If already set to the maximum buffer size, then the resize will fail.
+ * If the given length is too large for the buffer, then attempt to range max buffer size (F_number_t_size_unsigned_d).
+ * If already range to the maximum buffer size, then the resize will fail.
*
* @param step
* The allocation step to use.
* Must be greater than 0.
- * @param simple_packet_ranges
- * The simple_packet_ranges array to resize.
+ * @param ranges
+ * The ranges array to resize.
*
* @return
- * F_none on success.
- * F_data_not on success, but there is no reason to increase size (used + 1 <= size).
+ * Success from f_memory_array_increase().
*
- * F_array_too_large (with error bit) if the new array length is too large.
- * F_memory_not (with error bit) on out of memory.
* F_parameter (with error bit) if a parameter is invalid.
+ *
+ * Errors (with error bit) from: f_memory_array_increase().
+ *
+ * @see f_memory_array_increase()
*/
#ifndef _di_f_fss_simple_packet_ranges_increase_
- extern f_status_t f_fss_simple_packet_ranges_increase(const f_number_unsigned_t step, f_fss_simple_packet_ranges_t * const simple_packet_ranges);
+ extern f_status_t f_fss_simple_packet_ranges_increase(const f_number_unsigned_t step, f_fss_simple_packet_ranges_t *ranges);
#endif // _di_f_fss_simple_packet_ranges_increase_
/**
- * Resize the simple_packet_ranges array to a larger size.
+ * Resize the ranges array to a larger size.
*
* This will resize making the array larger based on the given length.
- * If the given length is too large for the buffer, then attempt to set max buffer size (F_number_t_size_unsigned_d).
- * If already set to the maximum buffer size, then the resize will fail.
+ * If the given length is too large for the buffer, then attempt to range max buffer size (F_number_t_size_unsigned_d).
+ * If already range to the maximum buffer size, then the resize will fail.
*
* @param amount
* A positive number representing how much to increase the size by.
- * @param simple_packet_ranges
- * The simple_packet_ranges array to resize.
+ * @param ranges
+ * The ranges array to resize.
*
* @return
- * F_none on success.
- * F_data_not on success, but there is no reason to increase size (used + amount <= size).
+ * Success from f_memory_array_increase_by().
*
- * F_memory_not (with error bit) on out of memory.
* F_parameter (with error bit) if a parameter is invalid.
- * F_array_too_large (with error bit) if the new array length is too large.
+ *
+ * Errors (with error bit) from: f_memory_array_increase_by().
+ *
+ * @see f_memory_array_increase_by()
*/
#ifndef _di_f_fss_simple_packet_ranges_increase_by_
- extern f_status_t f_fss_simple_packet_ranges_increase_by(const f_number_unsigned_t amount, f_fss_simple_packet_ranges_t * const simple_packet_ranges);
+ extern f_status_t f_fss_simple_packet_ranges_increase_by(const f_number_unsigned_t amount, f_fss_simple_packet_ranges_t *ranges);
#endif // _di_f_fss_simple_packet_ranges_increase_by_
/**
- * Resize the simple_packet_ranges array.
+ * Resize the ranges array.
*
* @param length
* The new size to use.
- * @param simple_packet_ranges
- * The simple_packet_ranges array to adjust.
+ * @param ranges
+ * The ranges array to adjust.
*
* @return
- * F_none on success.
+ * Success from f_memory_array_resize().
*
- * F_memory_not (with error bit) on out of memory.
* F_parameter (with error bit) if a parameter is invalid.
+ *
+ * Errors (with error bit) from: f_memory_array_resize().
+ *
+ * @see f_memory_array_resize()
*/
#ifndef _di_f_fss_simple_packet_ranges_resize_
- extern f_status_t f_fss_simple_packet_ranges_resize(const f_number_unsigned_t length, f_fss_simple_packet_ranges_t * const simple_packet_ranges);
+ extern f_status_t f_fss_simple_packet_ranges_resize(const f_number_unsigned_t length, f_fss_simple_packet_ranges_t *ranges);
#endif // _di_f_fss_simple_packet_ranges_resize_
+/**
+ * Resize the rangess array.
+ *
+ * @param length
+ * The new size to use.
+ * @param rangess
+ * The rangess array to resize.
+ *
+ * @return
+ * Success from f_memory_array_adjust().
+ *
+ * F_parameter (with error bit) if a parameter is invalid.
+ *
+ * Errors (with error bit) from: f_memory_array_adjust().
+ *
+ * @see f_memory_array_adjust()
+ */
+#ifndef _di_f_fss_simple_packet_rangess_adjust_
+ extern f_status_t f_fss_simple_packet_rangess_adjust(const f_number_unsigned_t length, f_fss_simple_packet_rangess_t *rangess);
+#endif // _di_f_fss_simple_packet_rangess_adjust_
+
+/**
+ * Append the single source ranges onto the destination.
+ *
+ * @param source
+ * The source ranges to append.
+ * @param destination
+ * The destination ranges the source is appended onto.
+ *
+ * @return
+ * F_none on success.
+ * F_data_not on success, but there is nothing to append (size == 0).
+ *
+ * Success from f_memory_array_resize().
+ *
+ * F_parameter (with error bit) if a parameter is invalid.
+ *
+ * Errors (with error bit) from: f_memory_array_increase_by().
+ * Errors (with error bit) from: f_memory_array_resize().
+ *
+ * @see f_memory_array_increase_by()
+ * @see f_memory_array_resize()
+ */
+#ifndef _di_f_fss_simple_packet_rangess_append_
+ extern f_status_t f_fss_simple_packet_rangess_append(const f_fss_simple_packet_ranges_t source, f_fss_simple_packet_rangess_t *destination);
+#endif // _di_f_fss_simple_packet_rangess_append_
+
+/**
+ * Append the source rangess onto the destination.
+ *
+ * @param source
+ * The source rangess to append.
+ * @param destination
+ * The destination ranges the source is appended onto.
+ *
+ * @return
+ * F_none on success.
+ * F_data_not on success, but there is nothing to append (size == 0).
+ *
+ * Success from f_memory_array_resize().
+ *
+ * F_parameter (with error bit) if a parameter is invalid.
+ *
+ * Errors (with error bit) from: f_memory_array_increase_by().
+ * Errors (with error bit) from: f_memory_array_resize().
+ *
+ * @see f_memory_array_increase_by()
+ * @see f_memory_array_resize()
+ */
+#ifndef _di_f_fss_simple_packet_rangess_append_all_
+ extern f_status_t f_fss_simple_packet_rangess_append_all(const f_fss_simple_packet_rangess_t source, f_fss_simple_packet_rangess_t *destination);
+#endif // _di_f_fss_simple_packet_rangess_append_all_
+
+/**
+ * Resize the rangess 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 rangess
+ * The rangess array to resize.
+ *
+ * @return
+ * F_data_not on success, but the amount to decrease by is 0.
+ *
+ * Success from f_memory_array_decimate_by().
+ *
+ * F_parameter (with error bit) if a parameter is invalid.
+ *
+ * Errors (with error bit) from: f_memory_array_decimate_by().
+ *
+ * @see f_memory_array_decimate_by()
+ */
+#ifndef _di_f_fss_simple_packet_rangess_decimate_by_
+ extern f_status_t f_fss_simple_packet_rangess_decimate_by(const f_number_unsigned_t amount, f_fss_simple_packet_rangess_t *rangess);
+#endif // _di_f_fss_simple_packet_rangess_decimate_by_
+
+/**
+ * Resize the rangess 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 rangess
+ * The rangess array to resize.
+ *
+ * @return
+ * F_data_not on success, but the amount to decrease by is 0.
+ *
+ * Success from f_memory_array_decrease_by().
+ *
+ * F_parameter (with error bit) if a parameter is invalid.
+ *
+ * Errors (with error bit) from: f_memory_array_decrease_by().
+ *
+ * @see f_memory_array_decrease_by()
+ */
+#ifndef _di_f_fss_simple_packet_rangess_decrease_by_
+ extern f_status_t f_fss_simple_packet_rangess_decrease_by(const f_number_unsigned_t amount, f_fss_simple_packet_rangess_t *rangess);
+#endif // _di_f_fss_simple_packet_rangess_decrease_by_
+
+/**
+ * Increase the size of the rangess array, but only if necessary.
+ *
+ * If the given length is too large for the buffer, then attempt to range max buffer size (F_number_t_size_unsigned_d).
+ * If already range to the maximum buffer size, then the resize will fail.
+ *
+ * @param step
+ * The allocation step to use.
+ * Must be greater than 0.
+ * @param rangess
+ * The rangess array to resize.
+ *
+ * @return
+ * Success from f_memory_array_increase().
+ *
+ * F_parameter (with error bit) if a parameter is invalid.
+ *
+ * Errors (with error bit) from: f_memory_array_increase().
+ *
+ * @see f_memory_array_increase()
+ */
+#ifndef _di_f_fss_simple_packet_rangess_increase_
+ extern f_status_t f_fss_simple_packet_rangess_increase(const f_number_unsigned_t step, f_fss_simple_packet_rangess_t *rangess);
+#endif // _di_f_fss_simple_packet_rangess_increase_
+
+/**
+ * Resize the rangess array to a larger size.
+ *
+ * This will resize making the array larger based on the given length.
+ * If the given length is too large for the buffer, then attempt to range max buffer size (F_number_t_size_unsigned_d).
+ * If already range to the maximum buffer size, then the resize will fail.
+ *
+ * @param amount
+ * A positive number representing how much to increase the size by.
+ * @param rangess
+ * The rangess array to resize.
+ *
+ * @return
+ * Success from f_memory_array_increase_by().
+ *
+ * F_parameter (with error bit) if a parameter is invalid.
+ *
+ * Errors (with error bit) from: f_memory_array_increase_by().
+ *
+ * @see f_memory_array_increase_by()
+ */
+#ifndef _di_f_fss_simple_packet_rangess_increase_by_
+ extern f_status_t f_fss_simple_packet_rangess_increase_by(const f_number_unsigned_t amount, f_fss_simple_packet_rangess_t *rangess);
+#endif // _di_f_fss_simple_packet_rangess_increase_by_
+
+/**
+ * Resize the rangess array.
+ *
+ * @param length
+ * The new size to use.
+ * @param rangess
+ * The rangess array to adjust.
+ *
+ * @return
+ * Success from f_memory_array_resize().
+ *
+ * F_parameter (with error bit) if a parameter is invalid.
+ *
+ * Errors (with error bit) from: f_memory_array_resize().
+ *
+ * @see f_memory_array_resize()
+ */
+#ifndef _di_f_fss_simple_packet_rangess_resize_
+ extern f_status_t f_fss_simple_packet_rangess_resize(const f_number_unsigned_t length, f_fss_simple_packet_rangess_t *rangess);
+#endif // _di_f_fss_simple_packet_rangess_resize_
+
#ifdef __cplusplus
} // extern "C"
#endif
+++ /dev/null
-#include "fss.h"
-#include "private-fss.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
+++ /dev/null
-/**
- * FLL - Level 0
- *
- * Project: FSS
- * API Version: 0.7
- * Licenses: lgpl-2.1-or-later
- *
- * These are provided for internal reduction in redundant code.
- * These should not be exposed/used outside of this project.
- */
-#ifndef _PRIVATE_F_fss_h
-#define _PRIVATE_F_fss_h
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif // _PRIVATE_F_fss_h
extern "C" {
#endif
-#if !defined(_di_f_limit_sets_adjust_) || !defined(_di_f_limit_sets_decimate_by_)
- f_status_t private_f_limit_sets_adjust(const f_number_unsigned_t length, f_limit_sets_t *sets) {
-
- const f_status_t status = f_memory_adjust(sets->size, length, sizeof(f_limit_set_t), (void **) & sets->array);
- if (F_status_is_error(status)) return status;
-
- sets->size = length;
-
- if (sets->used > sets->size) {
- sets->used = length;
- }
-
- return F_none;
- }
-#endif // !defined(_di_f_limit_sets_adjust_) || !defined(_di_f_limit_sets_decimate_by_)
-
#if !defined(_di_f_limit_sets_append_) || !defined(_di_f_limit_setss_append_)
extern f_status_t private_f_limit_sets_append(const f_limit_set_t source, f_limit_sets_t *destination) {
- if (destination->used + 1 > destination->size) {
- const f_status_t status = private_f_limit_sets_resize(destination->used + F_memory_default_allocation_small_d, destination);
- if (F_status_is_error(status)) return status;
- }
+ const f_status_t status = f_memory_array_increase(F_memory_default_allocation_small_d, sizeof(f_limit_set_t), (void **) &destination->array, &destination->used, &destination->size);
+ if (F_status_is_error(status)) return status;
destination->array[destination->used++] = source;
#if !defined(_di_f_limit_sets_append_) || !defined(_di_f_limit_sets_append_all_) || !defined(_di_f_limit_setss_append_all_)
extern f_status_t private_f_limit_sets_append_all(const f_limit_sets_t source, f_limit_sets_t *destination) {
- if (destination->used + source.used > destination->size) {
- const f_status_t status = private_f_limit_sets_resize(destination->used + source.used, destination);
- if (F_status_is_error(status)) return status;
- }
+ const f_status_t status = f_memory_array_increase_by(source.used, sizeof(f_limit_set_t), (void **) &destination->array, &destination->used, &destination->size);
+ if (F_status_is_error(status)) return status;
for (f_number_unsigned_t i = 0; i < source.used; ++i) {
destination->array[destination->used++] = source.array[i];
}
#endif // !defined(_di_f_limit_sets_append_) || !defined(_di_f_limit_sets_append_all_) || !defined(_di_f_limit_setss_append_all_)
-#if !defined(_di_f_limit_sets_resize_) || !defined(_di_f_limit_sets_append_) || !defined(_di_f_limit_sets_decimate_by_) || !defined(_di_f_limit_setss_append_)
- f_status_t private_f_limit_sets_resize(const f_number_unsigned_t length, f_limit_sets_t *sets) {
-
- const f_status_t status = f_memory_resize(sets->size, length, sizeof(f_limit_set_t), (void **) & sets->array);
- if (F_status_is_error(status)) return status;
-
- sets->size = length;
-
- if (sets->used > sets->size) {
- sets->used = length;
- }
-
- return F_none;
- }
-#endif // !defined(_di_f_limit_sets_resize_) || !defined(_di_f_limit_sets_append_) || !defined(_di_f_limit_sets_decimate_by_) || !defined(_di_f_limit_setss_append_)
-
#if !defined(_di_f_limit_setss_adjust_) || !defined(_di_f_limit_setss_decimate_by_)
f_status_t private_f_limit_setss_adjust(const f_number_unsigned_t length, f_limit_setss_t *setss) {
for (f_number_unsigned_t i = length; i < setss->size; ++i) {
- status = f_memory_destroy(setss->array[i].size, sizeof(f_limit_sets_t), (void **) & setss->array[i].array);
+ status = f_memory_array_adjust(0, sizeof(f_limit_set_t), (void **) &setss->array[i].array, &setss->array[i].used, &setss->array[i].size);
if (F_status_is_error(status)) return status;
-
- setss->array[i].size = 0;
- setss->array[i].used = 0;
} // for
- status = f_memory_adjust(setss->size, length, sizeof(f_limit_sets_t), (void **) & setss->array);
- if (F_status_is_error(status)) return status;
-
- setss->size = length;
-
- if (setss->used > setss->size) {
- setss->used = length;
- }
-
- return F_none;
+ return f_memory_array_adjust(length, sizeof(f_limit_sets_t), (void **) &setss->array, &setss->used, &setss->size);
}
#endif // !defined(_di_f_limit_setss_adjust_) || !defined(_di_f_limit_setss_decimate_by_)
for (f_number_unsigned_t i = length; i < setss->size; ++i) {
- status = f_memory_delete(setss->array[i].size, sizeof(f_limit_sets_t), (void **) & setss->array[i].array);
+ status = f_memory_array_resize(0, sizeof(f_limit_set_t), (void **) &setss->array[i].array, &setss->array[i].used, &setss->array[i].size);
if (F_status_is_error(status)) return status;
-
- setss->array[i].size = 0;
- setss->array[i].used = 0;
} // for
- status = f_memory_resize(setss->size, length, sizeof(f_limit_sets_t), (void **) & setss->array);
- if (F_status_is_error(status)) return status;
-
- setss->size = length;
-
- if (setss->used > setss->size) {
- setss->used = length;
- }
-
- return F_none;
+ return f_memory_array_resize(length, sizeof(f_limit_sets_t), (void **) &setss->array, &setss->used, &setss->size);
}
#endif // !defined(_di_f_limit_setss_decrease_by_) || !defined(_di_f_limit_setss_increase_) || !defined(_di_f_limit_setss_increase_by_) || !defined(_di_f_limit_setss_resize_)
#endif
/**
- * Private implementation for resizing the sets array.
- *
- * Intended to be shared to each of the different implementation variations.
- *
- * @param length
- * The length to adjust to.
- * @param sets
- * The sets array to adjust.
- *
- * @return
- * F_none on success.
- * F_data_not on success, but there is no reason to increase size (used + 1 <= size).
- *
- * Errors (with error bit) from: f_memory_adjust().
- *
- * @see f_limit_sets_adjust()
- * @see f_limit_sets_decimate_by()
- */
-#if !defined(_di_f_limit_sets_adjust_) || !defined(_di_f_limit_sets_decimate_by_)
- extern f_status_t private_f_limit_sets_adjust(const f_number_unsigned_t length, f_limit_sets_t *sets) F_attribute_visibility_internal_d;
-#endif // !defined(_di_f_limit_sets_adjust_) || !defined(_di_f_limit_sets_decimate_by_)
-
-/**
* Private implementation for appending the set array.
*
* Intended to be shared to each of the different implementation variations.
#endif // !defined(_di_f_limit_sets_append_) || !defined(_di_f_limit_sets_append_all_) || !defined(_di_f_limit_setss_append_all_)
/**
- * Private implementation for resizing the sets array.
- *
- * Intended to be shared to each of the different implementation variations.
- *
- * @param length
- * The length to adjust to.
- * @param sets
- * The sets array to adjust.
- *
- * @return
- * F_none on success.
- * F_data_not on success, but there is no reason to increase size (used + 1 <= size).
- *
- * Errors (with error bit) from: f_memory_resize().
- *
- * @see f_limit_sets_resize()
- * @see f_limit_sets_append()
- * @see f_limit_sets_decimate_by()
- * @see f_limit_setss_append()
- */
-#if !defined(_di_f_limit_sets_resize_) || !defined(_di_f_limit_sets_append_) || !defined(_di_f_limit_sets_decimate_by_) || !defined(_di_f_limit_setss_append_)
- extern f_status_t private_f_limit_sets_resize(const f_number_unsigned_t length, f_limit_sets_t *sets) F_attribute_visibility_internal_d;
-#endif // !defined(_di_f_limit_sets_resize_) || !defined(_di_f_limit_sets_append_) || !defined(_di_f_limit_sets_decimate_by_) || !defined(_di_f_limit_setss_append_)
-
-/**
* Private implementation for resizing the setss array.
*
* Intended to be shared to each of the different implementation variations.
extern "C" {
#endif
-#if !defined(_di_f_limit_values_adjust_) || !defined(_di_f_limit_values_decimate_by_)
- f_status_t private_f_limit_values_adjust(const f_number_unsigned_t length, f_limit_values_t *values) {
-
- const f_status_t status = f_memory_adjust(values->size, length, sizeof(f_limit_value_t), (void **) & values->array);
- if (F_status_is_error(status)) return status;
-
- values->size = length;
-
- if (values->used > values->size) {
- values->used = length;
- }
-
- return F_none;
- }
-#endif // !defined(_di_f_limit_values_adjust_) || !defined(_di_f_limit_values_decimate_by_)
-
#if !defined(_di_f_limit_values_append_) || !defined(_di_f_limit_valuess_append_)
extern f_status_t private_f_limit_values_append(const f_limit_value_t source, f_limit_values_t *destination) {
- if (destination->used + 1 > destination->size) {
- const f_status_t status = private_f_limit_values_resize(destination->used + F_memory_default_allocation_small_d, destination);
- if (F_status_is_error(status)) return status;
- }
+ const f_status_t status = f_memory_array_increase(F_memory_default_allocation_small_d, sizeof(f_limit_value_t), (void **) &destination->array, &destination->used, &destination->size);
+ if (F_status_is_error(status)) return status;
destination->array[destination->used++] = source;
#if !defined(_di_f_limit_values_append_) || !defined(_di_f_limit_values_append_all_) || !defined(_di_f_limit_valuess_append_all_)
extern f_status_t private_f_limit_values_append_all(const f_limit_values_t source, f_limit_values_t *destination) {
- if (destination->used + source.used > destination->size) {
- const f_status_t status = private_f_limit_values_resize(destination->used + source.used, destination);
- if (F_status_is_error(status)) return status;
- }
+ const f_status_t status = f_memory_array_increase_by(source.used, sizeof(f_limit_value_t), (void **) &destination->array, &destination->used, &destination->size);
+ if (F_status_is_error(status)) return status;
for (f_number_unsigned_t i = 0; i < source.used; ++i) {
destination->array[destination->used++] = source.array[i];
}
#endif // !defined(_di_f_limit_values_append_) || !defined(_di_f_limit_values_append_all_) || !defined(_di_f_limit_valuess_append_all_)
-#if !defined(_di_f_limit_values_resize_) || !defined(_di_f_limit_values_append_) || !defined(_di_f_limit_values_decimate_by_) || !defined(_di_f_limit_valuess_append_)
- f_status_t private_f_limit_values_resize(const f_number_unsigned_t length, f_limit_values_t *values) {
-
- const f_status_t status = f_memory_resize(values->size, length, sizeof(f_limit_value_t), (void **) & values->array);
- if (F_status_is_error(status)) return status;
-
- values->size = length;
-
- if (values->used > values->size) {
- values->used = length;
- }
-
- return F_none;
- }
-#endif // !defined(_di_f_limit_values_resize_) || !defined(_di_f_limit_values_append_) || !defined(_di_f_limit_values_decimate_by_) || !defined(_di_f_limit_valuess_append_)
-
#if !defined(_di_f_limit_valuess_adjust_) || !defined(_di_f_limit_valuess_decimate_by_)
f_status_t private_f_limit_valuess_adjust(const f_number_unsigned_t length, f_limit_valuess_t *valuess) {
for (f_number_unsigned_t i = length; i < valuess->size; ++i) {
- status = f_memory_destroy(valuess->array[i].size, sizeof(f_limit_values_t), (void **) & valuess->array[i].array);
+ status = f_memory_array_adjust(0, sizeof(f_limit_value_t), (void **) &valuess->array[i].array, &valuess->array[i].used, &valuess->array[i].size);
if (F_status_is_error(status)) return status;
-
- valuess->array[i].size = 0;
- valuess->array[i].used = 0;
} // for
- status = f_memory_adjust(valuess->size, length, sizeof(f_limit_values_t), (void **) & valuess->array);
- if (F_status_is_error(status)) return status;
-
- valuess->size = length;
-
- if (valuess->used > valuess->size) {
- valuess->used = length;
- }
-
- return F_none;
+ return f_memory_array_adjust(length, sizeof(f_limit_values_t), (void **) &valuess->array, &valuess->used, &valuess->size);
}
#endif // !defined(_di_f_limit_valuess_adjust_) || !defined(_di_f_limit_valuess_decimate_by_)
for (f_number_unsigned_t i = length; i < valuess->size; ++i) {
- status = f_memory_delete(valuess->array[i].size, sizeof(f_limit_values_t), (void **) & valuess->array[i].array);
+ status = f_memory_array_resize(0, sizeof(f_limit_value_t), (void **) &valuess->array[i].array, &valuess->array[i].used, &valuess->array[i].size);
if (F_status_is_error(status)) return status;
-
- valuess->array[i].size = 0;
- valuess->array[i].used = 0;
} // for
- status = f_memory_resize(valuess->size, length, sizeof(f_limit_values_t), (void **) & valuess->array);
- if (F_status_is_error(status)) return status;
-
- valuess->size = length;
-
- if (valuess->used > valuess->size) {
- valuess->used = length;
- }
-
- return F_none;
+ return f_memory_array_resize(length, sizeof(f_limit_values_t), (void **) &valuess->array, &valuess->used, &valuess->size);
}
#endif // !defined(_di_f_limit_valuess_decrease_by_) || !defined(_di_f_limit_valuess_increase_) || !defined(_di_f_limit_valuess_increase_by_) || !defined(_di_f_limit_valuess_resize_)
#endif
/**
- * Private implementation for resizing the values array.
- *
- * Intended to be shared to each of the different implementation variations.
- *
- * @param length
- * The length to adjust to.
- * @param values
- * The values array to adjust.
- *
- * @return
- * F_none on success.
- * F_data_not on success, but there is no reason to increase size (used + 1 <= size).
- *
- * Errors (with error bit) from: f_memory_adjust().
- *
- * @see f_limit_values_adjust()
- * @see f_limit_values_decimate_by()
- */
-#if !defined(_di_f_limit_values_adjust_) || !defined(_di_f_limit_values_decimate_by_)
- extern f_status_t private_f_limit_values_adjust(const f_number_unsigned_t length, f_limit_values_t *values) F_attribute_visibility_internal_d;
-#endif // !defined(_di_f_limit_values_adjust_) || !defined(_di_f_limit_values_decimate_by_)
-
-/**
* Private implementation for appending the value array.
*
* Intended to be shared to each of the different implementation variations.
#endif // !defined(_di_f_limit_values_append_) || !defined(_di_f_limit_values_append_all_) || !defined(_di_f_limit_valuess_append_all_)
/**
- * Private implementation for resizing the values array.
- *
- * Intended to be shared to each of the different implementation variations.
- *
- * @param length
- * The length to adjust to.
- * @param values
- * The values array to adjust.
- *
- * @return
- * F_none on success.
- * F_data_not on success, but there is no reason to increase size (used + 1 <= size).
- *
- * Errors (with error bit) from: f_memory_resize().
- *
- * @see f_limit_values_resize()
- * @see f_limit_values_append()
- * @see f_limit_values_decimate_by()
- * @see f_limit_valuess_append()
- */
-#if !defined(_di_f_limit_values_resize_) || !defined(_di_f_limit_values_append_) || !defined(_di_f_limit_values_decimate_by_) || !defined(_di_f_limit_valuess_append_)
- extern f_status_t private_f_limit_values_resize(const f_number_unsigned_t length, f_limit_values_t *values) F_attribute_visibility_internal_d;
-#endif // !defined(_di_f_limit_values_resize_) || !defined(_di_f_limit_values_append_) || !defined(_di_f_limit_values_decimate_by_) || !defined(_di_f_limit_valuess_append_)
-
-/**
* Private implementation for resizing the valuess array.
*
* Intended to be shared to each of the different implementation variations.
if (!sets) return F_status_set_error(F_parameter);
#endif // _di_level_0_parameter_checking_
- return private_f_limit_sets_adjust(length, sets);
+ return f_memory_array_adjust(length, sizeof(f_limit_set_t), (void **) &sets->array, &sets->used, &sets->size);
}
#endif // _di_f_limit_sets_adjust_
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) {
- return private_f_limit_sets_adjust(sets->size - amount, sets);
- }
-
- return private_f_limit_sets_adjust(0, sets);
+ return f_memory_array_decimate_by(amount, sizeof(f_limit_set_t), (void **) &sets->array, &sets->used, &sets->size);
}
#endif // _di_f_limit_sets_decimate_by_
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) {
- return private_f_limit_sets_resize(sets->size - amount, sets);
- }
-
- return private_f_limit_sets_resize(0, sets);
+ return f_memory_array_decrease_by(amount, sizeof(f_limit_set_t), (void **) &sets->array, &sets->used, &sets->size);
}
#endif // _di_f_limit_sets_decrease_by_
if (!sets) return F_status_set_error(F_parameter);
#endif // _di_level_0_parameter_checking_
- if (step && sets->used + 1 > sets->size) {
- f_number_unsigned_t size = sets->used + step;
-
- if (size > F_number_t_size_unsigned_d) {
- if (sets->used + 1 > F_number_t_size_unsigned_d) {
- return F_status_set_error(F_array_too_large);
- }
-
- size = F_number_t_size_unsigned_d;
- }
-
- return private_f_limit_sets_resize(size, sets);
- }
-
- return F_data_not;
+ return f_memory_array_increase(step, sizeof(f_limit_set_t), (void **) &sets->array, &sets->used, &sets->size);
}
#endif // _di_f_limit_sets_increase_
if (!sets) return F_status_set_error(F_parameter);
#endif // _di_level_0_parameter_checking_
- if (!amount) return F_data_not;
-
- if (sets->used + amount > sets->size) {
- if (sets->used + amount > F_number_t_size_unsigned_d) {
- return F_status_set_error(F_array_too_large);
- }
-
- return private_f_limit_sets_resize(sets->used + amount, sets);
- }
-
- return F_data_not;
+ return f_memory_array_increase_by(amount, sizeof(f_limit_set_t), (void **) &sets->array, &sets->used, &sets->size);
}
#endif // _di_f_limit_sets_increase_by_
if (!sets) return F_status_set_error(F_parameter);
#endif // _di_level_0_parameter_checking_
- return private_f_limit_sets_resize(length, sets);
+ return f_memory_array_resize(length, sizeof(f_limit_set_t), (void **) &sets->array, &sets->used, &sets->size);
}
#endif // _di_f_limit_sets_resize_
if (!source.used) return F_data_not;
- f_status_t status = F_none;
-
- if (destination->used + 1 > destination->size) {
- status = private_f_limit_setss_resize(destination->used + F_memory_default_allocation_small_d, destination);
- if (F_status_is_error(status)) return status;
- }
+ f_status_t status = f_memory_array_increase(F_memory_default_allocation_small_d, sizeof(f_limit_sets_t), (void **) &destination->array, &destination->used, &destination->size);
+ if (F_status_is_error(status)) return status;
status = private_f_limit_sets_append_all(source, &destination->array[destination->used]);
if (F_status_is_error(status)) return status;
if (!source.used) return F_data_not;
- f_status_t status = F_none;
-
- if (destination->used + source.used > destination->size) {
- status = private_f_limit_setss_resize(destination->used + source.used, destination);
- if (F_status_is_error(status)) return status;
- }
+ f_status_t status = f_memory_array_increase(source.used, sizeof(f_limit_sets_t), (void **) &destination->array, &destination->used, &destination->size);
+ if (F_status_is_error(status)) return status;
for (f_number_unsigned_t i = 0; i < source.used; ++i, ++destination->used) {
if (!amount) return F_data_not;
- if (setss->size > amount) {
- return private_f_limit_setss_adjust(setss->size - amount, setss);
- }
-
- return private_f_limit_setss_adjust(0, setss);
+ return private_f_limit_setss_adjust((setss->size > amount) ? setss->size - amount : 0, setss);
}
#endif // _di_f_limit_setss_decimate_by_
if (!amount) return F_data_not;
- if (setss->size > amount) {
- return private_f_limit_setss_resize(setss->size - amount, setss);
- }
-
- return private_f_limit_setss_resize(0, setss);
+ return private_f_limit_setss_resize((setss->size > amount) ? setss->size - amount : 0, setss);
}
#endif // _di_f_limit_setss_decrease_by_
if (!setss) return F_status_set_error(F_parameter);
#endif // _di_level_0_parameter_checking_
- if (step && setss->used + 1 > setss->size) {
- f_number_unsigned_t size = setss->used + step;
-
- if (size > F_number_t_size_unsigned_d) {
- if (setss->used + 1 > F_number_t_size_unsigned_d) {
- return F_status_set_error(F_array_too_large);
- }
-
- size = F_number_t_size_unsigned_d;
- }
-
- return private_f_limit_setss_resize(size, setss);
- }
-
- return F_data_not;
+ return f_memory_array_increase(step, sizeof(f_limit_sets_t), (void **) &setss->array, &setss->used, &setss->size);
}
#endif // _di_f_limit_setss_increase_
if (!setss) return F_status_set_error(F_parameter);
#endif // _di_level_0_parameter_checking_
- if (!amount) return F_data_not;
-
- if (setss->used + amount > setss->size) {
- if (setss->used + amount > F_number_t_size_unsigned_d) {
- return F_status_set_error(F_array_too_large);
- }
-
- return private_f_limit_setss_resize(setss->used + amount, setss);
- }
-
- return F_data_not;
+ return f_memory_array_increase_by(amount, sizeof(f_limit_sets_t), (void **) &setss->array, &setss->used, &setss->size);
}
#endif // _di_f_limit_setss_increase_by_
* The sets array to resize.
*
* @return
- * F_none on success.
+ * Success from f_memory_array_resize().
*
* F_parameter (with error bit) if a parameter is invalid.
*
- * Errors (with error bit) from: f_memory_adjust().
+ * Errors (with error bit) from: f_memory_array_resize().
+ *
+ * @see f_memory_array_resize()
*/
#ifndef _di_f_limit_sets_adjust_
extern f_status_t f_limit_sets_adjust(const f_number_unsigned_t length, f_limit_sets_t *sets);
* F_none on success.
* F_data_not on success, but there is nothing to append (size == 0).
*
+ * Success from f_memory_array_resize().
+ *
* F_parameter (with error bit) if a parameter is invalid.
*
- * Errors (with error bit) from: f_memory_resize().
+ * Errors (with error bit) from: f_memory_array_increase_by().
+ * Errors (with error bit) from: f_memory_array_resize().
+ *
+ * @see f_memory_array_increase_by()
+ * @see f_memory_array_resize()
*/
#ifndef _di_f_limit_sets_append_
extern f_status_t f_limit_sets_append(const f_limit_set_t source, f_limit_sets_t *destination);
* F_none on success.
* F_data_not on success, but there is nothing to append (size == 0).
*
+ * Success from f_memory_array_resize().
+ *
* F_parameter (with error bit) if a parameter is invalid.
*
- * Errors (with error bit) from: f_memory_resize().
+ * Errors (with error bit) from: f_memory_array_increase_by().
+ * Errors (with error bit) from: f_memory_array_resize().
+ *
+ * @see f_memory_array_increase_by()
+ * @see f_memory_array_resize()
*/
#ifndef _di_f_limit_sets_append_all_
extern f_status_t f_limit_sets_append_all(const f_limit_sets_t source, f_limit_sets_t *destination);
* The sets array to resize.
*
* @return
- * F_none on success.
- * F_data_not if amount is 0.
+ * @return
+ * Success from f_memory_array_decimate_by().
*
* F_parameter (with error bit) if a parameter is invalid.
*
- * Errors (with error bit) from: f_memory_adjust().
+ * Errors (with error bit) from: f_memory_array_decimate_by().
+ *
+ * @see f_memory_array_decimate_by()
*/
#ifndef _di_f_limit_sets_decimate_by_
extern f_status_t f_limit_sets_decimate_by(const f_number_unsigned_t amount, f_limit_sets_t *sets);
* The sets array to resize.
*
* @return
- * F_none on success.
+ * Success from f_memory_array_decrease_by().
*
* F_parameter (with error bit) if a parameter is invalid.
*
- * Errors (with error bit) from: f_memory_resize().
+ * Errors (with error bit) from: f_memory_array_decrease_by().
+ *
+ * @see f_memory_array_decrease_by()
*/
#ifndef _di_f_limit_sets_decrease_by_
extern f_status_t f_limit_sets_decrease_by(const f_number_unsigned_t amount, f_limit_sets_t *sets);
* The sets array to resize.
*
* @return
- * F_none on success.
- * F_data_not on success, but there is no reason to increase size (used + 1 <= size).
+ * Success from f_memory_array_increase().
*
- * F_array_too_large (with error bit) if the new array length is too large.
* F_parameter (with error bit) if a parameter is invalid.
*
- * Errors (with error bit) from: f_memory_resize().
+ * Errors (with error bit) from: f_memory_array_increase().
+ *
+ * @see f_memory_array_increase()
*/
#ifndef _di_f_limit_sets_increase_
extern f_status_t f_limit_sets_increase(const f_number_unsigned_t step, f_limit_sets_t *sets);
* The sets array to resize.
*
* @return
- * F_none on success.
- * F_data_not on success, but there is no reason to increase size (used + amount <= size).
+ * Success from f_memory_array_increase_by().
*
- * F_array_too_large (with error bit) if the new array length is too large.
* F_parameter (with error bit) if a parameter is invalid.
*
- * Errors (with error bit) from: f_memory_resize().
+ * Errors (with error bit) from: f_memory_array_increase_by().
+ *
+ * @see f_memory_array_increase_by()
*/
#ifndef _di_f_limit_sets_increase_by_
extern f_status_t f_limit_sets_increase_by(const f_number_unsigned_t amount, f_limit_sets_t *sets);
* The sets array to adjust.
*
* @return
- * F_none on success.
+ * Success from f_memory_array_resize().
*
* F_parameter (with error bit) if a parameter is invalid.
*
- * Errors (with error bit) from: f_memory_resize().
+ * Errors (with error bit) from: f_memory_array_resize().
+ *
+ * @see f_memory_array_resize()
*/
#ifndef _di_f_limit_sets_resize_
extern f_status_t f_limit_sets_resize(const f_number_unsigned_t length, f_limit_sets_t *sets);
* The setss array to resize.
*
* @return
- * F_none on success.
+ * Success from f_memory_array_adjust().
*
* F_parameter (with error bit) if a parameter is invalid.
*
- * Errors (with error bit) from: f_memory_adjust().
- * Errors (with error bit) from: f_memory_destroy().
+ * Errors (with error bit) from: f_memory_array_adjust().
+ *
+ * @see f_memory_array_adjust()
*/
#ifndef _di_f_limit_setss_adjust_
extern f_status_t f_limit_setss_adjust(const f_number_unsigned_t length, f_limit_setss_t *setss);
* F_none on success.
* F_data_not on success, but there is nothing to append (size == 0).
*
+ * Success from f_memory_array_resize().
+ *
* F_parameter (with error bit) if a parameter is invalid.
*
- * Errors (with error bit) from: f_memory_resize().
+ * Errors (with error bit) from: f_memory_array_increase_by().
+ * Errors (with error bit) from: f_memory_array_resize().
+ *
+ * @see f_memory_array_increase_by()
+ * @see f_memory_array_resize()
*/
#ifndef _di_f_limit_setss_append_
extern f_status_t f_limit_setss_append(const f_limit_sets_t source, f_limit_setss_t *destination);
* F_none on success.
* F_data_not on success, but there is nothing to append (size == 0).
*
+ * Success from f_memory_array_resize().
+ *
* F_parameter (with error bit) if a parameter is invalid.
*
- * Errors (with error bit) from: f_memory_resize().
+ * Errors (with error bit) from: f_memory_array_increase_by().
+ * Errors (with error bit) from: f_memory_array_resize().
+ *
+ * @see f_memory_array_increase_by()
+ * @see f_memory_array_resize()
*/
#ifndef _di_f_limit_setss_append_all_
extern f_status_t f_limit_setss_append_all(const f_limit_setss_t source, f_limit_setss_t *destination);
* The setss array to resize.
*
* @return
- * F_none on success.
- * F_data_not if amount is 0.
+ * F_data_not on success, but the amount to decrease by is 0.
+ *
+ * Success from f_memory_array_decimate_by().
*
* F_parameter (with error bit) if a parameter is invalid.
*
- * Errors (with error bit) from: f_memory_adjust().
- * Errors (with error bit) from: f_memory_destroy().
+ * Errors (with error bit) from: f_memory_array_decimate_by().
+ *
+ * @see f_memory_array_decimate_by()
*/
#ifndef _di_f_limit_setss_decimate_by_
extern f_status_t f_limit_setss_decimate_by(const f_number_unsigned_t amount, f_limit_setss_t *setss);
* The setss array to resize.
*
* @return
- * F_none on success.
+ * F_data_not on success, but the amount to decrease by is 0.
+ *
+ * Success from f_memory_array_decrease_by().
*
* F_parameter (with error bit) if a parameter is invalid.
*
- * Errors (with error bit) from: f_memory_delete().
- * Errors (with error bit) from: f_memory_resize().
+ * Errors (with error bit) from: f_memory_array_decrease_by().
+ *
+ * @see f_memory_array_decrease_by()
*/
#ifndef _di_f_limit_setss_decrease_by_
extern f_status_t f_limit_setss_decrease_by(const f_number_unsigned_t amount, f_limit_setss_t *setss);
* The setss array to resize.
*
* @return
- * F_none on success.
- * F_data_not on success, but there is no reason to increase size (used + 1 <= size).
+ * Success from f_memory_array_increase().
*
- * F_array_too_large (with error bit) if the new array length is too large.
* F_parameter (with error bit) if a parameter is invalid.
*
- * Errors (with error bit) from: f_memory_resize().
+ * Errors (with error bit) from: f_memory_array_increase().
+ *
+ * @see f_memory_array_increase()
*/
#ifndef _di_f_limit_setss_increase_
extern f_status_t f_limit_setss_increase(const f_number_unsigned_t step, f_limit_setss_t *setss);
* The setss array to resize.
*
* @return
- * F_none on success.
- * F_data_not on success, but there is no reason to increase size (used + amount <= size).
+ * Success from f_memory_array_increase_by().
*
- * F_array_too_large (with error bit) if the new array length is too large.
* F_parameter (with error bit) if a parameter is invalid.
*
- * Errors (with error bit) from: f_memory_resize().
+ * Errors (with error bit) from: f_memory_array_increase_by().
+ *
+ * @see f_memory_array_increase_by()
*/
#ifndef _di_f_limit_setss_increase_by_
extern f_status_t f_limit_setss_increase_by(const f_number_unsigned_t amount, f_limit_setss_t *setss);
* The setss array to adjust.
*
* @return
- * F_none on success.
+ * Success from f_memory_array_resize().
*
* F_parameter (with error bit) if a parameter is invalid.
*
- * Errors (with error bit) from: f_memory_delete().
- * Errors (with error bit) from: f_memory_resize().
+ * Errors (with error bit) from: f_memory_array_resize().
+ *
+ * @see f_memory_array_resize()
*/
#ifndef _di_f_limit_setss_resize_
extern f_status_t f_limit_setss_resize(const f_number_unsigned_t length, f_limit_setss_t *setss);
if (!values) return F_status_set_error(F_parameter);
#endif // _di_level_0_parameter_checking_
- return private_f_limit_values_adjust(length, values);
+ return f_memory_array_adjust(length, sizeof(f_limit_value_t), (void **) &values->array, &values->used, &values->size);
}
#endif // _di_f_limit_values_adjust_
if (!values) return F_status_set_error(F_parameter);
#endif // _di_level_0_parameter_checking_
- if (!amount) return F_data_not;
-
- if (values->size > amount) {
- return private_f_limit_values_adjust(values->size - amount, values);
- }
-
- return private_f_limit_values_adjust(0, values);
+ return f_memory_array_decimate_by(amount, sizeof(f_limit_value_t), (void **) &values->array, &values->used, &values->size);
}
#endif // _di_f_limit_values_decimate_by_
if (!values) return F_status_set_error(F_parameter);
#endif // _di_level_0_parameter_checking_
- if (!amount) return F_data_not;
-
- if (values->size > amount) {
- return private_f_limit_values_resize(values->size - amount, values);
- }
-
- return private_f_limit_values_resize(0, values);
+ return f_memory_array_decrease_by(amount, sizeof(f_limit_value_t), (void **) &values->array, &values->used, &values->size);
}
#endif // _di_f_limit_values_decrease_by_
if (!values) return F_status_set_error(F_parameter);
#endif // _di_level_0_parameter_checking_
- if (step && values->used + 1 > values->size) {
- f_number_unsigned_t size = values->used + step;
-
- if (size > F_number_t_size_unsigned_d) {
- if (values->used + 1 > F_number_t_size_unsigned_d) {
- return F_status_set_error(F_array_too_large);
- }
-
- size = F_number_t_size_unsigned_d;
- }
-
- return private_f_limit_values_resize(size, values);
- }
-
- return F_data_not;
+ return f_memory_array_increase(step, sizeof(f_limit_value_t), (void **) &values->array, &values->used, &values->size);
}
#endif // _di_f_limit_values_increase_
if (!values) return F_status_set_error(F_parameter);
#endif // _di_level_0_parameter_checking_
- if (!amount) return F_data_not;
-
- if (values->used + amount > values->size) {
- if (values->used + amount > F_number_t_size_unsigned_d) {
- return F_status_set_error(F_array_too_large);
- }
-
- return private_f_limit_values_resize(values->used + amount, values);
- }
-
- return F_data_not;
+ return f_memory_array_increase_by(amount, sizeof(f_limit_value_t), (void **) &values->array, &values->used, &values->size);
}
#endif // _di_f_limit_values_increase_by_
if (!values) return F_status_set_error(F_parameter);
#endif // _di_level_0_parameter_checking_
- return private_f_limit_values_resize(length, values);
+ return f_memory_array_resize(length, sizeof(f_limit_value_t), (void **) &values->array, &values->used, &values->size);
}
#endif // _di_f_limit_values_resize_
if (!source.used) return F_data_not;
- f_status_t status = F_none;
-
- if (destination->used + 1 > destination->size) {
- status = private_f_limit_valuess_resize(destination->used + F_memory_default_allocation_small_d, destination);
- if (F_status_is_error(status)) return status;
- }
+ f_status_t status = f_memory_array_increase(F_memory_default_allocation_small_d, sizeof(f_limit_values_t), (void **) &destination->array, &destination->used, &destination->size);
+ if (F_status_is_error(status)) return status;
status = private_f_limit_values_append_all(source, &destination->array[destination->used]);
if (F_status_is_error(status)) return status;
if (!source.used) return F_data_not;
- f_status_t status = F_none;
-
- if (destination->used + source.used > destination->size) {
- status = private_f_limit_valuess_resize(destination->used + source.used, destination);
- if (F_status_is_error(status)) return status;
- }
+ f_status_t status = f_memory_array_increase(source.used, sizeof(f_limit_values_t), (void **) &destination->array, &destination->used, &destination->size);
+ if (F_status_is_error(status)) return status;
for (f_number_unsigned_t i = 0; i < source.used; ++i, ++destination->used) {
if (!amount) return F_data_not;
- if (valuess->size > amount) {
- return private_f_limit_valuess_adjust(valuess->size - amount, valuess);
- }
-
- return private_f_limit_valuess_adjust(0, valuess);
+ return private_f_limit_valuess_adjust((valuess->size > amount) ? valuess->size - amount : 0, valuess);
}
#endif // _di_f_limit_valuess_decimate_by_
if (!amount) return F_data_not;
- if (valuess->size > amount) {
- return private_f_limit_valuess_resize(valuess->size - amount, valuess);
- }
-
- return private_f_limit_valuess_resize(0, valuess);
+ return private_f_limit_valuess_resize((valuess->size > amount) ? valuess->size - amount : 0, valuess);
}
#endif // _di_f_limit_valuess_decrease_by_
if (!valuess) return F_status_set_error(F_parameter);
#endif // _di_level_0_parameter_checking_
- if (step && valuess->used + 1 > valuess->size) {
- f_number_unsigned_t size = valuess->used + step;
-
- if (size > F_number_t_size_unsigned_d) {
- if (valuess->used + 1 > F_number_t_size_unsigned_d) {
- return F_status_set_error(F_array_too_large);
- }
-
- size = F_number_t_size_unsigned_d;
- }
-
- return private_f_limit_valuess_resize(size, valuess);
- }
-
- return F_data_not;
+ return f_memory_array_increase(step, sizeof(f_limit_values_t), (void **) &valuess->array, &valuess->used, &valuess->size);
}
#endif // _di_f_limit_valuess_increase_
if (!valuess) return F_status_set_error(F_parameter);
#endif // _di_level_0_parameter_checking_
- if (!amount) return F_data_not;
-
- if (valuess->used + amount > valuess->size) {
- if (valuess->used + amount > F_number_t_size_unsigned_d) {
- return F_status_set_error(F_array_too_large);
- }
-
- return private_f_limit_valuess_resize(valuess->used + amount, valuess);
- }
-
- return F_data_not;
+ return f_memory_array_increase_by(amount, sizeof(f_limit_values_t), (void **) &valuess->array, &valuess->used, &valuess->size);
}
#endif // _di_f_limit_valuess_increase_by_
* The values array to resize.
*
* @return
- * F_none on success.
+ * Success from f_memory_array_adjust().
*
* F_parameter (with error bit) if a parameter is invalid.
*
- * Errors (with error bit) from: f_memory_adjust().
+ * Errors (with error bit) from: f_memory_array_adjust().
+ *
+ * @see f_memory_array_adjust()
*/
#ifndef _di_f_limit_values_adjust_
extern f_status_t f_limit_values_adjust(const f_number_unsigned_t length, f_limit_values_t *values);
* F_none on success.
* F_data_not on success, but there is nothing to append (size == 0).
*
+ * Success from f_memory_array_resize().
+ *
* F_parameter (with error bit) if a parameter is invalid.
*
- * Errors (with error bit) from: f_memory_resize().
+ * Errors (with error bit) from: f_memory_array_increase_by().
+ * Errors (with error bit) from: f_memory_array_resize().
+ *
+ * @see f_memory_array_increase_by()
+ * @see f_memory_array_resize()
*/
#ifndef _di_f_limit_values_append_
extern f_status_t f_limit_values_append(const f_limit_value_t source, f_limit_values_t *destination);
* F_none on success.
* F_data_not on success, but there is nothing to append (size == 0).
*
+ * Success from f_memory_array_resize().
+ *
* F_parameter (with error bit) if a parameter is invalid.
*
- * Errors (with error bit) from: f_memory_resize().
+ * Errors (with error bit) from: f_memory_array_increase_by().
+ * Errors (with error bit) from: f_memory_array_resize().
+ *
+ * @see f_memory_array_increase_by()
+ * @see f_memory_array_resize()
*/
#ifndef _di_f_limit_values_append_all_
extern f_status_t f_limit_values_append_all(const f_limit_values_t source, f_limit_values_t *destination);
* The values array to resize.
*
* @return
- * F_none on success.
- * F_data_not if amount is 0.
+ * Success from f_memory_array_decimate_by().
*
* F_parameter (with error bit) if a parameter is invalid.
*
- * Errors (with error bit) from: f_memory_adjust().
+ * Errors (with error bit) from: f_memory_array_decimate_by().
+ *
+ * @see f_memory_array_decimate_by()
*/
#ifndef _di_f_limit_values_decimate_by_
extern f_status_t f_limit_values_decimate_by(const f_number_unsigned_t amount, f_limit_values_t *values);
* The values array to resize.
*
* @return
- * F_none on success.
+ * Success from f_memory_array_decrease_by().
*
* F_parameter (with error bit) if a parameter is invalid.
*
- * Errors (with error bit) from: f_memory_resize().
+ * Errors (with error bit) from: f_memory_array_decrease_by().
+ *
+ * @see f_memory_array_decrease_by()
*/
#ifndef _di_f_limit_values_decrease_by_
extern f_status_t f_limit_values_decrease_by(const f_number_unsigned_t amount, f_limit_values_t *values);
* The values array to resize.
*
* @return
- * F_none on success.
- * F_data_not on success, but there is no reason to increase size (used + 1 <= size).
+ * Success from f_memory_array_increase().
*
- * F_array_too_large (with error bit) if the new array length is too large.
* F_parameter (with error bit) if a parameter is invalid.
*
- * Errors (with error bit) from: f_memory_resize().
+ * Errors (with error bit) from: f_memory_array_increase().
+ *
+ * @see f_memory_array_increase()
*/
#ifndef _di_f_limit_values_increase_
extern f_status_t f_limit_values_increase(const f_number_unsigned_t step, f_limit_values_t *values);
* The values array to resize.
*
* @return
- * F_none on success.
- * F_data_not on success, but there is no reason to increase size (used + amount <= size).
+ * Success from f_memory_array_increase_by().
*
- * F_array_too_large (with error bit) if the new array length is too large.
* F_parameter (with error bit) if a parameter is invalid.
*
- * Errors (with error bit) from: f_memory_resize().
+ * Errors (with error bit) from: f_memory_array_increase_by().
+ *
+ * @see f_memory_array_increase_by()
*/
#ifndef _di_f_limit_values_increase_by_
extern f_status_t f_limit_values_increase_by(const f_number_unsigned_t amount, f_limit_values_t *values);
* The values array to adjust.
*
* @return
- * F_none on success.
+ * Success from f_memory_array_resize().
*
* F_parameter (with error bit) if a parameter is invalid.
*
- * Errors (with error bit) from: f_memory_resize().
+ * Errors (with error bit) from: f_memory_array_resize().
+ *
+ * @see f_memory_array_resize()
*/
#ifndef _di_f_limit_values_resize_
extern f_status_t f_limit_values_resize(const f_number_unsigned_t length, f_limit_values_t *values);
* The valuess array to resize.
*
* @return
- * F_none on success.
+ * Success from f_memory_array_adjust().
*
* F_parameter (with error bit) if a parameter is invalid.
*
- * Errors (with error bit) from: f_memory_adjust().
- * Errors (with error bit) from: f_memory_destroy().
+ * Errors (with error bit) from: f_memory_array_adjust().
+ *
+ * @see f_memory_array_adjust()
*/
#ifndef _di_f_limit_valuess_adjust_
extern f_status_t f_limit_valuess_adjust(const f_number_unsigned_t length, f_limit_valuess_t *valuess);
* F_none on success.
* F_data_not on success, but there is nothing to append (size == 0).
*
+ * Success from f_memory_array_resize().
+ *
* F_parameter (with error bit) if a parameter is invalid.
*
- * Errors (with error bit) from: f_memory_resize().
+ * Errors (with error bit) from: f_memory_array_increase_by().
+ * Errors (with error bit) from: f_memory_array_resize().
+ *
+ * @see f_memory_array_increase_by()
+ * @see f_memory_array_resize()
*/
#ifndef _di_f_limit_valuess_append_
extern f_status_t f_limit_valuess_append(const f_limit_values_t source, f_limit_valuess_t *destination);
* F_none on success.
* F_data_not on success, but there is nothing to append (size == 0).
*
+ * Success from f_memory_array_resize().
+ *
* F_parameter (with error bit) if a parameter is invalid.
*
- * Errors (with error bit) from: f_memory_resize().
+ * Errors (with error bit) from: f_memory_array_increase_by().
+ * Errors (with error bit) from: f_memory_array_resize().
+ *
+ * @see f_memory_array_increase_by()
+ * @see f_memory_array_resize()
*/
#ifndef _di_f_limit_valuess_append_all_
extern f_status_t f_limit_valuess_append_all(const f_limit_valuess_t source, f_limit_valuess_t *destination);
* The valuess array to resize.
*
* @return
- * F_none on success.
- * F_data_not if amount is 0.
+ * F_data_not on success, but the amount to decrease by is 0.
+ *
+ * Success from f_memory_array_decimate_by().
*
* F_parameter (with error bit) if a parameter is invalid.
*
- * Errors (with error bit) from: f_memory_adjust().
- * Errors (with error bit) from: f_memory_destroy().
+ * Errors (with error bit) from: f_memory_array_decimate_by().
+ *
+ * @see f_memory_array_decimate_by()
*/
#ifndef _di_f_limit_valuess_decimate_by_
extern f_status_t f_limit_valuess_decimate_by(const f_number_unsigned_t amount, f_limit_valuess_t *valuess);
* The valuess array to resize.
*
* @return
- * F_none on success.
+ * F_data_not on success, but the amount to decrease by is 0.
+ *
+ * Success from f_memory_array_decrease_by().
*
* F_parameter (with error bit) if a parameter is invalid.
*
- * Errors (with error bit) from: f_memory_delete().
- * Errors (with error bit) from: f_memory_resize().
+ * Errors (with error bit) from: f_memory_array_decrease_by().
+ *
+ * @see f_memory_array_decrease_by()
*/
#ifndef _di_f_limit_valuess_decrease_by_
extern f_status_t f_limit_valuess_decrease_by(const f_number_unsigned_t amount, f_limit_valuess_t *valuess);
* The valuess array to resize.
*
* @return
- * F_none on success.
- * F_data_not on success, but there is no reason to increase size (used + 1 <= size).
+ * Success from f_memory_array_increase().
*
- * F_array_too_large (with error bit) if the new array length is too large.
* F_parameter (with error bit) if a parameter is invalid.
*
- * Errors (with error bit) from: f_memory_resize().
+ * Errors (with error bit) from: f_memory_array_increase().
+ *
+ * @see f_memory_array_increase()
*/
#ifndef _di_f_limit_valuess_increase_
extern f_status_t f_limit_valuess_increase(const f_number_unsigned_t step, f_limit_valuess_t *valuess);
* The valuess array to resize.
*
* @return
- * F_none on success.
- * F_data_not on success, but there is no reason to increase size (used + amount <= size).
+ * Success from f_memory_array_increase_by().
*
- * F_array_too_large (with error bit) if the new array length is too large.
* F_parameter (with error bit) if a parameter is invalid.
*
- * Errors (with error bit) from: f_memory_resize().
+ * Errors (with error bit) from: f_memory_array_increase_by().
+ *
+ * @see f_memory_array_increase_by()
*/
#ifndef _di_f_limit_valuess_increase_by_
extern f_status_t f_limit_valuess_increase_by(const f_number_unsigned_t amount, f_limit_valuess_t *valuess);
* The valuess array to adjust.
*
* @return
- * F_none on success.
+ * Success from f_memory_array_resize().
*
* F_parameter (with error bit) if a parameter is invalid.
*
- * Errors (with error bit) from: f_memory_delete().
- * Errors (with error bit) from: f_memory_resize().
+ * Errors (with error bit) from: f_memory_array_resize().
+ *
+ * @see f_memory_array_resize()
*/
#ifndef _di_f_limit_valuess_resize_
extern f_status_t f_limit_valuess_resize(const f_number_unsigned_t length, f_limit_valuess_t *valuess);
// FLL-0 memory includes.
#include <fll/level_0/memory/common.h>
+#include <fll/level_0/memory/array.h>
#include <fll/level_0/memory/structure.h>
#ifdef __cplusplus
--- /dev/null
+#include "../memory.h"
+#include "private-array.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef _di_f_memory_array_adjust_
+ f_status_t f_memory_array_adjust(const f_number_unsigned_t length, const size_t width, void ** array, f_number_unsigned_t * const used, f_number_unsigned_t * const size) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!array) return F_status_set_error(F_parameter);
+ if (!used) return F_status_set_error(F_parameter);
+ if (!size) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large);
+
+ return private_f_memory_array_adjust(length, width, array, used, size);
+ }
+#endif // _di_f_memory_array_adjust_
+
+#ifndef _di_f_memory_array_decimate_by_
+ f_status_t f_memory_array_decimate_by(const f_number_unsigned_t amount, const size_t width, void ** array, f_number_unsigned_t * const used, f_number_unsigned_t * const size) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!array) return F_status_set_error(F_parameter);
+ if (!used) return F_status_set_error(F_parameter);
+ if (!size) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ if (!amount) return F_data_not;
+ if (*size > amount) return private_f_memory_array_adjust(*size - amount, width, array, used, size);
+
+ return private_f_memory_array_adjust(0, width, array, used, size);
+ }
+#endif // _di_f_memory_array_decimate_by_
+
+#ifndef _di_f_memory_array_decrease_by_
+ f_status_t f_memory_array_decrease_by(const f_number_unsigned_t amount, const size_t width, void ** array, f_number_unsigned_t * const used, f_number_unsigned_t * const size) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!array) return F_status_set_error(F_parameter);
+ if (!used) return F_status_set_error(F_parameter);
+ if (!size) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ if (!amount) return F_data_not;
+ if (*size > amount) return private_f_memory_array_resize(*size - amount, width, array, used, size);
+
+ return private_f_memory_array_resize(0, width, array, used, size);
+ }
+#endif // _di_f_memory_array_decrease_by_
+
+#ifndef _di_f_memory_array_increase_
+ f_status_t f_memory_array_increase(const f_number_unsigned_t step, const size_t width, void ** array, f_number_unsigned_t * const used, f_number_unsigned_t * const size) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!array) return F_status_set_error(F_parameter);
+ if (!used) return F_status_set_error(F_parameter);
+ if (!size) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ if (step && *used + 1 > *size) {
+ f_number_unsigned_t length = *used + step;
+
+ if (step > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large);
+
+ if (*size > F_number_t_size_unsigned_d) {
+ if (*used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large);
+ if (*used + length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large);
+
+ length = F_number_t_size_unsigned_d;
+ }
+
+ return private_f_memory_array_resize(length, width, array, used, size);
+ }
+
+ return F_data_not;
+ }
+#endif // _di_f_memory_array_increase_
+
+#ifndef _di_f_memory_array_increase_by_
+ f_status_t f_memory_array_increase_by(const f_number_unsigned_t amount, const size_t width, void ** array, f_number_unsigned_t * const used, f_number_unsigned_t * const size) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!array) return F_status_set_error(F_parameter);
+ if (!used) return F_status_set_error(F_parameter);
+ if (!size) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ if (!amount) return F_data_not;
+
+ if (*used + amount > *size) {
+ if (*used + amount > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large);
+
+ return private_f_memory_array_resize(*used + amount, width, array, used, size);
+ }
+
+ return F_data_not;
+ }
+#endif // _di_f_memory_array_increase_by_
+
+#ifndef _di_f_memory_array_resize_
+ f_status_t f_memory_array_resize(const f_number_unsigned_t length, const size_t width, void ** array, f_number_unsigned_t * const used, f_number_unsigned_t * const size) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!array) return F_status_set_error(F_parameter);
+ if (!used) return F_status_set_error(F_parameter);
+ if (!size) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large);
+
+ return private_f_memory_array_resize(length, width, array, used, size);
+ }
+#endif // _di_f_memory_array_resize_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Memory
+ * API Version: 0.7
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Defines memory array data.
+ *
+ * This is auto-included by memory.h and should not need to be explicitly included.
+ */
+#ifndef _F_memory_array_h
+#define _F_memory_array_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Resize the memory array.
+ *
+ * This function is only useful for simple structures of the form "{ array, used, size }" where the array is a simple type.
+ * If the simple type that is "array" requires additional memory manipulation on allocation or de-allocation, then do not use this function.
+ *
+ * @param length
+ * The new size to use.
+ * @param width
+ * The size of the structure represented by array.
+ * The word "width" is used due to conflicts of already using "length" and "size".
+ * @param array
+ * The structure.array to resize.
+ * @param used
+ * The structure.used.
+ * @param size
+ * The structure.size.
+ *
+ * @return
+ * F_none on success.
+ *
+ * F_array_too_large (with error bit) if the new array length is too large.
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_memory_array_adjust_
+ extern f_status_t f_memory_array_adjust(const f_number_unsigned_t length, const size_t width, void ** array, f_number_unsigned_t * const used, f_number_unsigned_t * const size);
+#endif // _di_f_memory_array_adjust_
+
+/**
+ * Resize the memory 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.
+ *
+ * This function is only useful for simple structures of the form "{ array, used, size }" where the array is a simple type.
+ * If the simple type that is "array" requires additional memory manipulation on allocation or de-allocation, then do not use this function.
+ *
+ * @param amount
+ * A positive number representing how much to decimate the size by.
+ * @param width
+ * The size of the structure represented by array.
+ * The word "width" is used due to conflicts of already using "length" and "size".
+ * @param array
+ * The structure.array to resize.
+ * @param used
+ * The structure.used.
+ * @param size
+ * The structure.size.
+ *
+ * @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_memory_array_decimate_by_
+ extern f_status_t f_memory_array_decimate_by(const f_number_unsigned_t amount, const size_t width, void ** array, f_number_unsigned_t * const used, f_number_unsigned_t * const size);
+#endif // _di_f_memory_array_decimate_by_
+
+/**
+ * Resize the memory 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.
+ *
+ * This function is only useful for simple structures of the form "{ array, used, size }" where the array is a simple type.
+ * If the simple type that is "array" requires additional memory manipulation on allocation or de-allocation, then do not use this function.
+ *
+ * @param amount
+ * A positive number representing how much to decrease the size by.
+ * @param width
+ * The size of the structure represented by array.
+ * The word "width" is used due to conflicts of already using "length" and "size".
+ * @param array
+ * The structure.array to resize.
+ * @param used
+ * The structure.used.
+ * @param size
+ * The structure.size.
+ *
+ * @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_memory_array_decrease_by_
+ extern f_status_t f_memory_array_decrease_by(const f_number_unsigned_t amount, const size_t width, void ** array, f_number_unsigned_t * const used, f_number_unsigned_t * const size);
+#endif // _di_f_memory_array_decrease_by_
+
+/**
+ * Increase the size of the memory array, but only if necessary.
+ *
+ * If the given length is too large for the buffer, then attempt to set max buffer size (F_number_t_size_unsigned_d).
+ * If already set to the maximum buffer size, then the resize will fail.
+ *
+ * This function is only useful for simple structures of the form "{ array, used, size }" where the array is a simple type.
+ * If the simple type that is "array" requires additional memory manipulation on allocation or de-allocation, then do not use this function.
+ *
+ * @param step
+ * The allocation step to use.
+ * Must be greater than 0.
+ * @param width
+ * The size of the structure represented by array.
+ * The word "width" is used due to conflicts of already using "length" and "size".
+ * @param array
+ * The structure.array to resize.
+ * @param used
+ * The structure.used.
+ * @param size
+ * The structure.size.
+ *
+ * @return
+ * F_none on success.
+ * F_data_not on success, but there is no reason to increase size (used + 1 <= size).
+ *
+ * F_array_too_large (with error bit) if the new array length is too large.
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_memory_array_increase_
+ extern f_status_t f_memory_array_increase(const f_number_unsigned_t step, const size_t width, void ** array, f_number_unsigned_t * const used, f_number_unsigned_t * const size);
+#endif // _di_f_memory_array_increase_
+
+/**
+ * Resize the memory array to a larger size.
+ *
+ * This will resize making the array larger based on the given length.
+ * If the given length is too large for the buffer, then attempt to set max buffer size (F_number_t_size_unsigned_d).
+ * If already set to the maximum buffer size, then the resize will fail.
+ *
+ * This function is only useful for simple structures of the form "{ array, used, size }" where the array is a simple type.
+ * If the simple type that is "array" requires additional memory manipulation on allocation or de-allocation, then do not use this function.
+ *
+ * @param amount
+ * A positive number representing how much to increase the size by.
+ * @param width
+ * The size of the structure represented by array.
+ * The word "width" is used due to conflicts of already using "length" and "size".
+ * @param array
+ * The structure.array to resize.
+ * @param used
+ * The structure.used.
+ * @param size
+ * The structure.size.
+ *
+ * @return
+ * F_none on success.
+ * F_data_not on success, but there is no reason to increase size (used + amount <= size).
+ *
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ * F_array_too_large (with error bit) if the new array length is too large.
+ */
+#ifndef _di_f_memory_array_increase_by_
+ extern f_status_t f_memory_array_increase_by(const f_number_unsigned_t amount, const size_t width, void ** array, f_number_unsigned_t * const used, f_number_unsigned_t * const size);
+#endif // _di_f_memory_array_increase_by_
+
+/**
+ * Resize the memory array.
+ *
+ * This function is only useful for simple structures of the form "{ array, used, size }" where the array is a simple type.
+ * If the simple type that is "array" requires additional memory manipulation on allocation or de-allocation, then do not use this function.
+ *
+ * @param length
+ * The new size to use.
+ * @param width
+ * The size of the structure represented by array.
+ * The word "width" is used due to conflicts of already using "length" and "size".
+ * @param array
+ * The structure.array to resize.
+ * @param used
+ * The structure.used.
+ * @param size
+ * The structure.size.
+ *
+ * @return
+ * F_none on success.
+ *
+ * F_array_too_large (with error bit) if the new array length is too large.
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_memory_array_resize_
+ extern f_status_t f_memory_array_resize(const f_number_unsigned_t length, const size_t width, void ** array, f_number_unsigned_t * const used, f_number_unsigned_t * const size);
+#endif // _di_f_memory_array_resize_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _F_memory_array_h
--- /dev/null
+#include "../memory.h"
+#include "private-array.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if !defined(_di_f_memory_array_adjust_) || !defined(_di_f_memory_array_decimate_by_)
+ f_status_t private_f_memory_array_adjust(const f_number_unsigned_t length, const size_t width, void ** array, f_number_unsigned_t * const used, f_number_unsigned_t * const size) {
+
+ const f_status_t status = f_memory_adjust(*size, length, width, array);
+ if (F_status_is_error(status)) return status;
+
+ *size = length;
+
+ if (*used > *size) {
+ *used = length;
+ }
+
+ return F_none;
+ }
+#endif // !defined(_di_f_memory_array_adjust_) || !defined(_di_f_memory_array_decimate_by_)
+
+#if !defined(_di_f_memory_array_decrease_by_) || !defined(_di_f_memory_array_increase_) || !defined(_di_f_memory_array_increase_by_) || !defined(_di_f_memory_array_resize_)
+ f_status_t private_f_memory_array_resize(const f_number_unsigned_t length, const size_t width, void ** array, f_number_unsigned_t * const used, f_number_unsigned_t * const size) {
+
+ const f_status_t status = f_memory_resize(*size, length, width, array);
+ if (F_status_is_error(status)) return status;
+
+ *size = length;
+
+ if (*used > *size) {
+ *used = length;
+ }
+
+ return F_none;
+ }
+#endif // !defined(_di_f_memory_array_decrease_by_) || !defined(_di_f_memory_array_increase_) || !defined(_di_f_memory_array_increase_by_) || !defined(_di_f_memory_array_resize_)
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Memory
+ * API Version: 0.7
+ * Licenses: lgpl-2.1-or-later
+ *
+ * These are provided for internal reduction in redundant code.
+ * These should not be exposed/used outside of this project.
+ */
+#ifndef _PRIVATE_F_memory_array_h
+#define _PRIVATE_F_memory_array_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Private implementation for resizing.
+ *
+ * Intended to be shared to each of the different implementation variations.
+ *
+ * @param length
+ * The new size to use.
+ * @param width
+ * The size of the structure represented by array.
+ * The word "width" is used due to conflicts of already using "length" and "size".
+ * @param array
+ * The structure.array to adjust.
+ * @param used
+ * The structure.used.
+ * @param size
+ * The structure.size.
+ *
+ * @return
+ * F_none on success.
+ *
+ * Errors (with error bit) from: f_memory_adjust().
+ *
+ * @see f_memory_array_adjust()
+ * @see f_memory_array_decimate_by()
+ * @see f_memory_adjust()
+ */
+#if !defined(_di_f_memory_array_adjust_) || !defined(_di_f_memory_array_decimate_by_)
+ extern f_status_t private_f_memory_array_adjust(const f_number_unsigned_t length, const size_t width, void ** array, f_number_unsigned_t * const used, f_number_unsigned_t * const size) F_attribute_visibility_internal_d;
+#endif // !defined(_di_f_memory_array_adjust_) || !defined(_di_f_memory_array_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 width
+ * The size of the structure represented by array.
+ * The word "width" is used due to conflicts of already using "length" and "size".
+ * @param array
+ * The structure.array to resize.
+ * @param used
+ * The structure.used.
+ * @param size
+ * The structure.size.
+ *
+ * @return
+ * F_none on success.
+ *
+ * Errors (with error bit) from: f_memory_resize().
+ *
+ * @see f_memory_array_decrease_by()
+ * @see f_memory_array_increase()
+ * @see f_memory_array_increase_by()
+ * @see f_memory_array_resize()
+ * @see f_memory_resize()
+ */
+#if !defined(_di_f_memory_array_decrease_by_) || !defined(_di_f_memory_array_increase_) || !defined(_di_f_memory_array_increase_by_) || !defined(_di_f_memory_array_resize_)
+ extern f_status_t private_f_memory_array_resize(const f_number_unsigned_t length, const size_t width, void ** array, f_number_unsigned_t * const used, f_number_unsigned_t * const size) F_attribute_visibility_internal_d;
+#endif // !defined(_di_f_memory_array_decrease_by_) || !defined(_di_f_memory_array_increase_) || !defined(_di_f_memory_array_increase_by_) || !defined(_di_f_memory_array_resize_)
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _PRIVATE_F_memory_array_h
if (!size) return F_status_set_error(F_parameter);
#endif // _di_level_0_parameter_checking_
- if (amount && *size) {
- return private_f_memory_structure_adjust(amount <= *size ? *size - amount : 0, type_size, structure, used, size);
- }
+ if (amount && *size) return private_f_memory_structure_adjust(amount <= *size ? *size - amount : 0, type_size, structure, used, size);
return F_data_not;
}
if (!size) return F_status_set_error(F_parameter);
#endif // _di_level_0_parameter_checking_
- if (amount && *size) {
- return private_f_memory_structure_resize(amount <= *size ? *size - amount : 0, type_size, structure, used, size);
- }
+ if (amount && *size) return private_f_memory_structure_resize(amount <= *size ? *size - amount : 0, type_size, structure, used, size);
return F_data_not;
}
f_number_unsigned_t length_new = *used + step;
if (length_new > F_number_t_size_unsigned_d) {
- if (*used + 1 > F_number_t_size_unsigned_d) {
- return F_status_set_error(F_array_too_large);
- }
+ if (*used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large);
length_new = F_number_t_size_unsigned_d;
}
#endif // _di_level_0_parameter_checking_
if (amount && *used + amount > *size) {
- if (*used + amount > F_number_t_size_unsigned_d) {
- return F_status_set_error(F_array_too_large);
- }
+ if (*used + amount > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large);
return private_f_memory_structure_resize(*used + amount, type_size, structure, used, size);
}
build_libraries -lc
-build_sources_library memory.c private-memory.c memory/structure.c
+build_sources_library memory.c memory/array.c memory/structure.c
+build_sources_library private-memory.c memory/private-array.c
-build_sources_headers memory.h memory/common.h memory/structure.h
+build_sources_headers memory.h memory/array.h memory/common.h memory/structure.h
build_script yes
build_shared yes
build_libraries-individual -lf_memory
build_sources_program test-memory-adjust.c test-memory-delete.c test-memory-destroy.c test-memory-new_aligned.c test-memory-new.c test-memory-resize.c test-memory.c
+build_sources_program test-memory-array_adjust.c test-memory-array_decimate_by.c test-memory-array_decrease_by.c test-memory-array_increase.c test-memory-array_increase_by.c test-memory-array_resize.c
build_script no
build_shared yes
--- /dev/null
+#include "test-memory.h"
+#include "test-memory-array_adjust.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_memory_array_adjust__parameter_checking(void **state) {
+
+ const int length = 5;
+ test_memory_array_t data = test_memory_array_t_initialize;
+
+ {
+ const f_status_t status = f_memory_array_adjust(length, sizeof(int), 0, 0, 0);
+
+ assert_int_equal(status, F_status_set_error(F_parameter));
+ assert_int_equal(data.used, 0);
+ assert_int_equal(data.size, 0);
+ }
+
+ {
+ const f_status_t status = f_memory_array_adjust(length, sizeof(int), 0, &data.used, &data.size);
+
+ assert_int_equal(status, F_status_set_error(F_parameter));
+ assert_int_equal(data.used, 0);
+ assert_int_equal(data.size, 0);
+ }
+
+ {
+ const f_status_t status = f_memory_array_adjust(length, sizeof(int), (void **) &data.array, 0, &data.size);
+
+ assert_int_equal(status, F_status_set_error(F_parameter));
+ assert_int_equal(data.used, 0);
+ assert_int_equal(data.size, 0);
+ }
+
+ {
+ const f_status_t status = f_memory_array_adjust(length, sizeof(int), (void **) &data.array, &data.used, 0);
+
+ assert_int_equal(status, F_status_set_error(F_parameter));
+ assert_int_equal(data.used, 0);
+ assert_int_equal(data.size, 0);
+ }
+
+ assert_null(data.array);
+}
+
+void test__f_memory_array_adjust__returns_array_too_large(void **state) {
+
+ const f_number_unsigned_t length = F_number_t_size_unsigned_d + 1;
+ test_memory_array_t data = test_memory_array_t_initialize;
+
+ {
+ const f_status_t status = f_memory_array_adjust(length, sizeof(int), (void **) &data.array, &data.used, &data.size);
+
+ assert_int_equal(status, F_status_set_error(F_array_too_large));
+ assert_int_equal(data.used, 0);
+ assert_int_equal(data.size, 0);
+ }
+}
+
+void test__f_memory_array_adjust__works(void **state) {
+
+ const int length = 5;
+ test_memory_array_t data = test_memory_array_t_initialize;
+
+ {
+ const f_status_t status = f_memory_array_adjust(length, sizeof(int), (void **) &data.array, &data.used, &data.size);
+
+ assert_int_equal(status, F_none);
+ assert_int_equal(data.used, 0);
+ assert_int_equal(data.size, length);
+ }
+
+ free((void *) data.array);
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: FSS
+ * API Version: 0.7
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test set quote adjust in the fss project.
+ */
+#ifndef _TEST__F_fss__simple_packet_range_adjust
+#define _TEST__F_fss__simple_packet_range_adjust
+
+/**
+ * Test that the function correctly fails on invalid parameter.
+ *
+ * @see f_memory_array_adjust()
+ */
+extern void test__f_memory_array_adjust__parameter_checking(void **state);
+
+/**
+ * Test that the function returns F_array_too_large.
+ *
+ * @see f_memory_array_adjust()
+ */
+extern void test__f_memory_array_adjust__returns_array_too_large(void **state);
+
+/**
+ * Test that the function works.
+ *
+ * @see f_memory_array_adjust()
+ */
+extern void test__f_memory_array_adjust__works(void **state);
+
+#endif // _TEST__F_fss__simple_packet_range_adjust
--- /dev/null
+#include "test-memory.h"
+#include "test-memory-array_decimate_by.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_memory_array_decimate_by__parameter_checking(void **state) {
+
+ const int length = 5;
+ test_memory_array_t data = test_memory_array_t_initialize;
+
+ {
+ const f_status_t status = f_memory_array_decimate_by(length, sizeof(int), 0, 0, 0);
+
+ assert_int_equal(status, F_status_set_error(F_parameter));
+ assert_int_equal(data.size, 0);
+ }
+
+ {
+ const f_status_t status = f_memory_array_decimate_by(length, sizeof(int), 0, &data.used, &data.size);
+
+ assert_int_equal(status, F_status_set_error(F_parameter));
+ assert_int_equal(data.used, 0);
+ assert_int_equal(data.size, 0);
+ }
+
+ {
+ const f_status_t status = f_memory_array_decimate_by(length, sizeof(int), (void **) &data.array, 0, &data.size);
+
+ assert_int_equal(status, F_status_set_error(F_parameter));
+ assert_int_equal(data.used, 0);
+ assert_int_equal(data.size, 0);
+ }
+
+ {
+ const f_status_t status = f_memory_array_decimate_by(length, sizeof(int), (void **) &data.array, &data.used, 0);
+
+ assert_int_equal(status, F_status_set_error(F_parameter));
+ assert_int_equal(data.used, 0);
+ assert_int_equal(data.size, 0);
+ }
+
+ assert_null(data.array);
+}
+
+void test__f_memory_array_decimate_by__returns_data_not(void **state) {
+
+ const int length = 5;
+ test_memory_array_t data = test_memory_array_t_initialize;
+
+ {
+ const f_status_t status = f_memory_array_resize(length, sizeof(int), (void **) &data.array, &data.used, &data.size);
+
+ assert_int_equal(status, F_none);
+ assert_int_equal(data.used, 0);
+ assert_int_equal(data.size, length);
+ }
+
+ {
+ const f_status_t status = f_memory_array_decimate_by(0, sizeof(int), (void **) &data.array, &data.used, &data.size);
+
+ assert_int_equal(status, F_data_not);
+ assert_int_equal(data.used, 0);
+ assert_int_equal(data.size, length);
+ }
+
+ free((void *) data.array);
+}
+
+void test__f_memory_array_decimate_by__works(void **state) {
+
+ const int length = 5;
+ test_memory_array_t data = test_memory_array_t_initialize;
+
+ {
+ const f_status_t status = f_memory_array_resize(length, sizeof(int), (void **) &data.array, &data.used, &data.size);
+
+ assert_int_equal(status, F_none);
+ assert_int_equal(data.used, 0);
+ assert_int_equal(data.size, length);
+ }
+
+ {
+ const f_status_t status = f_memory_array_decimate_by(length, sizeof(int), (void **) &data.array, &data.used, &data.size);
+
+ assert_int_equal(status, F_none);
+ assert_int_equal(data.used, 0);
+ assert_int_equal(data.size, 0);
+ }
+
+ assert_null(data.array);
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: FSS
+ * API Version: 0.7
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test set quote decimate by in the fss project.
+ */
+#ifndef _TEST__F_fss__simple_packet_range_decimate_by
+#define _TEST__F_fss__simple_packet_range_decimate_by
+
+/**
+ * Test that the function correctly fails on invalid parameter.
+ *
+ * @see f_memory_array_decimate_by()
+ */
+extern void test__f_memory_array_decimate_by__parameter_checking(void **state);
+
+/**
+ * Test that the function returns F_data_not.
+ *
+ * @see f_memory_array_decimate_by()
+ */
+extern void test__f_memory_array_decimate_by__returns_data_not(void **state);
+
+/**
+ * Test that the function works.
+ *
+ * @see f_memory_array_decimate_by()
+ */
+extern void test__f_memory_array_decimate_by__works(void **state);
+
+#endif // _TEST__F_fss__simple_packet_range_decimate_by
--- /dev/null
+#include "test-memory.h"
+#include "test-memory-array_decrease_by.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_memory_array_decrease_by__parameter_checking(void **state) {
+
+ const int length = 5;
+ test_memory_array_t data = test_memory_array_t_initialize;
+
+ {
+ const f_status_t status = f_memory_array_decrease_by(length, sizeof(int), 0, 0, 0);
+
+ assert_int_equal(status, F_status_set_error(F_parameter));
+ assert_int_equal(data.size, 0);
+ }
+
+ {
+ const f_status_t status = f_memory_array_decrease_by(length, sizeof(int), 0, &data.used, &data.size);
+
+ assert_int_equal(status, F_status_set_error(F_parameter));
+ assert_int_equal(data.used, 0);
+ assert_int_equal(data.size, 0);
+ }
+
+ {
+ const f_status_t status = f_memory_array_decrease_by(length, sizeof(int), (void **) &data.array, 0, &data.size);
+
+ assert_int_equal(status, F_status_set_error(F_parameter));
+ assert_int_equal(data.used, 0);
+ assert_int_equal(data.size, 0);
+ }
+
+ {
+ const f_status_t status = f_memory_array_decrease_by(length, sizeof(int), (void **) &data.array, &data.used, 0);
+
+ assert_int_equal(status, F_status_set_error(F_parameter));
+ assert_int_equal(data.used, 0);
+ assert_int_equal(data.size, 0);
+ }
+
+ assert_null(data.array);
+}
+
+void test__f_memory_array_decrease_by__returns_data_not(void **state) {
+
+ const int length = 5;
+ test_memory_array_t data = test_memory_array_t_initialize;
+
+ {
+ const f_status_t status = f_memory_array_resize(length, sizeof(int), (void **) &data.array, &data.used, &data.size);
+
+ assert_int_equal(status, F_none);
+ assert_int_equal(data.used, 0);
+ assert_int_equal(data.size, length);
+ }
+
+ {
+ const f_status_t status = f_memory_array_decrease_by(0, sizeof(int), (void **) &data.array, &data.used, &data.size);
+
+ assert_int_equal(status, F_data_not);
+ assert_int_equal(data.used, 0);
+ assert_int_equal(data.size, length);
+ }
+
+ free((void *) data.array);
+}
+
+void test__f_memory_array_decrease_by__works(void **state) {
+
+ const int length = 5;
+ test_memory_array_t data = test_memory_array_t_initialize;
+
+ {
+ const f_status_t status = f_memory_array_resize(length, sizeof(int), (void **) &data.array, &data.used, &data.size);
+
+ assert_int_equal(status, F_none);
+ assert_int_equal(data.used, 0);
+ assert_int_equal(data.size, length);
+ }
+
+ {
+ const f_status_t status = f_memory_array_decrease_by(length, sizeof(int), (void **) &data.array, &data.used, &data.size);
+
+ assert_int_equal(status, F_none);
+ assert_int_equal(data.used, 0);
+ assert_int_equal(data.size, 0);
+ }
+
+ assert_null(data.array);
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: FSS
+ * API Version: 0.7
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test set quote decrease by in the fss project.
+ */
+#ifndef _TEST__F_fss__simple_packet_range_decrease_by
+#define _TEST__F_fss__simple_packet_range_decrease_by
+
+/**
+ * Test that the function correctly fails on invalid parameter.
+ *
+ * @see f_memory_array_decrease_by()
+ */
+extern void test__f_memory_array_decrease_by__parameter_checking(void **state);
+
+/**
+ * Test that the function returns F_data_not.
+ *
+ * @see f_memory_array_decrease_by()
+ */
+extern void test__f_memory_array_decrease_by__returns_data_not(void **state);
+
+/**
+ * Test that the function works.
+ *
+ * @see f_memory_array_decrease_by()
+ */
+extern void test__f_memory_array_decrease_by__works(void **state);
+
+#endif // _TEST__F_fss__simple_packet_range_decrease_by
--- /dev/null
+#include "test-memory.h"
+#include "test-memory-array_increase.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_memory_array_increase__parameter_checking(void **state) {
+
+ const int length = 5;
+ test_memory_array_t data = test_memory_array_t_initialize;
+
+ {
+ const f_status_t status = f_memory_array_increase(length, sizeof(int), 0, 0, 0);
+
+ assert_int_equal(status, F_status_set_error(F_parameter));
+ assert_int_equal(data.size, 0);
+ }
+
+ {
+ const f_status_t status = f_memory_array_increase(length, sizeof(int), 0, &data.used, &data.size);
+
+ assert_int_equal(status, F_status_set_error(F_parameter));
+ assert_int_equal(data.used, 0);
+ assert_int_equal(data.size, 0);
+ }
+
+ {
+ const f_status_t status = f_memory_array_increase(length, sizeof(int), (void **) &data.array, 0, &data.size);
+
+ assert_int_equal(status, F_status_set_error(F_parameter));
+ assert_int_equal(data.used, 0);
+ assert_int_equal(data.size, 0);
+ }
+
+ {
+ const f_status_t status = f_memory_array_increase(length, sizeof(int), (void **) &data.array, &data.used, 0);
+
+ assert_int_equal(status, F_status_set_error(F_parameter));
+ assert_int_equal(data.used, 0);
+ assert_int_equal(data.size, 0);
+ }
+
+ assert_null(data.array);
+}
+
+void test__f_memory_array_increase__returns_array_too_large(void **state) {
+
+ const f_number_unsigned_t length = F_number_t_size_unsigned_d + 1;
+ test_memory_array_t data = test_memory_array_t_initialize;
+
+ {
+ const f_status_t status = f_memory_array_increase(length, sizeof(int), (void **) &data.array, &data.used, &data.size);
+
+ assert_int_equal(status, F_status_set_error(F_array_too_large));
+ assert_int_equal(data.used, 0);
+ assert_int_equal(data.size, 0);
+ }
+}
+
+void test__f_memory_array_increase__returns_data_not(void **state) {
+
+ const int length = 5;
+ test_memory_array_t data = test_memory_array_t_initialize;
+
+ {
+ const f_status_t status = f_memory_array_resize(length, sizeof(int), (void **) &data.array, &data.used, &data.size);
+
+ assert_int_equal(status, F_none);
+ assert_int_equal(data.used, 0);
+ assert_int_equal(data.size, length);
+ }
+
+ {
+ const f_status_t status = f_memory_array_increase(0, sizeof(int), (void **) &data.array, &data.used, &data.size);
+
+ assert_int_equal(status, F_data_not);
+ assert_int_equal(data.used, 0);
+ assert_int_equal(data.size, length);
+ }
+
+ free((void *) data.array);
+}
+
+void test__f_memory_array_increase__works(void **state) {
+
+ const int length = 5;
+ test_memory_array_t data = test_memory_array_t_initialize;
+
+ {
+ const f_status_t status = f_memory_array_resize(length, sizeof(int), (void **) &data.array, &data.used, &data.size);
+
+ assert_int_equal(status, F_none);
+ assert_int_equal(data.used, 0);
+ assert_int_equal(data.size, length);
+ }
+
+ {
+ data.used = length;
+
+ const f_status_t status = f_memory_array_increase(1, sizeof(int), (void **) &data.array, &data.used, &data.size);
+
+ assert_int_equal(status, F_none);
+ assert_int_equal(data.used, length);
+ assert_int_equal(data.size, length + 1);
+ }
+
+ free((void *) data.array);
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: FSS
+ * API Version: 0.7
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test set quote increase in the fss project.
+ */
+#ifndef _TEST__F_fss__simple_packet_range_increase
+#define _TEST__F_fss__simple_packet_range_increase
+
+/**
+ * Test that the function correctly fails on invalid parameter.
+ *
+ * @see f_memory_array_increase()
+ */
+extern void test__f_memory_array_increase__parameter_checking(void **state);
+
+/**
+ * Test that the function returns F_array_too_large.
+ *
+ * @see f_memory_array_increase()
+ */
+extern void test__f_memory_array_increase__returns_array_too_large(void **state);
+
+/**
+ * Test that the function returns F_data_not.
+ *
+ * @see f_memory_array_increase()
+ */
+extern void test__f_memory_array_increase__returns_data_not(void **state);
+
+/**
+ * Test that the function works.
+ *
+ * @see f_memory_array_increase()
+ */
+extern void test__f_memory_array_increase__works(void **state);
+
+#endif // _TEST__F_fss__simple_packet_range_increase
--- /dev/null
+#include "test-memory.h"
+#include "test-memory-array_increase_by.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_memory_array_increase_by__parameter_checking(void **state) {
+
+ const int length = 5;
+ test_memory_array_t data = test_memory_array_t_initialize;
+
+ {
+ const f_status_t status = f_memory_array_increase_by(length, sizeof(int), 0, 0, 0);
+
+ assert_int_equal(status, F_status_set_error(F_parameter));
+ assert_int_equal(data.used, 0);
+ assert_int_equal(data.size, 0);
+ }
+
+ {
+ const f_status_t status = f_memory_array_increase_by(length, sizeof(int), 0, &data.used, &data.size);
+
+ assert_int_equal(status, F_status_set_error(F_parameter));
+ assert_int_equal(data.used, 0);
+ assert_int_equal(data.size, 0);
+ }
+
+ {
+ const f_status_t status = f_memory_array_increase_by(length, sizeof(int), (void **) &data.array, 0, &data.size);
+
+ assert_int_equal(status, F_status_set_error(F_parameter));
+ assert_int_equal(data.used, 0);
+ assert_int_equal(data.size, 0);
+ }
+
+ {
+ const f_status_t status = f_memory_array_increase_by(length, sizeof(int), (void **) &data.array, &data.used, 0);
+
+ assert_int_equal(status, F_status_set_error(F_parameter));
+ assert_int_equal(data.used, 0);
+ assert_int_equal(data.size, 0);
+ }
+
+ assert_null(data.array);
+}
+
+void test__f_memory_array_increase_by__returns_array_too_large(void **state) {
+
+ const f_number_unsigned_t length = F_number_t_size_unsigned_d + 1;
+ test_memory_array_t data = test_memory_array_t_initialize;
+
+ {
+ const f_status_t status = f_memory_array_increase_by(length, sizeof(int), (void **) &data.array, &data.used, &data.size);
+
+ assert_int_equal(status, F_status_set_error(F_array_too_large));
+ assert_int_equal(data.used, 0);
+ assert_int_equal(data.size, 0);
+ }
+}
+
+void test__f_memory_array_increase_by__returns_data_not(void **state) {
+
+ const int length = 5;
+ test_memory_array_t data = test_memory_array_t_initialize;
+
+ {
+ const f_status_t status = f_memory_array_resize(length, sizeof(int), (void **) &data.array, &data.used, &data.size);
+
+ assert_int_equal(status, F_none);
+ assert_int_equal(data.used, 0);
+ assert_int_equal(data.size, length);
+ }
+
+ {
+ const f_status_t status = f_memory_array_increase_by(0, sizeof(int), (void **) &data.array, &data.used, &data.size);
+
+ assert_int_equal(status, F_data_not);
+ assert_int_equal(data.used, 0);
+ assert_int_equal(data.size, length);
+ }
+
+ free((void *) data.array);
+}
+
+void test__f_memory_array_increase_by__works(void **state) {
+
+ const int length = 5;
+ test_memory_array_t data = test_memory_array_t_initialize;
+
+ {
+ const f_status_t status = f_memory_array_resize(length, sizeof(int), (void **) &data.array, &data.used, &data.size);
+
+ assert_int_equal(status, F_none);
+ assert_int_equal(data.used, 0);
+ assert_int_equal(data.size, length);
+ }
+
+ {
+ data.used = length;
+
+ const f_status_t status = f_memory_array_increase_by(length, sizeof(int), (void **) &data.array, &data.used, &data.size);
+
+ assert_int_equal(status, F_none);
+ assert_int_equal(data.used, length);
+ assert_int_equal(data.size, length * 2);
+ }
+
+ free((void *) data.array);
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: FSS
+ * API Version: 0.7
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test set quote increase by in the fss project.
+ */
+#ifndef _TEST__F_fss__simple_packet_range_increase_by
+#define _TEST__F_fss__simple_packet_range_increase_by
+
+/**
+ * Test that the function correctly fails on invalid parameter.
+ *
+ * @see f_memory_array_increase_by()
+ */
+extern void test__f_memory_array_increase_by__parameter_checking(void **state);
+
+/**
+ * Test that the function returns F_array_too_large.
+ *
+ * @see f_memory_array_increase_by()
+ */
+extern void test__f_memory_array_increase_by__returns_array_too_large(void **state);
+
+/**
+ * Test that the function returns F_data_not.
+ *
+ * @see f_memory_array_increase_by()
+ */
+extern void test__f_memory_array_increase_by__returns_data_not(void **state);
+
+/**
+ * Test that the function works.
+ *
+ * @see f_memory_array_increase_by()
+ */
+extern void test__f_memory_array_increase_by__works(void **state);
+
+#endif // _TEST__F_fss__simple_packet_range_increase_by
--- /dev/null
+#include "test-memory.h"
+#include "test-memory-array_resize.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_memory_array_resize__parameter_checking(void **state) {
+
+ const int length = 5;
+ test_memory_array_t data = test_memory_array_t_initialize;
+
+ {
+ const f_status_t status = f_memory_array_resize(length, sizeof(int), 0, 0, 0);
+
+ assert_int_equal(status, F_status_set_error(F_parameter));
+ assert_int_equal(data.used, 0);
+ assert_int_equal(data.size, 0);
+ }
+
+ assert_null(data.array);
+}
+
+void test__f_memory_array_resize__returns_array_too_large(void **state) {
+
+ const f_number_unsigned_t length = F_number_t_size_unsigned_d + 1;
+ test_memory_array_t data = test_memory_array_t_initialize;
+
+ {
+ const f_status_t status = f_memory_array_resize(length, sizeof(int), (void **) &data.array, &data.used, &data.size);
+
+ assert_int_equal(status, F_status_set_error(F_array_too_large));
+ assert_int_equal(data.used, 0);
+ assert_int_equal(data.size, 0);
+ }
+}
+
+void test__f_memory_array_resize__works(void **state) {
+
+ const int length = 5;
+ test_memory_array_t data = test_memory_array_t_initialize;
+
+ {
+ const f_status_t status = f_memory_array_resize(length, sizeof(int), (void **) &data.array, &data.used, &data.size);
+
+ assert_int_equal(status, F_none);
+ assert_int_equal(data.used, 0);
+ assert_int_equal(data.size, length);
+ }
+
+ free((void *) data.array);
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: FSS
+ * API Version: 0.7
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test set quote resize in the fss project.
+ */
+#ifndef _TEST__F_fss__simple_packet_range_resize
+#define _TEST__F_fss__simple_packet_range_resize
+
+/**
+ * Test that the function correctly fails on invalid parameter.
+ *
+ * @see f_memory_array_resize()
+ */
+extern void test__f_memory_array_resize__parameter_checking(void **state);
+
+/**
+ * Test that the function returns F_array_too_large.
+ *
+ * @see f_memory_array_resize()
+ */
+extern void test__f_memory_array_resize__returns_array_too_large(void **state);
+
+/**
+ * Test that the function works.
+ *
+ * @see f_memory_array_resize()
+ */
+extern void test__f_memory_array_resize__works(void **state);
+
+#endif // _TEST__F_fss__simple_packet_range_resize
cmocka_unit_test(test__f_memory_resize__works),
+ cmocka_unit_test(test__f_memory_array_adjust__returns_array_too_large),
+ cmocka_unit_test(test__f_memory_array_increase__returns_array_too_large),
+ cmocka_unit_test(test__f_memory_array_increase_by__returns_array_too_large),
+ cmocka_unit_test(test__f_memory_array_resize__returns_array_too_large),
+
+ cmocka_unit_test(test__f_memory_array_decimate_by__returns_data_not),
+ cmocka_unit_test(test__f_memory_array_decrease_by__returns_data_not),
+ cmocka_unit_test(test__f_memory_array_increase__returns_data_not),
+ cmocka_unit_test(test__f_memory_array_increase_by__returns_data_not),
+
+ cmocka_unit_test(test__f_memory_array_adjust__works),
+ cmocka_unit_test(test__f_memory_array_decimate_by__works),
+ cmocka_unit_test(test__f_memory_array_decrease_by__works),
+ cmocka_unit_test(test__f_memory_array_increase__works),
+ cmocka_unit_test(test__f_memory_array_increase_by__works),
+ cmocka_unit_test(test__f_memory_array_resize__works),
+
#ifndef _di_level_0_parameter_checking_
cmocka_unit_test(test__f_memory_adjust__parameter_checking),
cmocka_unit_test(test__f_memory_delete__parameter_checking),
cmocka_unit_test(test__f_memory_destroy__parameter_checking),
cmocka_unit_test(test__f_memory_new__parameter_checking),
cmocka_unit_test(test__f_memory_resize__parameter_checking),
+
+ cmocka_unit_test(test__f_memory_array_adjust__parameter_checking),
+ cmocka_unit_test(test__f_memory_array_decimate_by__parameter_checking),
+ cmocka_unit_test(test__f_memory_array_decrease_by__parameter_checking),
+ cmocka_unit_test(test__f_memory_array_increase__parameter_checking),
+ cmocka_unit_test(test__f_memory_array_increase_by__parameter_checking),
+ cmocka_unit_test(test__f_memory_array_resize__parameter_checking),
#endif // _di_level_0_parameter_checking_
};
// Test includes.
#include "test-memory-adjust.h"
+#include "test-memory-array_adjust.h"
+#include "test-memory-array_decimate_by.h"
+#include "test-memory-array_decrease_by.h"
+#include "test-memory-array_increase.h"
+#include "test-memory-array_increase_by.h"
+#include "test-memory-array_resize.h"
#include "test-memory-delete.h"
#include "test-memory-destroy.h"
#include "test-memory-new.h"
#endif
/**
+ * A structure used for testing the memory array functions.
+ */
+typedef struct {
+ int *array;
+ f_number_unsigned_t used;
+ f_number_unsigned_t size;
+} test_memory_array_t;
+
+#define test_memory_array_t_initialize { 0, 0, 0 }
+
+/**
* Perform any setup operations.
*
* @param state
extern "C" {
#endif
-#if !defined(_di_f_sockets_adjust_) || !defined(_di_f_sockets_decimate_by_)
- f_status_t private_f_sockets_adjust(const f_number_unsigned_t length, f_sockets_t * const sockets) {
-
- const f_status_t status = f_memory_adjust(sockets->size, length, sizeof(f_socket_t), (void **) & sockets->array);
- if (F_status_is_error(status)) return status;
-
- sockets->size = length;
-
- if (sockets->used > sockets->size) {
- sockets->used = length;
- }
-
- return F_none;
- }
-#endif // !defined(_di_f_sockets_adjust_) || !defined(_di_f_sockets_decimate_by_)
-
#if !defined(_di_f_sockets_append_) || !defined(_di_f_socketss_append_)
extern f_status_t private_f_sockets_append(const f_socket_t source, f_sockets_t * const destination) {
- if (destination->used + 1 > destination->size) {
- const f_status_t status = private_f_sockets_resize(destination->used + F_memory_default_allocation_small_d, destination);
- if (F_status_is_error(status)) return status;
- }
+ const f_status_t status = f_memory_array_increase(F_memory_default_allocation_small_d, sizeof(f_socket_t), (void **) &destination->array, &destination->used, &destination->size);
+ if (F_status_is_error(status)) return status;
destination->array[destination->used++] = source;
#if !defined(_di_f_sockets_append_) || !defined(_di_f_sockets_append_all_) || !defined(_di_f_socketss_append_all_)
extern f_status_t private_f_sockets_append_all(const f_sockets_t source, f_sockets_t * const destination) {
-
-
- if (destination->used + source.used > destination->size) {
- const f_status_t status = private_f_sockets_resize(destination->used + source.used, destination);
- if (F_status_is_error(status)) return status;
- }
+ const f_status_t status = f_memory_array_increase_by(source.used, sizeof(f_socket_t), (void **) &destination->array, &destination->used, &destination->size);
+ if (F_status_is_error(status)) return status;
for (f_number_unsigned_t i = 0; i < source.used; ++i) {
destination->array[destination->used++] = source.array[i];
}
#endif // !defined(_di_f_sockets_append_) || !defined(_di_f_sockets_append_all_) || !defined(_di_f_socketss_append_all_)
-#if !defined(_di_f_sockets_resize_) || !defined(_di_f_sockets_append_) || !defined(_di_f_sockets_decrease_by_) || !defined(_di_f_socketss_append_)
- f_status_t private_f_sockets_resize(const f_number_unsigned_t length, f_sockets_t * const sockets) {
-
- const f_status_t status = f_memory_resize(sockets->size, length, sizeof(f_socket_t), (void **) & sockets->array);
- if (F_status_is_error(status)) return status;
-
- sockets->size = length;
-
- if (sockets->used > sockets->size) {
- sockets->used = length;
- }
-
- return F_none;
- }
-#endif // !defined(_di_f_sockets_resize_) || !defined(_di_f_sockets_append_) || !defined(_di_f_sockets_decrease_by_) || !defined(_di_f_socketss_append_)
-
#if !defined(_di_f_socketss_adjust_) || !defined(_di_f_socketss_decimate_by_)
f_status_t private_f_socketss_adjust(const f_number_unsigned_t length, f_socketss_t * const socketss) {
for (f_number_unsigned_t i = length; i < socketss->size; ++i) {
- status = f_memory_destroy(socketss->array[i].size, sizeof(f_socket_t), (void **) & socketss->array[i].array);
+ status = f_memory_array_adjust(0, sizeof(f_socket_t), (void **) &socketss->array[i].array, &socketss->array[i].used, &socketss->array[i].size);
if (F_status_is_error(status)) return status;
-
- socketss->array[i].size = 0;
- socketss->array[i].used = 0;
} // for
- status = f_memory_adjust(socketss->size, length, sizeof(f_sockets_t), (void **) & socketss->array);
- if (F_status_is_error(status)) return status;
-
- socketss->size = length;
-
- if (socketss->used > socketss->size) {
- socketss->used = length;
- }
-
- return F_none;
+ return f_memory_array_adjust(length, sizeof(f_sockets_t), (void **) &socketss->array, &socketss->used, &socketss->size);
}
#endif // !defined(_di_f_socketss_adjust_) || !defined(_di_f_socketss_decimate_by_)
for (f_number_unsigned_t i = length; i < socketss->size; ++i) {
- status = f_memory_delete(socketss->array[i].size, sizeof(f_socket_t), (void **) & socketss->array[i].array);
+ status = f_memory_array_resize(0, sizeof(f_socket_t), (void **) &socketss->array[i].array, &socketss->array[i].used, &socketss->array[i].size);
if (F_status_is_error(status)) return status;
-
- socketss->array[i].size = 0;
- socketss->array[i].used = 0;
} // for
- status = f_memory_resize(socketss->size, length, sizeof(f_sockets_t), (void **) & socketss->array);
- if (F_status_is_error(status)) return status;
-
- socketss->size = length;
-
- if (socketss->used > socketss->size) {
- socketss->used = length;
- }
-
- return F_none;
+ return f_memory_array_resize(length, sizeof(f_sockets_t), (void **) &socketss->array, &socketss->used, &socketss->size);
}
#endif // !defined(_di_f_socketss_decrease_by_) || !defined(_di_f_socketss_increase_) || !defined(_di_f_socketss_increase_by_) || !defined(_di_f_socketss_resize_)
#endif
/**
- * Private implementation for resizing the sockets array.
- *
- * Intended to be shared to each of the different implementation variations.
- *
- * @param length
- * The length to adjust to.
- * @param sockets
- * The sockets array to adjust.
- *
- * @return
- * F_none on success.
- * F_data_not on success, but there is no reason to increase size (used + 1 <= size).
- *
- * Errors (with error bit) from: f_memory_adjust().
- *
- * @see f_sockets_adjust()
- * @see f_sockets_decimate_by()
- */
-#if !defined(_di_f_sockets_adjust_) || !defined(_di_f_sockets_decimate_by_)
- extern f_status_t private_f_sockets_adjust(const f_number_unsigned_t length, f_sockets_t * const sockets) F_attribute_visibility_internal_d;
-#endif // !defined(_di_f_sockets_adjust_) || !defined(_di_f_sockets_decimate_by_)
-
-/**
* Private implementation for appending the socket array.
*
* Intended to be shared to each of the different implementation variations.
#endif // !defined(_di_f_sockets_append_) || !defined(_di_f_sockets_append_all_) || !defined(_di_f_socketss_append_all_)
/**
- * Private implementation for resizing the sockets array.
- *
- * Intended to be shared to each of the different implementation variations.
- *
- * @param length
- * The length to adjust to.
- * @param sockets
- * The sockets array to adjust.
- *
- * @return
- * F_none on success.
- * F_data_not on success, but there is no reason to increase size (used + 1 <= size).
- *
- * Errors (with error bit) from: f_memory_resize().
- *
- * @see f_sockets_resize()
- * @see f_sockets_append()
- * @see f_sockets_decrease_by()
- * @see f_socketss_append()
- */
-#if !defined(_di_f_sockets_resize_) || !defined(_di_f_sockets_append_) || !defined(_di_f_sockets_decrease_by_) || !defined(_di_f_socketss_append_)
- extern f_status_t private_f_sockets_resize(const f_number_unsigned_t length, f_sockets_t * const sockets) F_attribute_visibility_internal_d;
-#endif // !defined(_di_f_sockets_resize_) || !defined(_di_f_sockets_append_) || !defined(_di_f_sockets_decrease_by_) || !defined(_di_f_socketss_append_)
-
-/**
* Private implementation for resizing the socketss array.
*
* Intended to be shared to each of the different implementation variations.
if (!sockets) return F_status_set_error(F_parameter);
#endif // _di_level_0_parameter_checking_
- return private_f_sockets_adjust(length, sockets);
+ return f_memory_array_adjust(length, sizeof(f_socket_t), (void **) &sockets->array, &sockets->used, &sockets->size);
}
#endif // _di_f_sockets_adjust_
if (!sockets) return F_status_set_error(F_parameter);
#endif // _di_level_0_parameter_checking_
- if (!amount) return F_data_not;
-
- if (sockets->size - amount > 0) {
- return private_f_sockets_adjust(sockets->size - amount, sockets);
- }
-
- return private_f_sockets_adjust(0, sockets);
+ return f_memory_array_decimate_by(amount, sizeof(f_socket_t), (void **) &sockets->array, &sockets->used, &sockets->size);
}
#endif // _di_f_sockets_decimate_by_
if (!sockets) return F_status_set_error(F_parameter);
#endif // _di_level_0_parameter_checking_
- if (!amount) return F_data_not;
-
- if (sockets->size - amount > 0) {
- return private_f_sockets_resize(sockets->size - amount, sockets);
- }
-
- return private_f_sockets_resize(0, sockets);
+ return f_memory_array_decrease_by(amount, sizeof(f_socket_t), (void **) &sockets->array, &sockets->used, &sockets->size);
}
#endif // _di_f_sockets_decrease_by_
if (!sockets) return F_status_set_error(F_parameter);
#endif // _di_level_0_parameter_checking_
- if (step && sockets->used + 1 > sockets->size) {
- f_number_unsigned_t size = sockets->used + step;
-
- if (size > F_number_t_size_unsigned_d) {
- if (sockets->used + 1 > F_number_t_size_unsigned_d) {
- return F_status_set_error(F_array_too_large);
- }
-
- size = F_number_t_size_unsigned_d;
- }
-
- return private_f_sockets_resize(size, sockets);
- }
-
- return F_data_not;
+ return f_memory_array_increase(step, sizeof(f_socket_t), (void **) &sockets->array, &sockets->used, &sockets->size);
}
#endif // _di_f_sockets_increase_
if (!sockets) return F_status_set_error(F_parameter);
#endif // _di_level_0_parameter_checking_
- if (!amount) return F_data_not;
-
- if (sockets->used + amount > sockets->size) {
- if (sockets->used + amount > F_number_t_size_unsigned_d) {
- return F_status_set_error(F_array_too_large);
- }
-
- return private_f_sockets_resize(sockets->used + amount, sockets);
- }
-
- return F_data_not;
+ return f_memory_array_increase_by(amount, sizeof(f_socket_t), (void **) &sockets->array, &sockets->used, &sockets->size);
}
#endif // _di_f_sockets_increase_by_
if (!sockets) return F_status_set_error(F_parameter);
#endif // _di_level_0_parameter_checking_
- return private_f_sockets_resize(length, sockets);
+ return f_memory_array_resize(length, sizeof(f_socket_t), (void **) &sockets->array, &sockets->used, &sockets->size);
}
#endif // _di_f_sockets_resize_
if (!source.used) return F_data_not;
- f_status_t status = F_none;
-
- if (destination->used + 1 > destination->size) {
- status = private_f_socketss_resize(destination->used + F_memory_default_allocation_small_d, destination);
- if (F_status_is_error(status)) return status;
- }
+ f_status_t status = f_memory_array_increase(F_memory_default_allocation_small_d, sizeof(f_sockets_t), (void **) &destination->array, &destination->used, &destination->size);
+ if (F_status_is_error(status)) return status;
status = private_f_sockets_append_all(source, &destination->array[destination->used]);
if (F_status_is_error(status)) return status;
if (!source.used) return F_data_not;
- f_status_t status = F_none;
-
- if (destination->used + source.used > destination->size) {
- status = private_f_socketss_resize(destination->used + source.used, destination);
- if (F_status_is_error(status)) return status;
- }
+ f_status_t status = f_memory_array_increase_by(source.used, sizeof(f_sockets_t), (void **) &destination->array, &destination->used, &destination->size);
+ if (F_status_is_error(status)) return status;
for (f_number_unsigned_t i = 0; i < source.used; ++i, ++destination->used) {
if (!amount) return F_data_not;
- if (socketss->size - amount > 0) {
- return private_f_socketss_adjust(socketss->size - amount, socketss);
- }
-
- return private_f_socketss_adjust(0, socketss);
+ return private_f_socketss_adjust((socketss->size - amount > 0) ? socketss->size - amount : 0, socketss);
}
#endif // _di_f_socketss_decimate_by_
if (!amount) return F_data_not;
- if (socketss->size - amount > 0) {
- return private_f_socketss_resize(socketss->size - amount, socketss);
- }
-
- return private_f_socketss_resize(0, socketss);
+ return private_f_socketss_resize((socketss->size - amount > 0) ? socketss->size - amount : 0, socketss);
}
#endif // _di_f_socketss_decrease_by_
if (!socketss) return F_status_set_error(F_parameter);
#endif // _di_level_0_parameter_checking_
- if (step && socketss->used + 1 > socketss->size) {
- f_number_unsigned_t size = socketss->used + step;
-
- if (size > F_number_t_size_unsigned_d) {
- if (socketss->used + 1 > F_number_t_size_unsigned_d) {
- return F_status_set_error(F_array_too_large);
- }
-
- size = F_number_t_size_unsigned_d;
- }
-
- return private_f_socketss_resize(size, socketss);
- }
-
- return F_data_not;
+ return f_memory_array_increase(step, sizeof(f_sockets_t), (void **) &socketss->array, &socketss->used, &socketss->size);
}
#endif // _di_f_socketss_increase_
if (!socketss) return F_status_set_error(F_parameter);
#endif // _di_level_0_parameter_checking_
- if (!amount) return F_data_not;
-
- if (socketss->used + amount > socketss->size) {
- if (socketss->used + amount > F_number_t_size_unsigned_d) {
- return F_status_set_error(F_array_too_large);
- }
-
- return private_f_socketss_resize(socketss->used + amount, socketss);
- }
-
- return F_data_not;
+ return f_memory_array_increase_by(amount, sizeof(f_sockets_t), (void **) &socketss->array, &socketss->used, &socketss->size);
}
#endif // _di_f_socketss_increase_by_
* The string sockets array to resize.
*
* @return
- * F_none on success.
+ * Success from f_memory_array_adjust().
*
* F_parameter (with error bit) if a parameter is invalid.
*
- * Errors (with error bit) from: f_memory_adjust().
+ * Errors (with error bit) from: f_memory_array_adjust().
+ *
+ * @see f_memory_array_adjust()
*/
#ifndef _di_f_sockets_adjust_
extern f_status_t f_sockets_adjust(const f_number_unsigned_t length, f_sockets_t * const sockets);
* F_none on success.
* F_data_not on success, but there is nothing to append (size == 0).
*
+ * Success from f_memory_array_resize().
+ *
* F_parameter (with error bit) if a parameter is invalid.
*
- * Errors (with error bit) from: f_memory_resize().
+ * Errors (with error bit) from: f_memory_array_increase_by().
+ * Errors (with error bit) from: f_memory_array_resize().
+ *
+ * @see f_memory_array_increase_by()
+ * @see f_memory_array_resize()
*/
#ifndef _di_f_sockets_append_
extern f_status_t f_sockets_append(const f_socket_t source, f_sockets_t * const destination);
* F_none on success.
* F_data_not on success, but there is nothing to append (size == 0).
*
+ * Success from f_memory_array_resize().
+ *
* F_parameter (with error bit) if a parameter is invalid.
*
- * Errors (with error bit) from: f_memory_resize().
+ * Errors (with error bit) from: f_memory_array_increase_by().
+ * Errors (with error bit) from: f_memory_array_resize().
+ *
+ * @see f_memory_array_increase_by()
+ * @see f_memory_array_resize()
*/
#ifndef _di_f_sockets_append_all_
extern f_status_t f_sockets_append_all(const f_sockets_t source, f_sockets_t * const destination);
* The string sockets array to resize.
*
* @return
- * F_none on success.
- * F_data_not if amount is 0.
+ * Success from f_memory_array_decimate_by().
*
* F_parameter (with error bit) if a parameter is invalid.
*
- * Errors (with error bit) from: f_memory_adjust().
+ * Errors (with error bit) from: f_memory_array_decimate_by().
+ *
+ * @see f_memory_array_decimate_by()
*/
#ifndef _di_f_sockets_decimate_by_
extern f_status_t f_sockets_decimate_by(const f_number_unsigned_t amount, f_sockets_t * const sockets);
* The string sockets array to resize.
*
* @return
- * F_none on success.
- * F_data_not if amount is 0.
+ * Success from f_memory_array_decrease_by().
*
* F_parameter (with error bit) if a parameter is invalid.
*
- * Errors (with error bit) from: f_memory_resize().
+ * Errors (with error bit) from: f_memory_array_decrease_by().
+ *
+ * @see f_memory_array_decrease_by()
*/
#ifndef _di_f_sockets_decrease_by_
extern f_status_t f_sockets_decrease_by(const f_number_unsigned_t amount, f_sockets_t * const sockets);
* The string sockets array to resize.
*
* @return
- * F_none on success.
- * F_data_not on success, but there is no reason to increase size (used + 1 <= size).
+ * Success from f_memory_array_increase().
*
- * F_array_too_large (with error bit) if the new array length is too large.
* F_parameter (with error bit) if a parameter is invalid.
*
- * Errors (with error bit) from: f_memory_resize().
+ * Errors (with error bit) from: f_memory_array_increase().
+ *
+ * @see f_memory_array_increase()
*/
#ifndef _di_f_sockets_increase_
extern f_status_t f_sockets_increase(const f_number_unsigned_t step, f_sockets_t * const sockets);
* The string sockets array to resize.
*
* @return
- * F_none on success.
- * F_data_not on success, but there is no reason to increase size (used + amount <= size).
+ * Success from f_memory_array_increase_by().
*
- * F_array_too_large (with error bit) if the new array length is too large.
* F_parameter (with error bit) if a parameter is invalid.
*
- * Errors (with error bit) from: f_memory_resize().
+ * Errors (with error bit) from: f_memory_array_increase_by().
+ *
+ * @see f_memory_array_increase_by()
*/
#ifndef _di_f_sockets_increase_by_
extern f_status_t f_sockets_increase_by(const f_number_unsigned_t amount, f_sockets_t * const sockets);
* The string sockets array to adjust.
*
* @return
- * F_none on success.
+ * Success from f_memory_array_resize().
*
* F_parameter (with error bit) if a parameter is invalid.
*
- * Errors (with error bit) from: f_memory_resize().
+ * Errors (with error bit) from: f_memory_array_resize().
+ *
+ * @see f_memory_array_resize()
*/
#ifndef _di_f_sockets_resize_
extern f_status_t f_sockets_resize(const f_number_unsigned_t length, f_sockets_t * const sockets);
* F_none on success.
* F_data_not on success, but there is nothing to append (size == 0).
*
+ * Success from f_memory_array_resize().
+ *
* F_parameter (with error bit) if a parameter is invalid.
*
- * Errors (with error bit) from: f_memory_resize().
+ * Errors (with error bit) from: f_memory_array_increase_by().
+ * Errors (with error bit) from: f_memory_array_resize().
+ *
+ * @see f_memory_array_increase_by()
+ * @see f_memory_array_resize()
*/
#ifndef _di_f_socketss_append_
extern f_status_t f_socketss_append(const f_sockets_t source, f_socketss_t * const destination);
* F_none on success.
* F_data_not on success, but there is nothing to append (size == 0).
*
+ * Success from f_memory_array_resize().
+ *
* F_parameter (with error bit) if a parameter is invalid.
*
- * Errors (with error bit) from: f_memory_resize().
+ * Errors (with error bit) from: f_memory_array_increase_by().
+ * Errors (with error bit) from: f_memory_array_resize().
+ *
+ * @see f_memory_array_increase_by()
+ * @see f_memory_array_resize()
*/
#ifndef _di_f_socketss_append_all_
extern f_status_t f_socketss_append_all(const f_socketss_t source, f_socketss_t * const destination);
* The string socketss array to resize.
*
* @return
- * F_none on success.
+ * F_data_not on success, but the amount to decrease by is 0.
+ *
+ * Success from f_memory_array_decimate_by().
*
* F_parameter (with error bit) if a parameter is invalid.
*
- * Errors (with error bit) from: f_memory_adjust().
- * Errors (with error bit) from: f_memory_destroy().
+ * Errors (with error bit) from: f_memory_array_decimate_by().
+ *
+ * @see f_memory_array_decimate_by()
*/
#ifndef _di_f_socketss_decimate_by_
extern f_status_t f_socketss_decimate_by(const f_number_unsigned_t amount, f_socketss_t * const socketss);
* The string socketss array to resize.
*
* @return
- * F_none on success.
+ * F_data_not on success, but the amount to decrease by is 0.
+ *
+ * Success from f_memory_array_decrease_by().
*
* F_parameter (with error bit) if a parameter is invalid.
*
- * Errors (with error bit) from: f_memory_delete().
- * Errors (with error bit) from: f_memory_resize().
+ * Errors (with error bit) from: f_memory_array_decrease_by().
+ *
+ * @see f_memory_array_decrease_by()
*/
#ifndef _di_f_socketss_decrease_by_
extern f_status_t f_socketss_decrease_by(const f_number_unsigned_t amount, f_socketss_t * const socketss);
* The string socketss array to resize.
*
* @return
- * F_none on success.
- * F_data_not on success, but there is no reason to increase size (used + 1 <= size).
+ * Success from f_memory_array_increase().
*
- * F_array_too_large (with error bit) if the new array length is too large.
* F_parameter (with error bit) if a parameter is invalid.
*
- * Errors (with error bit) from: f_memory_resize().
+ * Errors (with error bit) from: f_memory_array_increase().
+ *
+ * @see f_memory_array_increase()
*/
#ifndef _di_f_socketss_increase_
extern f_status_t f_socketss_increase(const f_number_unsigned_t step, f_socketss_t * const socketss);
* The string socketss array to resize.
*
* @return
- * F_none on success.
- * F_data_not on success, but there is no reason to increase size (used + amount <= size).
+ * Success from f_memory_array_increase_by().
*
- * F_array_too_large (with error bit) if the new array length is too large.
* F_parameter (with error bit) if a parameter is invalid.
*
- * Errors (with error bit) from: f_memory_resize().
+ * Errors (with error bit) from: f_memory_array_increase_by().
+ *
+ * @see f_memory_array_increase_by()
*/
#ifndef _di_f_socketss_increase_by_
extern f_status_t f_socketss_increase_by(const f_number_unsigned_t amount, f_socketss_t * const socketss);
* The string socketss array to adjust.
*
* @return
- * F_none on success.
+ * Success from f_memory_array_resize().
*
* F_parameter (with error bit) if a parameter is invalid.
*
- * Errors (with error bit) from: f_memory_delete().
- * Errors (with error bit) from: f_memory_resize().
+ * Errors (with error bit) from: f_memory_array_resize().
+ *
+ * @see f_memory_array_resize()
*/
#ifndef _di_f_socketss_resize_
extern f_status_t f_socketss_resize(const f_number_unsigned_t length, f_socketss_t * const socketss);