From 06d99506cfb2ddfecbe4827aa58c17729d268312 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Santos=20Costa?= Date: Thu, 6 Mar 2014 15:39:56 +0000 Subject: [PATCH] osx patches --- C/load_dl.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/C/load_dl.c b/C/load_dl.c index b5c96121c..84166ba37 100755 --- a/C/load_dl.c +++ b/C/load_dl.c @@ -74,12 +74,14 @@ Yap_FindExecutable(void) return getexecname(); #elif __APPLE__ char path[1024]; + char *buf; + uint32_t size = sizeof(path); if (!_NSGetExecutablePath(path, &size)) { size_t sz = strlen(path); - char *rc = malloc(sz+1); - strncpy(rc, path, sz); - return rc; + buf = malloc(sz+1); + strncpy(buf, path, sz); + return buf; } else { char *rc = malloc(size+1); if (_NSGetExecutablePath(rc, &size) == 0) @@ -95,7 +97,6 @@ Yap_FindExecutable(void) buf[len] = '\0'; return buf; } - free( buf ); // follow through to standard method #elif defined(__FreeBSD__) || defined(__DragonFly__) enum { BUFFERSIZE = 1024 }; @@ -106,7 +107,6 @@ Yap_FindExecutable(void) buf[len] = '\0'; return buf; } - free( buf ); int mib[4]; mib[0] = CTL_KERN; mib[1] = KERN_PROC;