The design of the memory operations require that array, used, and size do not point to the same memory address.
Help prevent potential aliasing by adding restrict keyword.
The functions with only a single pointer in its parameters still has the restrict keyword added.
I opted to avoid adding the restrict keyword to some of the append and append all functions.
Those would require more attention before I am certain whether or not they should be allowed to have overlapping addresses.
I think they should not, but just in case, I put doing that on hold.
The callback could also use restrict but I have decided not to do that as well due to the number of files that I will need to change.
I will do this later.
#endif
#ifndef _di_f_memory_adjust_
- f_status_t f_memory_adjust(const size_t length_old, const size_t length_new, const size_t size, void ** const pointer) {
+ f_status_t f_memory_adjust(const size_t length_old, const size_t length_new, const size_t size, void ** restrict const pointer) {
#ifndef _di_level_0_parameter_checking_
if (!size) return F_status_set_error(F_parameter);
if (!pointer) return F_status_set_error(F_parameter);
#endif // _di_f_memory_adjust_
#ifndef _di_f_memory_delete_
- f_status_t f_memory_delete(const size_t length, const size_t size, void ** const pointer) {
+ f_status_t f_memory_delete(const size_t length, const size_t size, void ** restrict const pointer) {
#ifndef _di_level_0_parameter_checking_
if (!size) return F_status_set_error(F_parameter);
if (!pointer) return F_status_set_error(F_parameter);
#endif // _di_f_memory_delete_
#ifndef _di_f_memory_destroy_
- f_status_t f_memory_destroy(const size_t length, const size_t size, void ** const pointer) {
+ f_status_t f_memory_destroy(const size_t length, const size_t size, void ** restrict const pointer) {
#ifndef _di_level_0_parameter_checking_
if (!size) return F_status_set_error(F_parameter);
if (!pointer) return F_status_set_error(F_parameter);
#endif // _di_f_memory_destroy_
#ifndef _di_f_memory_new_
- f_status_t f_memory_new(const size_t length, const size_t size, void ** const pointer) {
+ f_status_t f_memory_new(const size_t length, const size_t size, void ** restrict const pointer) {
#ifndef _di_level_0_parameter_checking_
if (!size) return F_status_set_error(F_parameter);
if (!pointer) return F_status_set_error(F_parameter);
#ifndef _di_f_memory_new_aligned_
- f_status_t f_memory_new_aligned(const size_t length, const size_t alignment, void ** const pointer) {
+ f_status_t f_memory_new_aligned(const size_t length, const size_t alignment, void ** restrict const pointer) {
#ifndef _di_level_0_parameter_checking_
if (!alignment) return F_status_set_error(F_parameter);
if (!pointer) return F_status_set_error(F_parameter);
#endif // _di_f_memory_new_aligned_
#ifndef _di_f_memory_resize_
- f_status_t f_memory_resize(const size_t length_old, const size_t length_new, const size_t size, void ** const pointer) {
+ f_status_t f_memory_resize(const size_t length_old, const size_t length_new, const size_t size, void ** restrict const pointer) {
#ifndef _di_level_0_parameter_checking_
if (!size) return F_status_set_error(F_parameter);
if (!pointer) return F_status_set_error(F_parameter);
* @see realloc()
*/
#ifndef _di_f_memory_adjust_
- extern f_status_t f_memory_adjust(const size_t length_old, const size_t length_new, const size_t size, void ** const pointer);
+ extern f_status_t f_memory_adjust(const size_t length_old, const size_t length_new, const size_t size, void ** restrict const pointer);
#endif // _di_f_memory_adjust_
/**
* @see free()
*/
#ifndef _di_f_memory_delete_
- extern f_status_t f_memory_delete(const size_t length, const size_t size, void ** const pointer);
+ extern f_status_t f_memory_delete(const size_t length, const size_t size, void ** restrict const pointer);
#endif // _di_f_memory_delete_
/**
* @see memset()
*/
#ifndef _di_f_memory_destroy_
- extern f_status_t f_memory_destroy(const size_t length, const size_t size, void ** const pointer);
+ extern f_status_t f_memory_destroy(const size_t length, const size_t size, void ** restrict const pointer);
#endif // _di_f_memory_destroy_
/**
* @see memset()
*/
#ifndef _di_f_memory_new_
- extern f_status_t f_memory_new(const size_t length, const size_t size, void ** const pointer);
+ extern f_status_t f_memory_new(const size_t length, const size_t size, void ** restrict const pointer);
#endif // _di_f_memory_new_
/**
* @see memset()
*/
#ifndef _di_f_memory_new_aligned_
- extern f_status_t f_memory_new_aligned(const size_t length, const size_t alignment, void ** const pointer);
+ extern f_status_t f_memory_new_aligned(const size_t length, const size_t alignment, void ** restrict const pointer);
#endif // _di_f_memory_new_aligned_
/**
* @see realloc()
*/
#ifndef _di_f_memory_resize_
- extern f_status_t f_memory_resize(const size_t length_old, const size_t length_new, const size_t size, void ** const pointer);
+ extern f_status_t f_memory_resize(const size_t length_old, const size_t length_new, const size_t size, void ** restrict const pointer);
#endif // _di_f_memory_resize_
#ifdef __cplusplus
#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 ** const array, f_number_unsigned_t * const used, f_number_unsigned_t * const size) {
+ f_status_t f_memory_array_adjust(const f_number_unsigned_t length, const size_t width, void ** restrict const array, f_number_unsigned_t * restrict const used, f_number_unsigned_t * restrict const size) {
#ifndef _di_level_0_parameter_checking_
if (!width) return F_status_set_error(F_parameter);
if (!array) return F_status_set_error(F_parameter);
#endif // _di_f_memory_array_adjust_
#ifndef _di_f_memory_array_append_
- f_status_t f_memory_array_append(const void * const source, const size_t width, void ** const array, f_number_unsigned_t * const used, f_number_unsigned_t * const size) {
+ f_status_t f_memory_array_append(const void * const source, const size_t width, void ** const array, f_number_unsigned_t * restrict const used, f_number_unsigned_t * restrict const size) {
#ifndef _di_level_0_parameter_checking_
if (!source) return F_status_set_error(F_parameter);
if (!width) return F_status_set_error(F_parameter);
#endif // _di_f_memory_array_append_
#ifndef _di_f_memory_array_append_all_
- f_status_t f_memory_array_append_all(const void * const sources, const f_number_unsigned_t amount, const size_t width, void ** const array, f_number_unsigned_t * const used, f_number_unsigned_t * const size) {
+ f_status_t f_memory_array_append_all(const void * const sources, const f_number_unsigned_t amount, const size_t width, void ** const array, f_number_unsigned_t * restrict const used, f_number_unsigned_t * restrict const size) {
#ifndef _di_level_0_parameter_checking_
if (!sources) return F_status_set_error(F_parameter);
if (!width) return F_status_set_error(F_parameter);
#endif // _di_f_memory_array_append_all_
#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 ** const array, f_number_unsigned_t * const used, f_number_unsigned_t * const size) {
+ f_status_t f_memory_array_decimate_by(const f_number_unsigned_t amount, const size_t width, void ** restrict const array, f_number_unsigned_t * restrict const used, f_number_unsigned_t * restrict const size) {
#ifndef _di_level_0_parameter_checking_
if (!width) return F_status_set_error(F_parameter);
if (!array) return F_status_set_error(F_parameter);
#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 ** const array, f_number_unsigned_t * const used, f_number_unsigned_t * const size) {
+ f_status_t f_memory_array_decrease_by(const f_number_unsigned_t amount, const size_t width, void ** restrict const array, f_number_unsigned_t * restrict const used, f_number_unsigned_t * restrict const size) {
#ifndef _di_level_0_parameter_checking_
if (!width) return F_status_set_error(F_parameter);
if (!array) return F_status_set_error(F_parameter);
#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 ** const array, f_number_unsigned_t * const used, f_number_unsigned_t * const size) {
+ f_status_t f_memory_array_increase(const f_number_unsigned_t step, const size_t width, void ** restrict const array, f_number_unsigned_t * restrict const used, f_number_unsigned_t * restrict const size) {
#ifndef _di_level_0_parameter_checking_
if (!width) return F_status_set_error(F_parameter);
if (!array) return F_status_set_error(F_parameter);
#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 ** const array, f_number_unsigned_t * const used, f_number_unsigned_t * const size) {
+ f_status_t f_memory_array_increase_by(const f_number_unsigned_t amount, const size_t width, void ** restrict const array, f_number_unsigned_t * restrict const used, f_number_unsigned_t * restrict const size) {
#ifndef _di_level_0_parameter_checking_
if (!width) return F_status_set_error(F_parameter);
if (!array) return F_status_set_error(F_parameter);
#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 ** const array, f_number_unsigned_t * const used, f_number_unsigned_t * const size) {
+ f_status_t f_memory_array_resize(const f_number_unsigned_t length, const size_t width, void ** restrict const array, f_number_unsigned_t * restrict const used, f_number_unsigned_t * restrict const size) {
#ifndef _di_level_0_parameter_checking_
if (!width) return F_status_set_error(F_parameter);
if (!array) return F_status_set_error(F_parameter);
* 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 ** const array, f_number_unsigned_t * const used, f_number_unsigned_t * const size);
+ extern f_status_t f_memory_array_adjust(const f_number_unsigned_t length, const size_t width, void ** restrict const array, f_number_unsigned_t * restrict const used, f_number_unsigned_t * restrict const size);
#endif // _di_f_memory_array_adjust_
/**
* F_parameter (with error bit) if a parameter is invalid.
*/
#ifndef _di_f_memory_array_append_
- extern f_status_t f_memory_array_append(const void * const source, const size_t width, void ** const array, f_number_unsigned_t * const used, f_number_unsigned_t * const size);
+ extern f_status_t f_memory_array_append(const void * const source, const size_t width, void ** const array, f_number_unsigned_t * restrict const used, f_number_unsigned_t * restrict const size);
#endif // _di_f_memory_array_append_
/**
* F_parameter (with error bit) if a parameter is invalid.
*/
#ifndef _di_f_memory_array_append_all_
- extern f_status_t f_memory_array_append_all(const void * const sources, const f_number_unsigned_t amount, const size_t width, void ** const array, f_number_unsigned_t * const used, f_number_unsigned_t * const size);
+ extern f_status_t f_memory_array_append_all(const void * const sources, const f_number_unsigned_t amount, const size_t width, void ** const array, f_number_unsigned_t * restrict const used, f_number_unsigned_t * restrict const size);
#endif // _di_f_memory_array_append_all_
/**
* 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 ** const array, f_number_unsigned_t * const used, f_number_unsigned_t * const size);
+ extern f_status_t f_memory_array_decimate_by(const f_number_unsigned_t amount, const size_t width, void ** restrict const array, f_number_unsigned_t * restrict const used, f_number_unsigned_t * restrict const size);
#endif // _di_f_memory_array_decimate_by_
/**
* 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 ** const array, f_number_unsigned_t * const used, f_number_unsigned_t * const size);
+ extern f_status_t f_memory_array_decrease_by(const f_number_unsigned_t amount, const size_t width, void ** restrict const array, f_number_unsigned_t * restrict const used, f_number_unsigned_t * restrict const size);
#endif // _di_f_memory_array_decrease_by_
/**
* 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 ** const array, f_number_unsigned_t * const used, f_number_unsigned_t * const size);
+ extern f_status_t f_memory_array_increase(const f_number_unsigned_t step, const size_t width, void ** restrict const array, f_number_unsigned_t * restrict const used, f_number_unsigned_t * restrict const size);
#endif // _di_f_memory_array_increase_
/**
* 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 ** const array, f_number_unsigned_t * const used, f_number_unsigned_t * const size);
+ extern f_status_t f_memory_array_increase_by(const f_number_unsigned_t amount, const size_t width, void ** restrict const array, f_number_unsigned_t * restrict const used, f_number_unsigned_t * restrict const size);
#endif // _di_f_memory_array_increase_by_
/**
* 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 ** const array, f_number_unsigned_t * const used, f_number_unsigned_t * const size);
+ extern f_status_t f_memory_array_resize(const f_number_unsigned_t length, const size_t width, void ** restrict const array, f_number_unsigned_t * restrict const used, f_number_unsigned_t * restrict const size);
#endif // _di_f_memory_array_resize_
#ifdef __cplusplus
#endif
#ifndef _di_f_memory_arrays_adjust_
- f_status_t f_memory_arrays_adjust(const f_number_unsigned_t length, const size_t width, void ** const array, f_number_unsigned_t * const used, f_number_unsigned_t * const size, f_status_t (*callback)(const f_number_unsigned_t start, const f_number_unsigned_t size, void * const array)) {
+ f_status_t f_memory_arrays_adjust(const f_number_unsigned_t length, const size_t width, void ** const restrict array, f_number_unsigned_t * restrict const used, f_number_unsigned_t * restrict const size, f_status_t (*callback)(const f_number_unsigned_t start, const f_number_unsigned_t size, void * const array)) {
#ifndef _di_level_0_parameter_checking_
if (!width) return F_status_set_error(F_parameter);
if (!array) return F_status_set_error(F_parameter);
#endif // _di_f_memory_arrays_adjust_
#ifndef _di_f_memory_arrays_resize_
- f_status_t f_memory_arrays_resize(const f_number_unsigned_t length, const size_t width, void ** const array, f_number_unsigned_t * const used, f_number_unsigned_t * const size, f_status_t (*callback)(const f_number_unsigned_t start, const f_number_unsigned_t size, void * const array)) {
+ f_status_t f_memory_arrays_resize(const f_number_unsigned_t length, const size_t width, void ** restrict const array, f_number_unsigned_t * restrict const used, f_number_unsigned_t * restrict const size, f_status_t (*callback)(const f_number_unsigned_t start, const f_number_unsigned_t size, void * const array)) {
#ifndef _di_level_0_parameter_checking_
if (!width) return F_status_set_error(F_parameter);
if (!array) return F_status_set_error(F_parameter);
* F_parameter (with error bit) if a parameter is invalid.
*/
#ifndef _di_f_memory_arrays_resize_
- extern f_status_t f_memory_arrays_resize(const f_number_unsigned_t length, const size_t width, void ** const array, f_number_unsigned_t * const used, f_number_unsigned_t * const size, f_status_t (*callback)(const f_number_unsigned_t start, const f_number_unsigned_t size, void * const array));
+ extern f_status_t f_memory_arrays_resize(const f_number_unsigned_t length, const size_t width, void ** restrict const array, f_number_unsigned_t * restrict const used, f_number_unsigned_t * restrict const size, f_status_t (*callback)(const f_number_unsigned_t start, const f_number_unsigned_t size, void * const array));
#endif // _di_f_memory_arrays_resize_
#ifdef __cplusplus
#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 ** const array, f_number_unsigned_t * const used, f_number_unsigned_t * const size) {
+ f_status_t private_f_memory_array_adjust(const f_number_unsigned_t length, const size_t width, void ** restrict const array, f_number_unsigned_t * restrict const used, f_number_unsigned_t * restrict const size) {
{
const f_status_t status = private_f_memory_adjust(*size, length, width, array);
#endif // !defined(_di_f_memory_array_adjust_) || !defined(_di_f_memory_array_decimate_by_)
#if !defined(_di_f_memory_array_append_) || !defined(_di_f_memory_array_append_all_) || !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 ** const array, f_number_unsigned_t * const used, f_number_unsigned_t * const size) {
+ f_status_t private_f_memory_array_resize(const f_number_unsigned_t length, const size_t width, void ** const array, f_number_unsigned_t * const used, f_number_unsigned_t * restrict const size) {
{
const f_status_t status = private_f_memory_resize(*size, length, width, array);
* @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 ** const array, f_number_unsigned_t * const used, f_number_unsigned_t * const size) F_attribute_visibility_internal_d;
+ extern f_status_t private_f_memory_array_adjust(const f_number_unsigned_t length, const size_t width, void ** restrict const array, f_number_unsigned_t * restrict const used, f_number_unsigned_t * restrict const size) F_attribute_visibility_internal_d;
#endif // !defined(_di_f_memory_array_adjust_) || !defined(_di_f_memory_array_decimate_by_)
/**
* @see f_memory_resize()
*/
#if !defined(_di_f_memory_array_append_) || !defined(_di_f_memory_array_append_all_) || !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 ** const array, f_number_unsigned_t * const used, f_number_unsigned_t * const size) F_attribute_visibility_internal_d;
+ extern f_status_t private_f_memory_array_resize(const f_number_unsigned_t length, const size_t width, void ** restrict const array, f_number_unsigned_t * restrict const used, f_number_unsigned_t * restrict const size) F_attribute_visibility_internal_d;
#endif // !defined(_di_f_memory_array_append_) || !defined(_di_f_memory_array_append_all_) || !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