diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2014-01-13 11:45:34 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2014-01-13 11:45:34 +0100 |
commit | d74f8435ea7479fe558efa63c2ecc9aed5662db2 (patch) | |
tree | a29db0523f242d5506c94c1090bf4ee6675947dd /docs | |
parent | 0f592d7fb94c5887528d0ee24020c2225ab71c28 (diff) | |
download | busybox-d74f8435ea7479fe558efa63c2ecc9aed5662db2.tar.gz |
docs: tweak keep_data_small.txt
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'docs')
-rw-r--r-- | docs/keep_data_small.txt | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/docs/keep_data_small.txt b/docs/keep_data_small.txt index 9fc799646..3ced1a61d 100644 --- a/docs/keep_data_small.txt +++ b/docs/keep_data_small.txt @@ -103,7 +103,15 @@ smaller code. In order to assign it, use SET_PTR_TO_GLOBALS macro: SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); -Typically it is done in <applet>_main(). +Typically it is done in <applet>_main(). Another variation is +to use stack: + +int <applet>_main(...) +{ +#undef G + struct globals G; + memset(&G, 0, sizeof(G)); + SET_PTR_TO_GLOBALS(&G); Now you can reference "globals" by G.a, G.buf and so on, in any function. |