[Bf-blender-cvs] [6f43e1d] master: Cleanup: win32 mixed declare/statements in main()

Campbell Barton noreply at git.blender.org
Fri Mar 27 18:12:48 CET 2015


Commit: 6f43e1dfef3e5632976529a6f678292b15bd5a0c
Author: Campbell Barton
Date:   Sat Mar 28 03:32:56 2015 +1100
Branches: master
https://developer.blender.org/rB6f43e1dfef3e5632976529a6f678292b15bd5a0c

Cleanup: win32 mixed declare/statements in main()

Make it a more clear where declarations end
(ifdef's all over made it a bit confusing).

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

M	source/creator/creator.c

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

diff --git a/source/creator/creator.c b/source/creator/creator.c
index b2b6504..5b4f828 100644
--- a/source/creator/creator.c
+++ b/source/creator/creator.c
@@ -1559,13 +1559,13 @@ char **environ = NULL;
  *   or exit when running in background mode.
  */
 int main(
-       int argc,
+        int argc,
 #ifdef WIN32
         const char **UNUSED(argv_c)
 #else
         const char **argv
 #endif
-         )
+        )
 {
 	bContext *C;
 	SYS_SystemHandle syshandle;
@@ -1575,6 +1575,14 @@ int main(
 #endif
 
 #ifdef WIN32
+	char **argv;
+	int argv_num;
+#endif
+
+	/* --- end declarations --- */
+
+
+#ifdef WIN32
 	/* FMA3 support in the 2013 CRT is broken on Vista and Windows 7 RTM (fixed in SP1). Just disable it. */
 #  if defined(_MSC_VER) && _MSC_VER >= 1800 && defined(_M_X64)
 	_set_FMA3_enable(0);
@@ -1584,16 +1592,15 @@ int main(
 	/* NOTE: cannot use guardedalloc malloc here, as it's not yet initialized
 	 *       (it depends on the args passed in, which is what we're getting here!)
 	 */
-	wchar_t **argv_16 = CommandLineToArgvW(GetCommandLineW(), &argc);
-	char **argv = malloc(argc * sizeof(char *));
-	int argci = 0;
-	
-	for (argci = 0; argci < argc; argci++) {
-		argv[argci] = alloc_utf_8_from_16(argv_16[argci], 0);
+	{
+		wchar_t **argv_16 = CommandLineToArgvW(GetCommandLineW(), &argc);
+		argv = malloc(argc * sizeof(char *));
+		for (argv_num = 0; argv_num < argc; argv_num++) {
+			argv[argv_num] = alloc_utf_8_from_16(argv_16[argv_num], 0);
+		}
+		LocalFree(argv_16);
 	}
-	
-	LocalFree(argv_16);
-#endif
+#endif  /* WIN32 */
 
 	/* NOTE: Special exception for guarded allocator type switch:
 	 *       we need to perform switch from lock-free to fully
@@ -1661,7 +1668,7 @@ int main(
 	setCallbacks();
 	
 #if defined(__APPLE__) && !defined(WITH_PYTHON_MODULE)
-/* patch to ignore argument finder gives us (pid?) */
+	/* patch to ignore argument finder gives us (pid?) */
 	if (argc == 2 && STREQLEN(argv[1], "-psn_", 5)) {
 		extern int GHOST_HACK_getFirstFile(char buf[]);
 		static char firstfilebuf[512];
@@ -1819,8 +1826,8 @@ int main(
 #endif
 
 #ifdef WIN32
-	while (argci) {
-		free(argv[--argci]);
+	while (argv_num) {
+		free(argv[--argv_num]);
 	}
 	free(argv);
 	argv = NULL;




More information about the Bf-blender-cvs mailing list