Mercurial > minori
comparison 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 |
comparison
equal
deleted
inserted
replaced
164:99fdf5a90b0f | 165:8937fb7f2d66 |
---|---|
144 result = args.substr(last_slash + 1, null_pos - last_slash - 1); | 144 result = args.substr(last_slash + 1, null_pos - last_slash - 1); |
145 return true; | 145 return true; |
146 } | 146 } |
147 | 147 |
148 static bool GetProcessNameFromKernel(pid_t pid, std::string& result) { | 148 static bool GetProcessNameFromKernel(pid_t pid, std::string& result) { |
149 result.reserve(2*MAXCOMLEN); | 149 result.resize(2 * MAXCOMLEN); |
150 if (!proc_name(pid, &result.front(), result.length())) | 150 |
151 int size = proc_name(pid, &result.front(), result.length()); | |
152 if (!size) | |
151 return false; | 153 return false; |
152 | 154 |
153 result.shrink_to_fit(); | 155 result.resize(size); |
154 return true; | 156 return true; |
155 } | 157 } |
156 | 158 |
157 static bool GetProcessName(pid_t pid, std::string& result) { | 159 static bool GetProcessName(pid_t pid, std::string& result) { |
158 #ifdef HAVE_COREFOUNDATION | 160 #ifdef HAVE_COREFOUNDATION |