X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=docs%2Fkeep_data_small.txt;h=2ddbefa10aa3cde76a3700d9353432319953a761;hb=c028ec280a71c45ba71bb4712db1968391a440cc;hp=3c3d27396d48856d31096ce4ca6f72c914972586;hpb=b8e72fdde1186f41963697d57383c08402513ca8;p=oweals%2Fbusybox.git diff --git a/docs/keep_data_small.txt b/docs/keep_data_small.txt index 3c3d27396..2ddbefa10 100644 --- a/docs/keep_data_small.txt +++ b/docs/keep_data_small.txt @@ -43,6 +43,16 @@ takes 55k of memory on 64-bit x86 kernel. On 32-bit kernel we need ~26k per applet. +Script: + +i=1000; while test $i != 0; do + echo -n . + busybox sleep 30 & + i=$((i - 1)) +done +echo +wait + (Data from NOMMU arches are sought. Provide 'size busybox' output too) @@ -65,7 +75,7 @@ archival/libunarchive/decompress_unzip.c: (see the rest of the file to get the idea) This example completely eliminates globals in that module. -Required memory is allocated in inflate_gunzip() [its main module] +Required memory is allocated in unpack_gz_stream() [its main module] and then passed down to all subroutines which need to access 'globals' as a parameter. @@ -89,9 +99,9 @@ and then declare that ptr_to_globals is a pointer to it: ptr_to_globals is declared as constant pointer. This helps gcc understand that it won't change, resulting in noticeably -smaller code. In order to assign it, use PTR_TO_GLOBALS macro: +smaller code. In order to assign it, use SET_PTR_TO_GLOBALS macro: - PTR_TO_GLOBALS = xzalloc(sizeof(G)); + SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); Typically it is done in _main(). @@ -112,7 +122,7 @@ Be careful, though, and use it only if globals fit into bb_common_bufsiz1. Since bb_common_bufsiz1 is BUFSIZ + 1 bytes long and BUFSIZ can change from one libc to another, you have to add compile-time check for it: -if(sizeof(struct globals) > sizeof(bb_common_bufsiz1)) +if (sizeof(struct globals) > sizeof(bb_common_bufsiz1)) BUG__globals_too_big();