#endif // _di_level_0_parameter_checking_
if (step && *used + 1 > *size) {
- if (*used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large);
+ const f_number_unsigned_t length = *used + step;
- f_number_unsigned_t length = *used + step;
-
- if (length > F_number_t_size_unsigned_d) {
- if (*used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large);
-
- length = F_number_t_size_unsigned_d;
- }
+ if (length > F_number_t_size_unsigned_d || length < *used) return F_status_set_error(F_array_too_large);
return private_f_memory_array_resize(length, width, array, used, size);
}
#endif // _di_level_0_parameter_checking_
if (amount) {
- if (*used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large);
-
const f_number_unsigned_t length = *used + amount;
- if (length > *size) {
- if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large);
+ if (length > F_number_t_size_unsigned_d || length < *used) return F_status_set_error(F_array_too_large);
+ if (length > *size) {
return private_f_memory_array_resize(length, width, array, used, size);
}
}
* 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.
+ * If the simple type that is "array" requires additional memory manipulation on de-allocation, then do not use this function.
*
* @param amount
* A positive number representing how much to decimate the size by.
* 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.
+ * If the simple type that is "array" requires additional memory manipulation on de-allocation, then do not use this function.
*
* @param amount
* A positive number representing how much to decrease the size by.
#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.
+ * Increase the size of the memory array if and only if (used + 1 > size).
*
* 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.
+ * If the simple type that is "array" requires additional memory manipulation on allocation, then do not use this function.
*
* @param step
* The allocation step to use.
#endif // _di_f_memory_array_increase_
/**
- * Resize the memory array to a larger size.
+ * Increase the size of the memory array by the given amount.
*
* 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.
+ * If the simple type that is "array" requires additional memory manipulation on allocation, then do not use this function.
*
* @param amount
* A positive number representing how much to increase the size by.