aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2010-12-05 19:36:58 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2010-12-05 19:36:58 +0100
commit2161bd701a9267c04aa68fb43b2d40d7793884d4 (patch)
treea515217893a3d6dfa73cfe258f0e3d65f8f96158
parentc32e626988ab35ba62bbe5b64dc8b86cd9a76bac (diff)
downloadbusybox-w32-2161bd701a9267c04aa68fb43b2d40d7793884d4.tar.gz
busybox-w32-2161bd701a9267c04aa68fb43b2d40d7793884d4.tar.bz2
busybox-w32-2161bd701a9267c04aa68fb43b2d40d7793884d4.zip
pstree: another tiny shrink
function old new delta pstree_main 327 324 -3 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--procps/pstree.c20
1 files changed, 6 insertions, 14 deletions
diff --git a/procps/pstree.c b/procps/pstree.c
index 7e127739c..54a910f76 100644
--- a/procps/pstree.c
+++ b/procps/pstree.c
@@ -61,7 +61,7 @@ typedef struct child {
61#define first_3 "-+-" 61#define first_3 "-+-"
62 62
63struct globals { 63struct globals {
64 /* 0-based. IOW: the number of chars we printer on current line */ 64 /* 0-based. IOW: the number of chars we printed on current line */
65 unsigned cur_x; 65 unsigned cur_x;
66 unsigned output_width; 66 unsigned output_width;
67 67
@@ -95,16 +95,6 @@ static void ensure_buffer_capacity(int bufindex)
95 } 95 }
96} 96}
97 97
98#if ENABLE_FEATURE_CLEAN_UP
99static void maybe_free_buffers(void)
100{
101 free(G.width);
102 free(G.more);
103}
104#else
105# define maybe_free_buffers() ((void)0)
106#endif
107
108/* NB: this function is never called with "bad" chars 98/* NB: this function is never called with "bad" chars
109 * (control chars or chars >= 0x7f) 99 * (control chars or chars >= 0x7f)
110 */ 100 */
@@ -385,12 +375,11 @@ int pstree_main(int argc UNUSED_PARAM, char **argv)
385 375
386 get_terminal_width_height(1, &G.output_width, NULL); 376 get_terminal_width_height(1, &G.output_width, NULL);
387 377
378 opt_complementary = "?1";
388 getopt32(argv, "p"); 379 getopt32(argv, "p");
389 argv += optind; 380 argv += optind;
390 381
391 if (argv[0]) { 382 if (argv[0]) {
392 if (argv[1])
393 bb_show_usage();
394 if (argv[0][0] >= '0' && argv[0][0] <= '9') { 383 if (argv[0][0] >= '0' && argv[0][0] <= '9') {
395 pid = xatoi(argv[0]); 384 pid = xatoi(argv[0]);
396 } else { 385 } else {
@@ -409,6 +398,9 @@ int pstree_main(int argc UNUSED_PARAM, char **argv)
409 } 398 }
410 } 399 }
411 400
412 maybe_free_buffers(); 401 if (ENABLE_FEATURE_CLEAN_UP) {
402 free(G.width);
403 free(G.more);
404 }
413 return 0; 405 return 0;
414} 406}