Source-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

CVS commit: src/bin/sh



Module Name:    src
Committed By:   kre
Date:           Sat Apr 18 14:35:16 UTC 2026

Modified Files:
        src/bin/sh: memalloc.c memalloc.h

Log Message:
Make CHECKSTRSPACE() do what it always should have done

The CHECKSTRSPACE() macro is given a number 'n' of bytes,
which it is intended to assure are to be available on the
stack - allocating more space if needed.   The old macro
checked to see if 'n' were available, and if not, allocated
more space (which sounds right) - but with no specification
of how much more space would be allocated, just a general
hope that it would be enough.

This then required additional workarounds whenever 'n' might
be larger than "just a few", because it just wasn't safe (and
had caused problems in the past).

Now CHECKSTRSPACE() works as intended, though the actual change is
to the makestrspace() function (used only from CHECKSTRSPACE()), which
now gets told how much space is needed, so it can ensure that sufficient
is provided, rather than just the generic "more".

By itself, this changes nothing, the CHECKSTRSPACE() issues
had been worked around (aside from unbelievably unlikely circumstances)
so nothing really changes - except that after this, those
workarounds can be removed (which will speed up the shell in
unlikely cases, but also make it slightly smaller.)

While here, fix the comments on how all of this works, so that
they are closer to reality - if it were ever possible to:
        The user declares a variable of type STACKSTR
do that, I can't find when it isn't in the ash sources, (though
that comment is, so perhaps it was a very early ash intention
that either never happened, or was removed, leaving just the
nonsense comment).  There is no "type STACKSTR", the only use
of that string as a word (rather than as a substring of other words)
is in that comment.   That is "was in that comment", it is gone now.


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/bin/sh/memalloc.c
cvs rdiff -u -r1.21 -r1.22 src/bin/sh/memalloc.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.




Home | Main Index | Thread Index | Old Index