Dag-Erling Smorgrav wrote: > > To be precise, I experience a 30% decrease in system time and a 100% > increase in user time when I use RE_STARTEND and eliminate the > malloc() / memcpy() calls in procfile().
Could you please test my patch that removes malloc() but bot memcpy()? Here it is again, though against an old version: --- util.c.orig Thu Jul 29 19:14:17 1999 +++ util.c Thu Jul 29 20:49:16 1999 @@ -107,6 +107,8 @@ ln.file = fn; ln.line_no = 0; + ln.bufsize = 81; /* Magical constants, yeah! */ + ln.dat = grep_malloc(81); linesqueued = 0; if (Bflag > 0) @@ -115,11 +117,14 @@ ln.off = grep_tell(); if ((tmp = grep_getln(&ln.len)) == NULL) break; - ln.dat = grep_malloc(ln.len + 1); + if (ln.bufsize < ln.len + 1) + ln.dat = grep_realloc(ln.dat, ln.len + 1); memcpy(ln.dat, tmp, ln.len); - ln.dat[ln.len] = 0; if (ln.len > 0 && ln.dat[ln.len - 1] == '\n') ln.dat[--ln.len] = 0; + else + ln.dat[ln.len] = 0; + ln.line_no++; z = tail; @@ -127,9 +132,9 @@ enqueue(&ln); linesqueued++; } - free(ln.dat); c += t; } + free(ln.dat); if (Bflag > 0) clearqueue(); grep_close(); --- grep.h.orig Thu Jul 29 20:47:52 1999 +++ grep.h Thu Jul 29 20:48:34 1999 @@ -35,6 +35,7 @@ typedef struct { size_t len; + size_t bufsize; int line_no; int off; char *file; -- Daniel C. Sobral (8-DCS) d...@newsguy.com d...@freebsd.org "Is it true that you're a millionaire's son who never worked a day in your life?" "Yeah, I guess so." "Lemme tell you, son, you ain't missed a thing." To Unsubscribe: send mail to majord...@freebsd.org with "unsubscribe freebsd-hackers" in the body of the message