changeset 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 99fdf5a90b0f
children 54c5d80a737e
files dep/animia/src/util/osx.cc
diffstat 1 files changed, 5 insertions(+), 3 deletions(-) [+]
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;
 }