2023-08-16 00:20:26 +10:00
|
|
|
/* SPDX-FileCopyrightText: 2023 Blender Authors
|
2023-05-31 16:19:06 +02: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"
|
|
|
|
|
|
2024-02-14 13:40:31 +11:00
|
|
|
#include "BLI_strict_flags.h" /* Keep last. */
|
2015-10-20 14:39:08 +02:00
|
|
|
|
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
|
|
|
}
|