aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Lewis <martin.lewis.x84@gmail.com>2020-06-11 15:45:57 -0500
committerDenys Vlasenko <vda.linux@googlemail.com>2020-06-29 16:07:20 +0200
commitac79db6a3b8c9d1815dc4f506d55bc6a2a4e34dd (patch)
treef063784ee967c4a21b6b5875d253927a9bf6cdbd
parent1f86ecb72974d0b284d73e7fea5acdab104af5f8 (diff)
downloadbusybox-w32-ac79db6a3b8c9d1815dc4f506d55bc6a2a4e34dd.tar.gz
busybox-w32-ac79db6a3b8c9d1815dc4f506d55bc6a2a4e34dd.tar.bz2
busybox-w32-ac79db6a3b8c9d1815dc4f506d55bc6a2a4e34dd.zip
procps: code shrink
function old new delta skip_whitespace_if_prefixed_with - 17 +17 procps_read_smaps 911 854 -57 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 0/1 up/down: 17/-57) Total: -40 bytes Signed-off-by: Martin Lewis <martin.lewis.x84@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--libbb/procps.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/libbb/procps.c b/libbb/procps.c
index af3ad86ff..4cc3cb2a1 100644
--- a/libbb/procps.c
+++ b/libbb/procps.c
@@ -177,6 +177,15 @@ static char *skip_fields(char *str, int count)
177} 177}
178#endif 178#endif
179 179
180static char* skip_whitespace_if_prefixed_with(char *buf, const char *prefix)
181{
182 char *tp = is_prefixed_with(buf, prefix);
183 if (tp) {
184 tp = skip_whitespace(tp);
185 }
186 return tp;
187}
188
180#if ENABLE_FEATURE_TOPMEM || ENABLE_PMAP 189#if ENABLE_FEATURE_TOPMEM || ENABLE_PMAP
181int FAST_FUNC procps_read_smaps(pid_t pid, struct smaprec *total, 190int FAST_FUNC procps_read_smaps(pid_t pid, struct smaprec *total,
182 void (*cb)(struct smaprec *, void *), void *data) 191 void (*cb)(struct smaprec *, void *), void *data)
@@ -207,8 +216,7 @@ int FAST_FUNC procps_read_smaps(pid_t pid, struct smaprec *total,
207 char *tp, *p; 216 char *tp, *p;
208 217
209#define SCAN(S, X) \ 218#define SCAN(S, X) \
210 if ((tp = is_prefixed_with(buf, S)) != NULL) { \ 219 if ((tp = skip_whitespace_if_prefixed_with(buf, S)) != NULL) { \
211 tp = skip_whitespace(tp); \
212 total->X += currec.X = fast_strtoul_10(&tp); \ 220 total->X += currec.X = fast_strtoul_10(&tp); \
213 continue; \ 221 continue; \
214 } 222 }