2323# include <limits.h>
2424#endif
2525
26- #ifdef FEAT_GUI_MACVIM
27- #include <objc/objc-runtime.h> /* for objc_*() and sel_*() */
28- #endif
29-
3026/* Maximum number of commands from + or -c arguments. */
3127#define MAX_ARG_CMDS 10
3228
180176 // Cocoa needs an NSAutoreleasePool in place or it will leak memory.
181177 // This particular pool will hold autorelease objects created during
182178 // initialization.
183- id autoreleasePool = objc_msgSend (objc_msgSend (
184- objc_getClass ("NSAutoreleasePool" ),sel_getUid ("alloc" )
185- ), sel_getUid ("init" ));
179+ void * autoreleasePool = gui_macvim_new_autoreleasepool ();
186180#endif
187181
188182 /*
@@ -1066,13 +1060,11 @@ vim_main2(int argc UNUSED, char **argv UNUSED)
10661060#ifdef FEAT_GUI_MACVIM
10671061 // The autorelease pool might have filled up quite a bit during
10681062 // initialization, so purge it before entering the main loop.
1069- objc_msgSend (autoreleasePool , sel_getUid ( "release" ) );
1063+ gui_macvim_release_autoreleasepool (autoreleasePool );
10701064
10711065 // The main loop sets up its own autorelease pool, but to be safe we still
10721066 // realloc this one here.
1073- autoreleasePool = objc_msgSend (objc_msgSend (
1074- objc_getClass ("NSAutoreleasePool" ),sel_getUid ("alloc" )
1075- ), sel_getUid ("init" ));
1067+ autoreleasePool = gui_macvim_new_autoreleasepool ();
10761068#endif
10771069
10781070 /*
@@ -1081,7 +1073,7 @@ vim_main2(int argc UNUSED, char **argv UNUSED)
10811073 main_loop (FALSE, FALSE);
10821074
10831075#ifdef FEAT_GUI_MACVIM
1084- objc_msgSend (autoreleasePool , sel_getUid ( "release" ) );
1076+ gui_macvim_release_autoreleasepool (autoreleasePool );
10851077#endif
10861078
10871079 return 0 ;
@@ -1152,9 +1144,7 @@ main_loop(cmdwin, noexmode)
11521144#ifdef FEAT_GUI_MACVIM
11531145 // Cocoa needs an NSAutoreleasePool in place or it will leak memory.
11541146 // This particular pool gets released once every loop.
1155- id autoreleasePool = objc_msgSend (objc_msgSend (
1156- objc_getClass ("NSAutoreleasePool" ),sel_getUid ("alloc" )
1157- ), sel_getUid ("init" ));
1147+ void * autoreleasePool = gui_macvim_new_autoreleasepool ();
11581148#endif
11591149
11601150 if (stuff_empty ())
@@ -1404,7 +1394,7 @@ main_loop(cmdwin, noexmode)
14041394#ifdef FEAT_GUI_MACVIM
14051395 // TODO! Make sure there are no continue statements that will cause
14061396 // this not to be called or MacVim will leak memory!
1407- objc_msgSend (autoreleasePool , sel_getUid ( "release" ) );
1397+ gui_macvim_release_autoreleasepool (autoreleasePool );
14081398#endif
14091399 }
14101400}
0 commit comments