From: Kevin Day Date: Sat, 12 Aug 2023 03:28:09 +0000 (-0500) Subject: Update: Ensure pointers passed to the function are constant. X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=16a9af8f5d632d6f92c1f28aa5cddf1c0b477b8a;p=fll Update: Ensure pointers passed to the function are constant. The function should never be allowed to change the pointer itself. A double pointer is used so that the value of the pointer can be another pointer which can then be changed. --- diff --git a/level_0/f_memory/c/memory/array.c b/level_0/f_memory/c/memory/array.c index c73fbca..97d6215 100644 --- a/level_0/f_memory/c/memory/array.c +++ b/level_0/f_memory/c/memory/array.c @@ -6,7 +6,7 @@ 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) { + 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) { #ifndef _di_level_0_parameter_checking_ if (!width) return F_status_set_error(F_parameter); if (!array) return F_status_set_error(F_parameter); @@ -21,7 +21,7 @@ extern "C" { #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 ** 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 * const used, f_number_unsigned_t * 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); @@ -54,7 +54,7 @@ extern "C" { #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 ** 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 * const used, f_number_unsigned_t * 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); @@ -88,7 +88,7 @@ extern "C" { #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 ** 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 ** const array, f_number_unsigned_t * const used, f_number_unsigned_t * 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); @@ -103,7 +103,7 @@ extern "C" { #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) { + 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) { #ifndef _di_level_0_parameter_checking_ if (!width) return F_status_set_error(F_parameter); if (!array) return F_status_set_error(F_parameter); @@ -118,7 +118,7 @@ extern "C" { #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) { + 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) { #ifndef _di_level_0_parameter_checking_ if (!width) return F_status_set_error(F_parameter); if (!array) return F_status_set_error(F_parameter); @@ -145,7 +145,7 @@ extern "C" { #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) { + 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) { #ifndef _di_level_0_parameter_checking_ if (!width) return F_status_set_error(F_parameter); if (!array) return F_status_set_error(F_parameter); @@ -170,7 +170,7 @@ extern "C" { #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) { + 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) { #ifndef _di_level_0_parameter_checking_ if (!width) return F_status_set_error(F_parameter); if (!array) return F_status_set_error(F_parameter); diff --git a/level_0/f_memory/c/memory/array.h b/level_0/f_memory/c/memory/array.h index f581a0c..53818be 100644 --- a/level_0/f_memory/c/memory/array.h +++ b/level_0/f_memory/c/memory/array.h @@ -43,7 +43,7 @@ extern "C" { * 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); + 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); #endif // _di_f_memory_array_adjust_ /** @@ -88,7 +88,7 @@ extern "C" { * 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 ** 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 * const used, f_number_unsigned_t * const size); #endif // _di_f_memory_array_append_ /** @@ -141,7 +141,7 @@ extern "C" { * 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 ** 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 * const used, f_number_unsigned_t * const size); #endif // _di_f_memory_array_append_all_ /** @@ -174,7 +174,7 @@ extern "C" { * 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); + 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); #endif // _di_f_memory_array_decimate_by_ /** @@ -207,7 +207,7 @@ extern "C" { * 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); + 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); #endif // _di_f_memory_array_decrease_by_ /** @@ -242,7 +242,7 @@ extern "C" { * 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); + 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); #endif // _di_f_memory_array_increase_ /** @@ -277,7 +277,7 @@ extern "C" { * 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); + 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); #endif // _di_f_memory_array_increase_by_ /** @@ -307,7 +307,7 @@ extern "C" { * 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); + 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); #endif // _di_f_memory_array_resize_ #ifdef __cplusplus diff --git a/level_0/f_memory/c/memory/arrays.c b/level_0/f_memory/c/memory/arrays.c index 2d16806..0e7d37b 100644 --- a/level_0/f_memory/c/memory/arrays.c +++ b/level_0/f_memory/c/memory/arrays.c @@ -6,7 +6,7 @@ extern "C" { #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 ** 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 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)) { #ifndef _di_level_0_parameter_checking_ if (!width) return F_status_set_error(F_parameter); if (!array) return F_status_set_error(F_parameter); @@ -27,7 +27,7 @@ extern "C" { #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 ** 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 ** 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)) { #ifndef _di_level_0_parameter_checking_ if (!width) return F_status_set_error(F_parameter); if (!array) return F_status_set_error(F_parameter); diff --git a/level_0/f_memory/c/memory/arrays.h b/level_0/f_memory/c/memory/arrays.h index 218ddcc..cd4a546 100644 --- a/level_0/f_memory/c/memory/arrays.h +++ b/level_0/f_memory/c/memory/arrays.h @@ -58,7 +58,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_memory_arrays_adjust_ - extern f_status_t f_memory_arrays_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_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_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)); #endif // _di_f_memory_arrays_adjust_ /** @@ -103,7 +103,7 @@ extern "C" { * 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 ** 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 ** 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)); #endif // _di_f_memory_arrays_resize_ #ifdef __cplusplus diff --git a/level_0/f_memory/c/memory/private-array.c b/level_0/f_memory/c/memory/private-array.c index 6d0b7f6..44c804d 100644 --- a/level_0/f_memory/c/memory/private-array.c +++ b/level_0/f_memory/c/memory/private-array.c @@ -7,7 +7,7 @@ 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) { + 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) { { const f_status_t status = private_f_memory_adjust(*size, length, width, array); @@ -25,7 +25,7 @@ extern "C" { #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 ** 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 * const size) { { const f_status_t status = private_f_memory_resize(*size, length, width, array); diff --git a/level_0/f_memory/c/memory/private-array.h b/level_0/f_memory/c/memory/private-array.h index 6172eeb..f04866c 100644 --- a/level_0/f_memory/c/memory/private-array.h +++ b/level_0/f_memory/c/memory/private-array.h @@ -42,7 +42,7 @@ extern "C" { * @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; + extern f_status_t private_f_memory_array_adjust(const f_number_unsigned_t length, const size_t width, void ** const const 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_) /** @@ -76,7 +76,7 @@ extern "C" { * @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 ** 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 ** const array, f_number_unsigned_t * const used, f_number_unsigned_t * 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