aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormitchell <70453897+667e-11@users.noreply.github.com>2010-07-11 23:04:41 -0400
committermitchell <70453897+667e-11@users.noreply.github.com>2010-07-11 23:04:41 -0400
commit1c406403ba2bd7cdfe800075bf117b51d9e0cbcd (patch)
tree0666dccf6ad6cbad9140a22ced29f2feb76dfab0 /src
parentea2b7b80db293115e51d07108edb580903794142 (diff)
downloadtextadept-1c406403ba2bd7cdfe800075bf117b51d9e0cbcd.tar.gz
textadept-1c406403ba2bd7cdfe800075bf117b51d9e0cbcd.zip
Fixed memory leak for Mac OSX; src/textadept.c
Diffstat (limited to 'src')
-rw-r--r--src/textadept.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/textadept.c b/src/textadept.c
index 142ea4da..b0e35702 100644
--- a/src/textadept.c
+++ b/src/textadept.c
@@ -7,8 +7,6 @@
#elif MAC
#include <Carbon/Carbon.h>
#include "ige-mac-menu.h"
-#define CFURL_TO_STR(u) \
- CFStringGetCStringPtr(CFURLCopyFileSystemPath(u, kCFURLPOSIXPathStyle), 0)
#elif __BSD__
#include <sys/types.h>
#include <sys/sysctl.h>
@@ -65,10 +63,13 @@ int main(int argc, char **argv) {
#if !(__WIN32__ || MAC || __BSD__)
textadept_home = g_file_read_link("/proc/self/exe", NULL);
#elif MAC
- CFBundleRef bundle = CFBundleGetMainBundle();
+ CFURLRef bundle = CFBundleCopyBundleURL(CFBundleGetMainBundle());
if (bundle) {
- const char *bundle_path = CFURL_TO_STR(CFBundleCopyBundleURL(bundle));
- textadept_home = g_strconcat(bundle_path, "/Contents/Resources/", NULL);
+ CFStringRef path = CFURLCopyFileSystemPath(bundle, kCFURLPOSIXPathStyle);
+ const char *p = CFStringGetCStringPtr(path, kCFStringEncodingMacRoman);
+ textadept_home = g_strconcat(p, "/Contents/Resources/", NULL);
+ CFRelease(path);
+ CFRelease(bundle);
} else textadept_home = calloc(1, 1);
// GTK-OSX does not parse ~/.gtkrc-2.0; parse it manually
char *user_home = g_strconcat(getenv("HOME"), "/.gtkrc-2.0", NULL);
@@ -507,7 +508,10 @@ static OSErr w_ae_open(const AppleEvent *event, AppleEvent *reply, long ref) {
NULL);
CFURLRef url = CFURLCreateFromFSRef(kCFAllocatorDefault, &fsref);
if (url) {
- l_emit_event("appleevent_odoc", LUA_TSTRING, CFURL_TO_STR(url), -1);
+ CFStringRef path = CFURLCopyFileSystemPath(url, kCFURLPOSIXPathStyle);
+ const char *p = CFStringGetCStringPtr(path, kCFStringEncodingMacRoman);
+ l_emit_event("appleevent_odoc", LUA_TSTRING, p, -1);
+ CFRelease(path);
CFRelease(url);
}
}