dyld: Write directly into std::string buffer
This removes extra memory allocation. Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
parent
930db802a3
commit
fc6bca5cb6
@ -24,10 +24,10 @@ inline int _NSGetExecutablePath(std::string& path)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (result == -1) {
|
if (result == -1) {
|
||||||
std::unique_ptr<char[]> heap_buffer(new char[capacity]);
|
path.resize(capacity - 1);
|
||||||
result = _NSGetExecutablePath(heap_buffer.get(), &capacity);
|
result = _NSGetExecutablePath(&path[0], &capacity);
|
||||||
if (result == 0) {
|
if (result == 0) {
|
||||||
path = heap_buffer.get();
|
path.resize(strnlen(path.data(), path.size()));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user