diff options
-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: | |||
103 | 103 | ||
104 | SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); | 104 | SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); |
105 | 105 | ||
106 | Typically it is done in <applet>_main(). | 106 | Typically it is done in <applet>_main(). Another variation is |
107 | to use stack: | ||
108 | |||
109 | int <applet>_main(...) | ||
110 | { | ||
111 | #undef G | ||
112 | struct globals G; | ||
113 | memset(&G, 0, sizeof(G)); | ||
114 | SET_PTR_TO_GLOBALS(&G); | ||
107 | 115 | ||
108 | Now you can reference "globals" by G.a, G.buf and so on, in any function. | 116 | Now you can reference "globals" by G.a, G.buf and so on, in any function. |
109 | 117 | ||