summaryrefslogtreecommitdiff
path: root/gnu/usr.bin/awk/zmalloc.c
diff options
context:
space:
mode:
authorjtc <jtc@NetBSD.org>1993-07-02 23:56:52 +0000
committerjtc <jtc@NetBSD.org>1993-07-02 23:56:52 +0000
commitf4e00a39c236bf7481c72bcc6d215900040c7cdf (patch)
tree52e2aaed1a2ff6e364820a186cf85c4b792e5626 /gnu/usr.bin/awk/zmalloc.c
parent8ebc845441169cc86d3f7c2b400125e254124a27 (diff)
Updated to mawk 1.1.4
Diffstat (limited to 'gnu/usr.bin/awk/zmalloc.c')
-rw-r--r--gnu/usr.bin/awk/zmalloc.c42
1 files changed, 31 insertions, 11 deletions
diff --git a/gnu/usr.bin/awk/zmalloc.c b/gnu/usr.bin/awk/zmalloc.c
index 7315e372804..1a38d9c50e6 100644
--- a/gnu/usr.bin/awk/zmalloc.c
+++ b/gnu/usr.bin/awk/zmalloc.c
@@ -11,12 +11,16 @@ the GNU General Public License, version 2, 1991.
********************************************/
/*$Log: zmalloc.c,v $
-/*Revision 1.1.1.1 1993/03/21 09:45:37 cgd
-/*initial import of 386bsd-0.1 sources
+/*Revision 1.2 1993/07/02 23:58:03 jtc
+/*Updated to mawk 1.1.4
/*
- * Revision 5.1 91/12/05 07:56:35 brennan
+ * Revision 5.1.1.1 1993/02/06 11:12:19 mike
+ * fix bug in reuse of parser table memory
+ * for most users ifdef the mess out
+ *
+ * Revision 5.1 1991/12/05 07:56:35 brennan
* 1.1 pre-release
- *
+ *
*/
/* zmalloc.c */
@@ -86,20 +90,36 @@ PTR bmalloc( blocks )
{ pool[blocks-1] = p->link ; return (PTR) p ; }
if ( blocks > amt_avail )
- { if ( amt_avail ) /* free avail */
- { avail->link = pool[--amt_avail] ; pool[amt_avail] = avail ; }
+ {
+ if ( amt_avail != 0 ) /* free avail */
+ {
+ avail->link = pool[--amt_avail] ;
+ pool[amt_avail] = avail ;
+ }
+#if MSDOS || HAVE_SMALL_MEMORY
+/* this hack is dangerous (I've blown it twice), not portable,
+ and counts on byacc not changing, but it is a big win on
+ DOS. On paged vmem systems it is a nop so ifdef it out.
+*/
/* use parser tables first */
- if ( yacc_memp->zblocks >= blocks )
- { avail = (ZBLOCK *) yacc_memp->mem ;
+ if ( yacc_memp->zblocks > blocks )
+ {
+ avail = (ZBLOCK *) yacc_memp->mem ;
amt_avail = yacc_memp++ -> zblocks ;
/* make sure its -- aligned */
- if ( (int) avail & 7 )
- { avail = (ZBLOCK*)((char *)avail + 8 - ((int)avail&7)) ;
- amt_avail-- ;
+ {
+ int k = (int) avail & 7 ;
+ if ( k )
+ {
+ avail = (ZBLOCK*)((char *)avail + (8-k)) ;
+ amt_avail-- ;
+ }
}
}
else
+#endif
+
if ( !(avail = (ZBLOCK *) malloc(SIZE_T(CHUNK*ZBLOCKSZ))) )
{ /* if we get here, almost out of memory */
amt_avail = 0 ;