[Bf-blender-cvs] [444a755] missing-libs: Missing from last commit

Campbell Barton noreply at git.blender.org
Tue Oct 20 11:02:06 CEST 2015


Commit: 444a755d863d01dc9d55b6309b531e8e55b33fae
Author: Campbell Barton
Date:   Tue Oct 20 19:56:21 2015 +1100
Branches: missing-libs
https://developer.blender.org/rB444a755d863d01dc9d55b6309b531e8e55b33fae

Missing from last commit

===================================================================

A	source/blender/blenlib/BLI_memory_utils.h
A	source/blender/blenlib/intern/memory_utils.c

===================================================================

diff --git a/source/blender/blenlib/BLI_memory_utils.h b/source/blender/blenlib/BLI_memory_utils.h
new file mode 100644
index 0000000..ab2542c
--- /dev/null
+++ b/source/blender/blenlib/BLI_memory_utils.h
@@ -0,0 +1,34 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef __BLI_MEMORY_UTILS_H__
+#define __BLI_MEMORY_UTILS_H__
+
+/** \file BLI_memory_utils.h
+ *  \ingroup bli
+ *  \brief Generic memory manipulation API.
+ */
+
+/* it may be defined already */
+#ifndef __BLI_UTILDEFINES_H__
+bool BLI_memory_is_zero(const void *arr, const size_t size);
+#endif
+
+#endif  /* __BLI_ARRAY_UTILS_H__ */
diff --git a/source/blender/blenlib/intern/memory_utils.c b/source/blender/blenlib/intern/memory_utils.c
new file mode 100644
index 0000000..1c1f408
--- /dev/null
+++ b/source/blender/blenlib/intern/memory_utils.c
@@ -0,0 +1,51 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/blenlib/intern/memory_utils.c
+ *  \ingroup bli
+ *  \brief Generic array manipulation API.
+ *
+ * \warning This is to extend on existing functions
+ * such as ``memcpy`` & ``memcmp``.
+ */
+#include <string.h>
+#include <stdlib.h>
+
+#include "BLI_sys_types.h"
+#include "BLI_utildefines.h"
+
+#include "BLI_memory_utils.h"
+
+#include "BLI_strict_flags.h"
+
+/**
+ * Check if memory is zero'd, as with memset(arr, 0, arr_size)
+ */
+bool BLI_memory_is_zero(const void *arr, const size_t arr_size)
+{
+	const char *arr_byte = arr;
+	const char *arr_end = (char *)arr + arr_size;
+
+	while ((arr_byte != arr_end) && (*arr_byte == 0)) {
+		arr_byte++;
+	}
+
+	return (arr_byte == arr_end);
+}




More information about the Bf-blender-cvs mailing list