return F_data_not;
}
- const int result = posix_memalign(pointer, alignment, length);
+ #ifdef _f_memory_USE_posix_memalign_
+ const int result = posix_memalign(pointer, alignment, length);
- if (result) {
- if (result == EINVAL) {
- return F_status_set_error(F_parameter);
+ if (result) {
+ if (result == EINVAL) {
+ return F_status_set_error(F_parameter);
+ }
+
+ return F_status_set_error(F_memory_not);
}
+ #else
+ void *result = aligned_alloc(alignment, length);
- return F_status_set_error(F_memory_not);
- }
+ if (result) {
+ *pointer = result;
+ }
+ else if (errno == EINVAL) {
+ return F_status_set_error(F_parameter);
+ }
+ else {
+ return F_status_set_error(F_memory_not);
+ }
+ #endif // _f_memory_USE_posix_memalign_
// uint8_t * is of a data size size of 1, casting it to uint8_t should result in a single-length increment.
// this is done to avoid problems with (void *) having arithmetic issues.
* Licenses: lgpl-2.1-or-later
*
* Provide means to use memory routines, with error checking.
- *
- * @todo consider adding f_memory_scramble() and f_memory_juggle().
- * f_memory_scramble() is like f_destroy() but it writes random data instead of 0.
- * f_memory_juggle() is like f_adjust() but it writes random data instead of 0.
*/
#ifndef _F_memory_h
#define _F_memory_h
* F_memory_not (with error bit) on allocation error.
* F_parameter (with error bit) if a parameter is invalid.
*
+ * @see aligned_alloc()
* @see posix_memalign()
* @see memset()
*/
# fss-0000
_f_memory_FORCE_secure_memory_ all to-be removed address spaces are set to 0 before freeing or resizing.
_f_memory_FORCE_fast_memory_ all to-be removed address spaces remain unchanged before freeing or resizing.
+_f_memory_USE_posix_memalign_ use POSIX memalign instead of aligned_alloc() (aligned_alloc() is in C as of C11 standard).