[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [60096] branches/soc-2013-depsgraph_mt/ source/creator/creator.c: Second attempt at fixing windows + guardedalloc issues in main()

Joshua Leung aligorith at gmail.com
Fri Sep 13 04:31:16 CEST 2013


Revision: 60096
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=60096
Author:   aligorith
Date:     2013-09-13 02:31:15 +0000 (Fri, 13 Sep 2013)
Log Message:
-----------
Second attempt at fixing windows + guardedalloc issues in main()

Although previous fix compiled, it would crash on startup, since
the guardedalloc changes need to read from the args passed in.
Now use plain malloc for allocating the offending array, so that
we can grab the args before they're needed.

Modified Paths:
--------------
    branches/soc-2013-depsgraph_mt/source/creator/creator.c

Modified: branches/soc-2013-depsgraph_mt/source/creator/creator.c
===================================================================
--- branches/soc-2013-depsgraph_mt/source/creator/creator.c	2013-09-13 00:47:53 UTC (rev 60095)
+++ branches/soc-2013-depsgraph_mt/source/creator/creator.c	2013-09-13 02:31:15 UTC (rev 60096)
@@ -1467,13 +1467,21 @@
 #endif
 
 #ifdef WIN32 /* Win32 Unicode Args */
-	wchar_t **argv_16;
+	/* NOTE: cannot use guardedalloc malloc here, as it's not yet initialised 
+	 *       (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;
-	char **argv;
+	
+	for (argci = 0; argci < argc; argci++) {
+		argv[argci] = alloc_utf_8_from_16(argv_16[argci], 0);
+	}
+	
+	LocalFree(argv_16);
 #endif
 
-
-	/* NOTE: Special excpetion for guarded allocator type switch:
+	/* NOTE: Special exception for guarded allocator type switch:
 	 *       we need to perform switch from lock-free to fully
 	 *       guarded allocator before any allocation happened.
 	 */
@@ -1495,15 +1503,6 @@
 
 	C = CTX_create();
 
-#ifdef WIN32 /* Win32 Unicode Args */
-	argv_16 = CommandLineToArgvW(GetCommandLineW(), &argc);
-	argv = MEM_mallocN(argc * sizeof(char *), "argv array");
-	for (argci = 0; argci < argc; argci++) {
-		argv[argci] = alloc_utf_8_from_16(argv_16[argci], 0);
-	}
-	LocalFree(argv_16);
-#endif
-
 #ifdef WITH_PYTHON_MODULE
 #ifdef __APPLE__
 	environ = *_NSGetEnviron();
@@ -1675,7 +1674,7 @@
 	while (argci) {
 		free(argv[--argci]);
 	}
-	MEM_freeN(argv);
+	free(argv);
 	argv = NULL;
 #endif
 




More information about the Bf-blender-cvs mailing list