Mercurial > minori
diff dep/animia/src/util/osx.cc @ 165:8937fb7f2d66
dep/animia/osx: that's not how std::string works
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Sat, 18 Nov 2023 01:12:02 -0500 |
parents | 44c5e6dd9488 |
children | e44b7c428d7c |
line wrap: on
line diff
--- a/dep/animia/src/util/osx.cc Sat Nov 18 00:54:29 2023 -0500 +++ b/dep/animia/src/util/osx.cc Sat Nov 18 01:12:02 2023 -0500 @@ -146,11 +146,13 @@ } static bool GetProcessNameFromKernel(pid_t pid, std::string& result) { - result.reserve(2*MAXCOMLEN); - if (!proc_name(pid, &result.front(), result.length())) + result.resize(2 * MAXCOMLEN); + + int size = proc_name(pid, &result.front(), result.length()); + if (!size) return false; - result.shrink_to_fit(); + result.resize(size); return true; }