diff options
-rw-r--r-- | procps/top.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/procps/top.c b/procps/top.c index 1bc432fc9..b9958afa0 100644 --- a/procps/top.c +++ b/procps/top.c | |||
@@ -116,7 +116,6 @@ | |||
116 | //kbuild:lib-$(CONFIG_TOP) += top.o | 116 | //kbuild:lib-$(CONFIG_TOP) += top.o |
117 | 117 | ||
118 | #include "libbb.h" | 118 | #include "libbb.h" |
119 | #include "common_bufsiz.h" | ||
120 | 119 | ||
121 | 120 | ||
122 | typedef struct top_status_t { | 121 | typedef struct top_status_t { |
@@ -154,6 +153,8 @@ typedef int (*cmp_funcp)(top_status_t *P, top_status_t *Q); | |||
154 | 153 | ||
155 | enum { SORT_DEPTH = 3 }; | 154 | enum { SORT_DEPTH = 3 }; |
156 | 155 | ||
156 | /* Screens wider than this are unlikely */ | ||
157 | enum { LINE_BUF_SIZE = 512 - 64 }; | ||
157 | 158 | ||
158 | struct globals { | 159 | struct globals { |
159 | top_status_t *top; | 160 | top_status_t *top; |
@@ -192,10 +193,9 @@ struct globals { | |||
192 | #if ENABLE_FEATURE_TOP_INTERACTIVE | 193 | #if ENABLE_FEATURE_TOP_INTERACTIVE |
193 | char kbd_input[KEYCODE_BUFFER_SIZE]; | 194 | char kbd_input[KEYCODE_BUFFER_SIZE]; |
194 | #endif | 195 | #endif |
195 | char line_buf[80]; | 196 | char line_buf[LINE_BUF_SIZE]; |
196 | }; //FIX_ALIASING; - large code growth | 197 | }; |
197 | enum { LINE_BUF_SIZE = COMMON_BUFSIZE - offsetof(struct globals, line_buf) }; | 198 | #define G (*ptr_to_globals) |
198 | #define G (*(struct globals*)bb_common_bufsiz1) | ||
199 | #define top (G.top ) | 199 | #define top (G.top ) |
200 | #define ntop (G.ntop ) | 200 | #define ntop (G.ntop ) |
201 | #define sort_field (G.sort_field ) | 201 | #define sort_field (G.sort_field ) |
@@ -213,8 +213,7 @@ enum { LINE_BUF_SIZE = COMMON_BUFSIZE - offsetof(struct globals, line_buf) }; | |||
213 | #define total_pcpu (G.total_pcpu ) | 213 | #define total_pcpu (G.total_pcpu ) |
214 | #define line_buf (G.line_buf ) | 214 | #define line_buf (G.line_buf ) |
215 | #define INIT_G() do { \ | 215 | #define INIT_G() do { \ |
216 | setup_common_bufsiz(); \ | 216 | SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \ |
217 | BUILD_BUG_ON(sizeof(G) > COMMON_BUFSIZE); \ | ||
218 | BUILD_BUG_ON(LINE_BUF_SIZE <= 80); \ | 217 | BUILD_BUG_ON(LINE_BUF_SIZE <= 80); \ |
219 | } while (0) | 218 | } while (0) |
220 | 219 | ||