Hi folks, looking at make(1)'s sources i came to the following patch; its not a big deal, but its exponentially allocating memory wich might not be wise for all architectures. It also doesn't try to allocate a power of two wich might otherwise be handy for pages. Index: buf.c =================================================================== RCS file: /cvsroot/src/usr.bin/make/buf.c,v retrieving revision 1.24 diff -u -p -r1.24 buf.c --- buf.c 17 Jan 2009 13:29:37 -0000 1.24 +++ buf.c 9 Feb 2009 20:36:03 -0000 @@ -90,10 +90,6 @@ __RCSID("$NetBSD: buf.c,v 1.24 2009/01/1 #include "make.h" #include "buf.h" -#ifndef max -#define max(a,b) ((a) > (b) ? (a) : (b)) -#endif - #define BUF_DEF_SIZE 256 /* Default buffer size */ /*- @@ -106,7 +102,7 @@ __RCSID("$NetBSD: buf.c,v 1.24 2009/01/1 void Buf_Expand_1(Buffer *bp) { - bp->size += max(bp->size, 16); + bp->size += 16; bp->buffer = bmake_realloc(bp->buffer, bp->size); } @@ -130,7 +126,7 @@ Buf_AddBytes(Buffer *bp, int numBytes, c Byte *ptr; if (__predict_false(count + numBytes >= bp->size)) { - bp->size += max(bp->size, numBytes + 16); + bp->size += (count + numBytes - bp->size) + 16; bp->buffer = bmake_realloc(bp->buffer, bp->size); } -------------- Any objections? Tested with pkgsrc, and it still works fine :) With regards, Reinoud
Attachment:
pgpGYGdo9__eV.pgp
Description: PGP signature