take two: make grabstackstr() work correctly, in the face of strange filling.

This commit is contained in:
cgd 1994-12-31 01:56:16 +00:00
parent 12fae60ada
commit 809218efc4
2 changed files with 14 additions and 3 deletions

View File

@ -36,7 +36,7 @@
#ifndef lint
/*static char sccsid[] = "from: @(#)memalloc.c 8.1 (Berkeley) 5/31/93";*/
static char *rcsid = "$Id: memalloc.c,v 1.12 1994/12/30 06:33:59 mycroft Exp $";
static char *rcsid = "$Id: memalloc.c,v 1.13 1994/12/31 01:56:16 cgd Exp $";
#endif /* not lint */
#include "shell.h"
@ -288,6 +288,16 @@ makestrspace() {
}
char *
grabstackstr(p)
char *p;
{
int len = stackblocksize() - sstrnleft;
if (ALIGN(len) > stackblocksize())
growstackstr();
stalloc(len);
}
void
ungrabstackstr(s, p)

View File

@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* from: @(#)memalloc.h 8.1 (Berkeley) 5/31/93
* $Id: memalloc.h,v 1.6 1994/06/11 16:12:09 mycroft Exp $
* $Id: memalloc.h,v 1.7 1994/12/31 01:56:19 cgd Exp $
*/
struct stackmark {
@ -62,6 +62,7 @@ void growstackblock(void);
void grabstackblock(int);
char *growstackstr(void);
char *makestrspace(void);
char *grabstackstr(char *);
void ungrabstackstr(char *, char *);
#else
pointer ckmalloc();
@ -76,6 +77,7 @@ void growstackblock();
void grabstackblock();
char *growstackstr();
char *makestrspace();
char *grabstackstr();
void ungrabstackstr();
#endif
@ -91,6 +93,5 @@ void ungrabstackstr();
#define STUNPUTC(p) (++sstrnleft, --p)
#define STTOPC(p) p[-1]
#define STADJUST(amount, p) (p += (amount), sstrnleft -= (amount))
#define grabstackstr(p) stalloc(stackblocksize() - sstrnleft)
#define ckfree(p) free((pointer)(p))