diff options
Diffstat (limited to 'libbb/procps.c')
-rw-r--r-- | libbb/procps.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/libbb/procps.c b/libbb/procps.c index e6892d7ff..4f9705bc1 100644 --- a/libbb/procps.c +++ b/libbb/procps.c | |||
@@ -178,6 +178,15 @@ static char *skip_fields(char *str, int count) | |||
178 | } | 178 | } |
179 | #endif | 179 | #endif |
180 | 180 | ||
181 | static char* skip_whitespace_if_prefixed_with(char *buf, const char *prefix) | ||
182 | { | ||
183 | char *tp = is_prefixed_with(buf, prefix); | ||
184 | if (tp) { | ||
185 | tp = skip_whitespace(tp); | ||
186 | } | ||
187 | return tp; | ||
188 | } | ||
189 | |||
181 | #if ENABLE_FEATURE_TOPMEM || ENABLE_PMAP | 190 | #if ENABLE_FEATURE_TOPMEM || ENABLE_PMAP |
182 | int FAST_FUNC procps_read_smaps(pid_t pid, struct smaprec *total, | 191 | int FAST_FUNC procps_read_smaps(pid_t pid, struct smaprec *total, |
183 | void (*cb)(struct smaprec *, void *), void *data) | 192 | void (*cb)(struct smaprec *, void *), void *data) |
@@ -208,8 +217,7 @@ int FAST_FUNC procps_read_smaps(pid_t pid, struct smaprec *total, | |||
208 | char *tp, *p; | 217 | char *tp, *p; |
209 | 218 | ||
210 | #define SCAN(S, X) \ | 219 | #define SCAN(S, X) \ |
211 | if ((tp = is_prefixed_with(buf, S)) != NULL) { \ | 220 | if ((tp = skip_whitespace_if_prefixed_with(buf, S)) != NULL) { \ |
212 | tp = skip_whitespace(tp); \ | ||
213 | total->X += currec.X = fast_strtoul_10(&tp); \ | 221 | total->X += currec.X = fast_strtoul_10(&tp); \ |
214 | continue; \ | 222 | continue; \ |
215 | } | 223 | } |