2022-02-11 09:07:11 +11:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
2015-10-20 14:39:08 +02:00
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup bli
|
|
|
|
|
* \brief Generic memory manipulation API.
|
2015-10-20 14:39:08 +02:00
|
|
|
*
|
|
|
|
|
* This is to extend on existing functions
|
2021-07-20 22:52:31 +10:00
|
|
|
* such as `memcpy` & `memcmp`.
|
2015-10-20 14:39:08 +02:00
|
|
|
*/
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
|
|
#include "BLI_sys_types.h"
|
|
|
|
|
#include "BLI_utildefines.h"
|
|
|
|
|
|
|
|
|
|
#include "BLI_memory_utils.h"
|
|
|
|
|
|
|
|
|
|
#include "BLI_strict_flags.h"
|
|
|
|
|
|
2020-09-04 20:59:13 +02:00
|
|
|
bool BLI_memory_is_zero(const void *arr, const size_t arr_size)
|
2015-10-20 14:39:08 +02:00
|
|
|
{
|
2020-09-04 20:59:13 +02:00
|
|
|
const char *arr_byte = arr;
|
|
|
|
|
const char *arr_end = (const char *)arr + arr_size;
|
2015-10-20 14:39:08 +02:00
|
|
|
|
2020-09-04 20:59:13 +02:00
|
|
|
while ((arr_byte != arr_end) && (*arr_byte == 0)) {
|
|
|
|
|
arr_byte++;
|
2015-10-20 14:39:08 +02:00
|
|
|
}
|
|
|
|
|
|
2020-09-04 20:59:13 +02:00
|
|
|
return (arr_byte == arr_end);
|
2015-10-20 14:39:08 +02:00
|
|
|
}
|