FreeBSD Bugzilla – Attachment 11388 Details for
Bug 22442
[PATCH] Increase speed of split(1)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
file.diff
file.diff (text/plain), 1.93 KB, created by
George Reid
on 2000-10-31 14:30:01 UTC
(
hide
)
Description:
file.diff
Filename:
MIME Type:
Creator:
George Reid
Created:
2000-10-31 14:30:01 UTC
Size:
1.93 KB
patch
obsolete
>--- split.c.orig Tue Oct 31 14:11:46 2000 >+++ split.c Tue Oct 31 14:16:30 2000 >@@ -62,7 +62,7 @@ > long numlines; /* Line count to split on. */ > int file_open; /* If a file open. */ > int ifd = -1, ofd = -1; /* Input/output file descriptors. */ >-char bfr[MAXBSIZE]; /* I/O buffer. */ >+char *bfr; /* I/O buffer. */ > char fname[MAXPATHLEN]; /* File name prefix. */ > regex_t rgx; > int pflag; >@@ -176,11 +176,16 @@ > int dist, len; > char *C; > >+ if((bfr = (char *)malloc(bytecnt)) == NULL) >+ err(EX_OSERR, "malloc"); >+ > for (bcnt = 0;;) >- switch ((len = read(ifd, bfr, MAXBSIZE))) { >+ switch ((len = read(ifd, bfr, bytecnt))) { > case 0: >+ free(bfr); > exit(0); > case -1: >+ free(bfr); > err(EX_IOERR, "read"); > /* NOTREACHED */ > default: >@@ -195,22 +200,29 @@ > len -= bytecnt, C += bytecnt) { > newfile(); > if (write(ofd, >- C, (int)bytecnt) != bytecnt) >+ C, (int)bytecnt) != bytecnt) { >+ free(bfr); > err(EX_IOERR, "write"); >+ } > } > if (len != 0) { > newfile(); >- if (write(ofd, C, len) != len) >+ if (write(ofd, C, len) != len) { >+ free(bfr); > err(EX_IOERR, "write"); >+ } > } else > file_open = 0; > bcnt = len; > } else { > bcnt += len; >- if (write(ofd, bfr, len) != len) >+ if (write(ofd, bfr, len) != len) { >+ free(bfr); > err(EX_IOERR, "write"); >+ } > } > } >+ free(bfr); > } > > /* >@@ -227,6 +239,9 @@ > if ((infp = fdopen(ifd, "r")) == NULL) > err(EX_NOINPUT, "fdopen"); > >+ if((bfr = (char *)malloc(MAXBSIZE)) == NULL) >+ err(EX_OSERR, "malloc"); >+ > /* Process input one line at a time */ > while (fgets(bfr, sizeof(bfr), infp) != NULL) { > const int len = strlen(bfr); >@@ -254,9 +269,13 @@ > newfile(); > > /* Write out line */ >- if (write(ofd, bfr, len) != len) >+ if (write(ofd, bfr, len) != len) { >+ free(bfr); > err(EX_IOERR, "write"); >+ } > } >+ >+ free(bfr); > > /* EOF or error? */ > if (ferror(infp))
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 22442
: 11388