71 uint32_t buf_size = 0;
72 const int rc = _NSGetExecutablePath(
NULL, &buf_size);
76 char *
path = calloc(1, buf_size);
83 if (_NSGetExecutablePath(
path, &buf_size) < 0) {
101 size_t path_size = 0;
106 const size_t size = path_size == 0 ? 1024 : (path_size * 2);
107 char *
const p = realloc(
path, size);
117 rc = GetModuleFileNameA(
NULL,
path, path_size);
123 }
while (rc == path_size);
147 int mib[] = {CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1};
148 static const size_t MIB_LENGTH =
sizeof(mib) /
sizeof(mib[0]);
153 if (sysctl(mib, MIB_LENGTH,
NULL, &buf_size,
NULL, 0) < 0) {
156 assert(buf_size > 0);
159 char *buf = calloc(1, buf_size);
166 if (sysctl(mib, MIB_LENGTH, buf, &buf_size,
NULL, 0) == 0) {