[EMAIL PROTECTED] wrote:
> >- Allocations do not require a function call, just a few instructions
> >(e.g. store pointer, adjust stack pointer etc.)
>
> You could aslo use "alloca()" (which is a fine solution in Solaris and
> is used in a lot of Solaris library code, specifically the bits written
> by more experienced programmers)
Both solutions (dynamic arrays as well as alloca()) suffer from the same
problem: They abort your program ungracefully in case that you try to use
too much memory this way.
This is why I decided not to use these contructs in smake when I enhanced smake
to allow arbitrary sized strings in Makefiles.
What I now do is to define a static array that is sufficient for newarly all
cases and realloc() the space in case I need more. This way I am able to print
error messages that help the user to find the reason that caused the problem.
Note that smake as well as a shell are interpreters that need to be able to deal
with arbitrary input and should handle this graceefully. I strongly object to
use variable arrays in a shell unless the shell catches all relevent signals and
use longjmp() to recover from problems caused by too big arrays and other
reasons that may cause a core dump. If you use signals and longjmp(), it may be
that all code size meditations are void as you may need to call setjmp() at
many places in order to have working recovery points in your sw.
BTW: Sun's make dumps core in case that a string in a Makefile is too long...
Jörg
--
EMail:[EMAIL PROTECTED] (home) Jörg Schilling D-13353 Berlin
[EMAIL PROTECTED] (uni)
[EMAIL PROTECTED] (work) Blog: http://schily.blogspot.com/
URL: http://cdrecord.berlios.de/old/private/ ftp://ftp.berlios.de/pub/schily
_______________________________________________
opensolaris-code mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/opensolaris-code