[Bf-blender-cvs] [54507234b79] blender2.8: RNA: use string join functions as with operators

Campbell Barton noreply at git.blender.org
Wed Aug 23 11:41:52 CEST 2017


Commit: 54507234b7955ac8ecb1bf50ef776ebbca4a6420
Author: Campbell Barton
Date:   Wed Aug 23 19:40:48 2017 +1000
Branches: blender2.8
https://developer.blender.org/rB54507234b7955ac8ecb1bf50ef776ebbca4a6420

RNA: use string join functions as with operators

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

M	source/blender/makesrna/intern/rna_wm_manipulator.c

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

diff --git a/source/blender/makesrna/intern/rna_wm_manipulator.c b/source/blender/makesrna/intern/rna_wm_manipulator.c
index b074433e3b5..e6bf68c4f3e 100644
--- a/source/blender/makesrna/intern/rna_wm_manipulator.c
+++ b/source/blender/makesrna/intern/rna_wm_manipulator.c
@@ -31,6 +31,7 @@
 #include "DNA_windowmanager_types.h"
 
 #include "BLI_utildefines.h"
+#include "BLI_string_utils.h"
 
 #include "BLT_translation.h"
 
@@ -446,11 +447,8 @@ static StructRNA *rna_Manipulator_register(
 	}
 
 	{   /* allocate the idname */
-		const uint idname_len = strlen(temp_buffers.idname) + 1;
-		char *ch = MEM_mallocN(
-		        sizeof(char) * idname_len, __func__);
-		dummywt.idname = ch;
-		memcpy(ch, temp_buffers.idname, idname_len);
+		/* For multiple strings see ManipulatorGroup. */
+		dummywt.idname = BLI_strdup(temp_buffers.idname);
 	}
 
 	/* create a new manipulator type */
@@ -754,15 +752,16 @@ static StructRNA *rna_ManipulatorGroup_register(
 	}
 
 	{   /* allocate the idname */
-		const uint idname_len = strlen(temp_buffers.idname) + 1;
-		const uint name_len = strlen(temp_buffers.name) + 1;
-		char *ch = MEM_mallocN(
-		        sizeof(char) * idname_len + name_len, __func__);
-		dummywgt.idname = ch;
-		memcpy(ch, temp_buffers.idname, idname_len);
-		ch += idname_len;
-		memcpy(ch, temp_buffers.name, name_len);
-		dummywgt.name = ch;
+		const char *strings[] = {
+			temp_buffers.idname,
+			temp_buffers.name,
+		};
+		char *strings_table[ARRAY_SIZE(strings)];
+		BLI_string_join_array_by_sep_char_with_tableN('\0', strings_table, strings, ARRAY_SIZE(strings));
+
+		dummywgt.idname = strings_table[0];  /* allocated string stored here */
+		dummywgt.name = strings_table[1];
+		BLI_assert(ARRAY_SIZE(strings) == 2);
 	}
 
 	/* create a new manipulatorgroup type */



More information about the Bf-blender-cvs mailing list