Don't allocate struct entry one by one; it just wastes memory.
This commit is contained in:
parent
7ec345ff22
commit
89e4128421
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: main.c,v 1.21 2001/02/19 22:56:22 cgd Exp $ */
|
||||
/* $NetBSD: main.c,v 1.22 2002/11/18 04:28:03 enami Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1983, 1993
|
||||
|
@ -43,7 +43,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 1993\n\
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)main.c 8.6 (Berkeley) 5/4/95";
|
||||
#else
|
||||
__RCSID("$NetBSD: main.c,v 1.21 2001/02/19 22:56:22 cgd Exp $");
|
||||
__RCSID("$NetBSD: main.c,v 1.22 2002/11/18 04:28:03 enami Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
|
@ -77,6 +77,7 @@ char *usedinomap;
|
|||
ino_t maxino;
|
||||
time_t dumptime;
|
||||
time_t dumpdate;
|
||||
size_t pagesize;
|
||||
FILE *terminal;
|
||||
char *tmpdir;
|
||||
|
||||
|
@ -177,6 +178,7 @@ main(argc, argv)
|
|||
if (signal(SIGTERM, onintr) == SIG_IGN)
|
||||
(void) signal(SIGTERM, SIG_IGN);
|
||||
setlinebuf(stderr);
|
||||
pagesize = sysconf(_SC_PAGESIZE);
|
||||
|
||||
atexit(cleanup);
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: restore.h,v 1.11 2001/08/24 10:24:46 wiz Exp $ */
|
||||
/* $NetBSD: restore.h,v 1.12 2002/11/18 04:28:03 enami Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1983, 1993
|
||||
|
@ -64,6 +64,7 @@ extern int32_t ntrec; /* number of TP_BSIZE records per tape block */
|
|||
extern time_t dumptime; /* time that this dump begins */
|
||||
extern time_t dumpdate; /* time that this dump was made */
|
||||
extern char command; /* opration being performed */
|
||||
extern size_t pagesize; /* system page size */
|
||||
extern FILE *terminal; /* file descriptor for the terminal input */
|
||||
extern char *tmpdir; /* where to store temporary files */
|
||||
extern int oldinofmt; /* reading tape with old format inodes */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: symtab.c,v 1.15 2002/08/12 02:40:20 itojun Exp $ */
|
||||
/* $NetBSD: symtab.c,v 1.16 2002/11/18 04:28:03 enami Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1983, 1993
|
||||
|
@ -38,7 +38,7 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)symtab.c 8.3 (Berkeley) 4/28/95";
|
||||
#else
|
||||
__RCSID("$NetBSD: symtab.c,v 1.15 2002/08/12 02:40:20 itojun Exp $");
|
||||
__RCSID("$NetBSD: symtab.c,v 1.16 2002/11/18 04:28:03 enami Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
|
@ -233,15 +233,20 @@ addentry(name, inum, type)
|
|||
{
|
||||
struct entry *np, *ep;
|
||||
|
||||
if (freelist != NULL) {
|
||||
if (freelist == NULL) {
|
||||
np = malloc(pagesize);
|
||||
if (np == NULL)
|
||||
panic("no memory to extend symbol table\n");
|
||||
for (ep = (struct entry *)((char *)np + pagesize) - 1;
|
||||
np <= ep; np++) {
|
||||
np->e_next = freelist;
|
||||
freelist = np;
|
||||
}
|
||||
}
|
||||
np = freelist;
|
||||
freelist = np->e_next;
|
||||
memset(np, 0, (long)sizeof(struct entry));
|
||||
} else {
|
||||
np = (struct entry *)calloc(1, sizeof(struct entry));
|
||||
if (np == NULL)
|
||||
panic("no memory to extend symbol table\n");
|
||||
}
|
||||
|
||||
np->e_type = type & ~LINK;
|
||||
ep = lookupparent(name);
|
||||
if (ep == NULL) {
|
||||
|
|
Loading…
Reference in New Issue