src/main/macosx/SDLMain.m
changeset 1211 304d8dd6a989
parent 1125 a6011e1394d9
child 1572 3a8920cc822b
--- a/src/main/macosx/SDLMain.m	Sun Jan 01 23:34:06 2006 +0000
+++ b/src/main/macosx/SDLMain.m	Sun Jan 01 23:45:52 2006 +0000
@@ -190,7 +190,7 @@
 }
 
 /* Replacement for NSApplicationMain */
-static void CustomApplicationMain (argc, argv)
+static void CustomApplicationMain (int argc, char **argv)
 {
     NSAutoreleasePool	*pool = [[NSAutoreleasePool alloc] init];
     SDLMain				*sdlMain;
@@ -251,8 +251,8 @@
     if (gCalledAppMainline)  /* app has started, ignore this document. */
         return FALSE;
 
-    unsigned buflen = [filename lengthOfBytesUsingEncoding:NSUTF8StringEncoding] + 1;
-    char *arg = (char *) malloc(buflen);
+    const char *temparg = [filename UTF8String];
+    char *arg = (char *) malloc(strlen(temparg) + 1);
     if (arg == NULL)
         return FALSE;
 
@@ -264,15 +264,10 @@
     }
     gArgv = newargv;
 
-    BOOL rc = [filename getCString:arg maxLength:buflen encoding:NSUTF8StringEncoding];
-    if (!rc)
-        free(arg);
-    else
-    {
-        gArgv[gArgc++] = arg;
-        gArgv[gArgc] = NULL;
-    }
-    return rc;
+    strcpy(arg, temparg);
+    gArgv[gArgc++] = arg;
+    gArgv[gArgc] = NULL;
+    return TRUE;
 }