aboutsummaryrefslogtreecommitdiff
path: root/docs/style-guide.txt
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2001-01-25 23:49:09 +0000
committerEric Andersen <andersen@codepoet.org>2001-01-25 23:49:09 +0000
commitd35c21587a4139031c077fd122252217a4713681 (patch)
tree7bd14fd247492c00f3d38ae1dbd7727e03fda9ad /docs/style-guide.txt
parentffde8673fe8b2c32076aa3e01eab1fefc5f08e86 (diff)
downloadbusybox-w32-d35c21587a4139031c077fd122252217a4713681.tar.gz
busybox-w32-d35c21587a4139031c077fd122252217a4713681.tar.bz2
busybox-w32-d35c21587a4139031c077fd122252217a4713681.zip
Commit Larry Doolittle's buffers-on-stack/buffers-via-malloc patch.
-Erik
Diffstat (limited to 'docs/style-guide.txt')
-rw-r--r--docs/style-guide.txt18
1 files changed, 9 insertions, 9 deletions
diff --git a/docs/style-guide.txt b/docs/style-guide.txt
index 9a3b10207..1a04e4474 100644
--- a/docs/style-guide.txt
+++ b/docs/style-guide.txt
@@ -402,7 +402,7 @@ The problem with these is that any time any busybox app is run, you pay a
402memory penalty for this buffer, even if the applet that uses said buffer is 402memory penalty for this buffer, even if the applet that uses said buffer is
403not run. This can be fixed, thusly: 403not run. This can be fixed, thusly:
404 404
405 static char *buffer 405 static char *buffer;
406 ... 406 ...
407 other_func() 407 other_func()
408 { 408 {
@@ -418,7 +418,7 @@ mallocing the buffers (and thus growing the text size), buffers can be
418declared on the stack in the *_main() function and made available globally by 418declared on the stack in the *_main() function and made available globally by
419assigning them to a global pointer thusly: 419assigning them to a global pointer thusly:
420 420
421 static char *pbuffer 421 static char *pbuffer;
422 ... 422 ...
423 other_func() 423 other_func()
424 { 424 {
@@ -430,13 +430,13 @@ assigning them to a global pointer thusly:
430 pbuffer = buffer; /* but available globally */ 430 pbuffer = buffer; /* but available globally */
431 ... 431 ...
432 432
433Thus: 433This last approach has some advantages (low code size, space not used until
434 - global static buffers are eliminated 434it's needed), but can be a problem in some low resource machines that have
435 - we don't grow the text segment as much because no malloc() call is made; 435very limited stack space (e.g., uCLinux). busybox.h declares a macro that
436 memory is automatically allocated on the stack when execution context 436implements compile-time selection between xmalloc() and stack creation, so
437 enters the function. (We still grow text a little bit because of the 437you can code the line in question as
438 assignment, but that's cheap compared to a function call.) 438 RESERVE_BB_BUFFER(buffer, BUFSIZ);
439 - the buffer is still available globally via the pointer 439and the right thing will happen, based on the customer's configuration.
440 440
441 441
442 442