if (!pointer) return F_status_set_error(F_parameter);
#endif // _di_level_0_parameter_checking_
- // prevent double-frees.
+ // Prevent double-frees.
if (!*pointer || !size) {
return F_data_not;
}
free(*pointer);
- // it has been deallocated, so reset the pointer.
+ // It has been deallocated, so reset the pointer.
*pointer = 0;
return F_none;
if (!pointer) return F_status_set_error(F_parameter);
#endif // _di_level_0_parameter_checking_
- // prevent double-frees.
+ // Prevent double-frees.
if (!*pointer) {
return F_data_not;
}
free(*pointer);
- // it has been deallocated, so reset the pointer.
+ // It has been deallocated, so reset the pointer.
*pointer = 0;
return F_none;
return F_data_not;
}
- // Some people use malloc(size * length) to produce the same results.
- // This has been observed to sometimes causes an increase in L1/L2 cache misses (0.02% L1 increase, 0.01% L2 increase).
*pointer = calloc(length, size);
if (*pointer) {
-
- // 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.
- memset(((uint8_t *) *pointer), 0, size * length);
-
return F_none;
}
if (!pointer) return F_status_set_error(F_parameter);
#endif // _di_level_0_parameter_checking_
- // prevent double-allocations.
+ // Prevent double-allocations.
if (*pointer || !length) {
return F_data_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.
+ // uint8_t * is of a data 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.
memset(((uint8_t *) *pointer), 0, length);
return F_none;
if (length_new < length_old) {
// 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.
+ // This is done to avoid problems with (void *) having arithmetic issues.
memset(((uint8_t *) *pointer) + length_new, 0, type_size * (length_old - length_new));
}
}
if (length_new > length_old) {
// uint8_t * is of a data size size of 1, casting it to bool should result in a single-length increment.
- // this is done to avoid problems with (void *) having arithmetic issues.
+ // This is done to avoid problems with (void *) having arithmetic issues.
memset(((uint8_t *) new_pointer) + (type_size * length_old), 0, type_size * (length_new - length_old));
}
else {
free(*pointer);
- // assure that the pointer is always 0 after deallocation.
+ // Assure that the pointer is always 0 after deallocation.
*pointer = 0;
return F_none;
*pointer = calloc(type_size, length_new);
if (*pointer) {
- memset(*pointer, 0, type_size * length_new);
-
return F_none;
}
}
if (length_new > length_old) {
// uint8_t * is of a data size size of 1, casting it to bool should result in a single-length increment.
- // this is done to avoid problems with (void *) having arithmetic issues.
+ // This is done to avoid problems with (void *) having arithmetic issues.
memset(((uint8_t *) new_pointer) + (type_size * length_old), 0, type_size * (length_new - length_old));
}
else {
free(*pointer);
- // assure that the pointer is always 0 after deallocation.
+ // Assure that the pointer is always 0 after deallocation.
*pointer = 0;
return F_none;
*pointer = calloc(type_size, length_new);
if (*pointer) {
- memset(*pointer, 0, type_size * length_new);
-
return F_none;
}
}