mirror of
https://github.com/freebsd/freebsd-src
synced 2024-09-24 02:34:59 +00:00
Add a guarded abort() for the problem in PR bin/7059 (no fix so far,
this is hairy). Reformat this file to comply to style(9). It had mixed styles before. PR: bin/7059
This commit is contained in:
parent
7a19b7ed76
commit
9d5efc1507
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=45618
|
@ -39,7 +39,7 @@
|
||||||
static char sccsid[] = "@(#)memalloc.c 8.3 (Berkeley) 5/4/95";
|
static char sccsid[] = "@(#)memalloc.c 8.3 (Berkeley) 5/4/95";
|
||||||
#endif
|
#endif
|
||||||
static const char rcsid[] =
|
static const char rcsid[] =
|
||||||
"$Id: memalloc.c,v 1.11 1998/09/10 14:51:06 cracauer Exp $";
|
"$Id: memalloc.c,v 1.12 1998/09/13 19:24:57 tegge Exp $";
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
#include "shell.h"
|
#include "shell.h"
|
||||||
|
@ -77,7 +77,6 @@ ckrealloc(p, nbytes)
|
||||||
pointer p;
|
pointer p;
|
||||||
int nbytes;
|
int nbytes;
|
||||||
{
|
{
|
||||||
|
|
||||||
if ((p = realloc(p, nbytes)) == NULL)
|
if ((p = realloc(p, nbytes)) == NULL)
|
||||||
error("Out of space");
|
error("Out of space");
|
||||||
return p;
|
return p;
|
||||||
|
@ -91,7 +90,7 @@ ckrealloc(p, nbytes)
|
||||||
char *
|
char *
|
||||||
savestr(s)
|
savestr(s)
|
||||||
char *s;
|
char *s;
|
||||||
{
|
{
|
||||||
char *p;
|
char *p;
|
||||||
|
|
||||||
p = ckmalloc(strlen(s) + 1);
|
p = ckmalloc(strlen(s) + 1);
|
||||||
|
@ -141,7 +140,8 @@ stalloc(nbytes)
|
||||||
if (blocksize < MINSIZE)
|
if (blocksize < MINSIZE)
|
||||||
blocksize = MINSIZE;
|
blocksize = MINSIZE;
|
||||||
INTOFF;
|
INTOFF;
|
||||||
sp = ckmalloc(sizeof(struct stack_block) - MINSIZE + blocksize);
|
sp = ckmalloc(sizeof(struct stack_block) - MINSIZE +
|
||||||
|
blocksize);
|
||||||
sp->prev = stackp;
|
sp->prev = stackp;
|
||||||
stacknxt = sp->space;
|
stacknxt = sp->space;
|
||||||
stacknleft = blocksize;
|
stacknleft = blocksize;
|
||||||
|
@ -158,7 +158,7 @@ stalloc(nbytes)
|
||||||
void
|
void
|
||||||
stunalloc(p)
|
stunalloc(p)
|
||||||
pointer p;
|
pointer p;
|
||||||
{
|
{
|
||||||
if (p == NULL) { /*DEBUG */
|
if (p == NULL) { /*DEBUG */
|
||||||
write(2, "stunalloc\n", 10);
|
write(2, "stunalloc\n", 10);
|
||||||
abort();
|
abort();
|
||||||
|
@ -172,7 +172,7 @@ stunalloc(p)
|
||||||
void
|
void
|
||||||
setstackmark(mark)
|
setstackmark(mark)
|
||||||
struct stackmark *mark;
|
struct stackmark *mark;
|
||||||
{
|
{
|
||||||
mark->stackp = stackp;
|
mark->stackp = stackp;
|
||||||
mark->stacknxt = stacknxt;
|
mark->stacknxt = stacknxt;
|
||||||
mark->stacknleft = stacknleft;
|
mark->stacknleft = stacknleft;
|
||||||
|
@ -182,11 +182,15 @@ setstackmark(mark)
|
||||||
void
|
void
|
||||||
popstackmark(mark)
|
popstackmark(mark)
|
||||||
struct stackmark *mark;
|
struct stackmark *mark;
|
||||||
{
|
{
|
||||||
struct stack_block *sp;
|
struct stack_block *sp;
|
||||||
|
|
||||||
INTOFF;
|
INTOFF;
|
||||||
while (stackp != mark->stackp) {
|
while (stackp != mark->stackp) {
|
||||||
|
if (stackp == NULL) {
|
||||||
|
write(2, "Oops, stackp deleted\n", 21);
|
||||||
|
abort();
|
||||||
|
}
|
||||||
sp = stackp;
|
sp = stackp;
|
||||||
stackp = sp->prev;
|
stackp = sp->prev;
|
||||||
ckfree(sp);
|
ckfree(sp);
|
||||||
|
@ -208,18 +212,24 @@ popstackmark(mark)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
growstackblock() {
|
growstackblock()
|
||||||
|
{
|
||||||
char *p;
|
char *p;
|
||||||
int newlen = ALIGN(stacknleft * 2 + 100);
|
int newlen;
|
||||||
char *oldspace = stacknxt;
|
char *oldspace;
|
||||||
int oldlen = stacknleft;
|
int oldlen;
|
||||||
struct stack_block *sp;
|
struct stack_block *sp;
|
||||||
|
|
||||||
|
newlen = ALIGN(stacknleft * 2 + 100);
|
||||||
|
oldspace = stacknxt;
|
||||||
|
oldlen = stacknleft;
|
||||||
|
|
||||||
if (stacknxt == stackp->space && stackp != &stackbase) {
|
if (stacknxt == stackp->space && stackp != &stackbase) {
|
||||||
INTOFF;
|
INTOFF;
|
||||||
sp = stackp;
|
sp = stackp;
|
||||||
stackp = sp->prev;
|
stackp = sp->prev;
|
||||||
sp = ckrealloc((pointer)sp, sizeof(struct stack_block) - MINSIZE + newlen);
|
sp = ckrealloc((pointer)sp, sizeof(struct stack_block) -
|
||||||
|
MINSIZE + newlen);
|
||||||
sp->prev = stackp;
|
sp->prev = stackp;
|
||||||
stackp = sp;
|
stackp = sp;
|
||||||
stacknxt = sp->space;
|
stacknxt = sp->space;
|
||||||
|
@ -266,8 +276,11 @@ grabstackblock(len)
|
||||||
|
|
||||||
|
|
||||||
char *
|
char *
|
||||||
growstackstr() {
|
growstackstr()
|
||||||
int len = stackblocksize();
|
{
|
||||||
|
int len;
|
||||||
|
|
||||||
|
len = stackblocksize();
|
||||||
if (herefd >= 0 && len >= 1024) {
|
if (herefd >= 0 && len >= 1024) {
|
||||||
xwrite(herefd, stackblock(), len);
|
xwrite(herefd, stackblock(), len);
|
||||||
sstrnleft = len - 1;
|
sstrnleft = len - 1;
|
||||||
|
@ -284,8 +297,11 @@ growstackstr() {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
char *
|
char *
|
||||||
makestrspace() {
|
makestrspace()
|
||||||
int len = stackblocksize() - sstrnleft;
|
{
|
||||||
|
int len;
|
||||||
|
|
||||||
|
len = stackblocksize() - sstrnleft;
|
||||||
growstackblock();
|
growstackblock();
|
||||||
sstrnleft = stackblocksize() - len;
|
sstrnleft = stackblocksize() - len;
|
||||||
return stackblock() + len;
|
return stackblock() + len;
|
||||||
|
@ -297,7 +313,7 @@ void
|
||||||
ungrabstackstr(s, p)
|
ungrabstackstr(s, p)
|
||||||
char *s;
|
char *s;
|
||||||
char *p;
|
char *p;
|
||||||
{
|
{
|
||||||
stacknleft += stacknxt - s;
|
stacknleft += stacknxt - s;
|
||||||
stacknxt = s;
|
stacknxt = s;
|
||||||
sstrnleft = stacknleft - (p - s);
|
sstrnleft = stacknleft - (p - s);
|
||||||
|
|
Loading…
Reference in a new issue