Commit: 1f9fe0626fc0f6de449b62d88763faf8290e93b5
Author: Campbell Barton
Date:   Tue Apr 28 21:14:46 2015 +1000
Branches: master
https://developer.blender.org/rB1f9fe0626fc0f6de449b62d88763faf8290e93b5

BLI_utildefines: add MEMSET_STRUCT_OFS macro

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

M       source/blender/blenlib/BLI_utildefines.h

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

diff --git a/source/blender/blenlib/BLI_utildefines.h 
b/source/blender/blenlib/BLI_utildefines.h
index 2ddc8fa..d817aa9 100644
--- a/source/blender/blenlib/BLI_utildefines.h
+++ b/source/blender/blenlib/BLI_utildefines.h
@@ -493,8 +493,11 @@ extern "C" {
 #define OFFSETOF_STRUCT(_struct, _member) \
        ((((char *)&((_struct)->_member)) - ((char *)(_struct))) + 
sizeof((_struct)->_member))
 
-/* memcpy, skipping the first part of a struct,
- * ensures 'struct_dst' isn't const and that the offset can be computed at 
compile time */
+/**
+ * memcpy helper, skipping the first part of a struct,
+ * ensures 'struct_dst' isn't const and the offset can be computed at compile 
time.
+ * This isn't inclusive, the value of \a member isn't copied.
+ */
 #define MEMCPY_STRUCT_OFS(struct_dst, struct_src, member)  { \
        CHECK_TYPE_NONCONST(struct_dst); \
        ((void)(struct_dst == struct_src), \
@@ -503,6 +506,13 @@ extern "C" {
                sizeof(*(struct_dst)) - OFFSETOF_STRUCT(struct_dst, member))); \
 } (void)0
 
+#define MEMSET_STRUCT_OFS(struct_var, value, member)  { \
+       CHECK_TYPE_NONCONST(struct_var); \
+       memset((char *)(struct_var)  + OFFSETOF_STRUCT(struct_var, member), \
+              value, \
+              sizeof(*(struct_var)) - OFFSETOF_STRUCT(struct_var, member)); \
+} (void)0
+
 /* Warning-free macros for storing ints in pointers. Use these _only_
  * for storing an int in a pointer, not a pointer in an int (64bit)! */
 #define SET_INT_IN_POINTER(i)    ((void *)(intptr_t)(i))

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to