diff dep/animia/src/util/osx.cc @ 182:c413e475f496

dep/animia: various stylistic changes
author Paper <mrpapersonic@gmail.com>
date Mon, 04 Dec 2023 13:19:54 -0500
parents e44b7c428d7c
children 649786bae914
line wrap: on
line diff
--- a/dep/animia/src/util/osx.cc	Mon Dec 04 12:14:30 2023 -0500
+++ b/dep/animia/src/util/osx.cc	Mon Dec 04 13:19:54 2023 -0500
@@ -84,11 +84,13 @@
 		str.reset(rstr);
 	}
 
-	result.reserve(CFStringGetMaximumSizeForEncoding(CFStringGetLength(str.get()), kCFStringEncodingUTF8) + 1);
+	result.resize(CFStringGetMaximumSizeForEncoding(CFStringGetLength(str.get()), kCFStringEncodingUTF8) + 1);
 
 	if (!CFStringGetCString(str.get(), &result.front(), result.length(), result.length()))
 		return false;
 
+	result.resize(result.find('\0'));
+
 	return true;
 }
 #endif // HAVE_COREFOUNDATION
@@ -98,7 +100,11 @@
 	const int mib[3] = {CTL_KERN, KERN_PROCARGS2, static_cast<int>(pid)};
 	const size_t mib_size = sizeof(mib)/sizeof(*mib);
 
-	/* Get the initial size of the array */
+	/* Get the initial size of the array
+	 *
+	 * NOTE: it IS possible for this value to change inbetween calls to sysctl().
+	 * Unfortunately, I couldn't care less about handling this. :)
+	*/
 	size_t size;
 	{
 		int ret = sysctl((int*)mib, mib_size, nullptr, &size, nullptr, 0);