src/main/macosx/SDLMain.m
changeset 1211 304d8dd6a989
parent 1125 a6011e1394d9
child 1572 3a8920cc822b
equal deleted inserted replaced
1210:8609567ea02f 1211:304d8dd6a989
   188     [windowMenu release];
   188     [windowMenu release];
   189     [windowMenuItem release];
   189     [windowMenuItem release];
   190 }
   190 }
   191 
   191 
   192 /* Replacement for NSApplicationMain */
   192 /* Replacement for NSApplicationMain */
   193 static void CustomApplicationMain (argc, argv)
   193 static void CustomApplicationMain (int argc, char **argv)
   194 {
   194 {
   195     NSAutoreleasePool	*pool = [[NSAutoreleasePool alloc] init];
   195     NSAutoreleasePool	*pool = [[NSAutoreleasePool alloc] init];
   196     SDLMain				*sdlMain;
   196     SDLMain				*sdlMain;
   197 
   197 
   198     /* Ensure the application object is initialised */
   198     /* Ensure the application object is initialised */
   249         return FALSE;
   249         return FALSE;
   250 
   250 
   251     if (gCalledAppMainline)  /* app has started, ignore this document. */
   251     if (gCalledAppMainline)  /* app has started, ignore this document. */
   252         return FALSE;
   252         return FALSE;
   253 
   253 
   254     unsigned buflen = [filename lengthOfBytesUsingEncoding:NSUTF8StringEncoding] + 1;
   254     const char *temparg = [filename UTF8String];
   255     char *arg = (char *) malloc(buflen);
   255     char *arg = (char *) malloc(strlen(temparg) + 1);
   256     if (arg == NULL)
   256     if (arg == NULL)
   257         return FALSE;
   257         return FALSE;
   258 
   258 
   259     char **newargv = (char **) realloc(gArgv, sizeof (char *) * (gArgc + 2));
   259     char **newargv = (char **) realloc(gArgv, sizeof (char *) * (gArgc + 2));
   260     if (newargv == NULL)
   260     if (newargv == NULL)
   262         free(arg);
   262         free(arg);
   263         return FALSE;
   263         return FALSE;
   264     }
   264     }
   265     gArgv = newargv;
   265     gArgv = newargv;
   266 
   266 
   267     BOOL rc = [filename getCString:arg maxLength:buflen encoding:NSUTF8StringEncoding];
   267     strcpy(arg, temparg);
   268     if (!rc)
   268     gArgv[gArgc++] = arg;
   269         free(arg);
   269     gArgv[gArgc] = NULL;
   270     else
   270     return TRUE;
   271     {
       
   272         gArgv[gArgc++] = arg;
       
   273         gArgv[gArgc] = NULL;
       
   274     }
       
   275     return rc;
       
   276 }
   271 }
   277 
   272 
   278 
   273 
   279 /* Called when the internal event loop has just started running */
   274 /* Called when the internal event loop has just started running */
   280 - (void) applicationDidFinishLaunching: (NSNotification *) note
   275 - (void) applicationDidFinishLaunching: (NSNotification *) note