osx patches

This commit is contained in:
Vítor Santos Costa 2014-03-06 15:39:56 +00:00
parent f257efc2ef
commit 06d99506cf
1 changed files with 5 additions and 5 deletions

View File

@ -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;