[git commit] docs: tweak keep_data_small.txt

Denys Vlasenko vda.linux at googlemail.com
Mon Jan 13 10:45:34 UTC 2014


commit: http://git.busybox.net/busybox/commit/?id=d74f8435ea7479fe558efa63c2ecc9aed5662db2
branch: http://git.busybox.net/busybox/commit/?id=refs/heads/master

Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
 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 9fc7996..3ced1a6 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.
 


More information about the busybox-cvs mailing list