speedup by pitching the "compacting" realloc, which loses with new malloc
authorJay Lepreau <lepreau@ucbvax.Berkeley.EDU>
Tue, 4 Jun 1985 14:13:38 +0000 (06:13 -0800)
committerJay Lepreau <lepreau@ucbvax.Berkeley.EDU>
Tue, 4 Jun 1985 14:13:38 +0000 (06:13 -0800)
SCCS-vsn: usr.bin/diff/diff/diff.c 4.3
SCCS-vsn: usr.bin/diff/diff/diff.h 4.5
SCCS-vsn: usr.bin/diff/diff/diffreg.c 4.9

usr/src/usr.bin/diff/diff/diff.c
usr/src/usr.bin/diff/diff/diff.h
usr/src/usr.bin/diff/diff/diffreg.c

index 43fbae0..8d82563 100644 (file)
@@ -1,4 +1,4 @@
-static char sccsid[] = "@(#)diff.c 4.2 %G%";
+static char sccsid[] = "@(#)diff.c 4.3 %G%";
 
 #include "diff.h"
 /*
 
 #include "diff.h"
 /*
@@ -172,23 +172,20 @@ char *
 talloc(n)
 {
        register char *p;
 talloc(n)
 {
        register char *p;
-       p = malloc((unsigned)n);
-       if(p!=NULL)
+
+       if ((p = malloc((unsigned)n)) != NULL)
                return(p);
        noroom();
 }
 
 char *
                return(p);
        noroom();
 }
 
 char *
-ralloc(p,n)    /*compacting reallocation */
+ralloc(p,n)
 char *p;
 {
        register char *q;
        char *realloc();
 char *p;
 {
        register char *q;
        char *realloc();
-       free(p);
-       free(dummy);
-       dummy = malloc(1);
-       q = realloc(p, (unsigned)n);
-       if(q==NULL)
+
+       if ((q = realloc(p, (unsigned)n)) == NULL)
                noroom();
        return(q);
 }
                noroom();
        return(q);
 }
index a5202cc..aaa022c 100644 (file)
@@ -1,4 +1,4 @@
-/*     diff.h  4.4     83/07/01        */
+/*     diff.h  4.5     85/06/03        */
 
 /*
  * diff - common declarations
 
 /*
  * diff - common declarations
@@ -72,12 +72,6 @@ char *file1, *file2, *efile1, *efile2;
 struct stat stb1, stb2;
 struct stat stb1, stb2;
 
 struct stat stb1, stb2;
 struct stat stb1, stb2;
 
-/*
- * This is allocated early, and used
- * to reset the free storage pointer to effect space compaction.
- */
-char   *dummy;
-
 char   *malloc(), *talloc(), *ralloc();
 char   *savestr(), *splice(), *splicen();
 char   *mktemp(), *copytemp(), *rindex();
 char   *malloc(), *talloc(), *ralloc();
 char   *savestr(), *splice(), *splicen();
 char   *mktemp(), *copytemp(), *rindex();
index 780caf6..fd4e873 100644 (file)
@@ -1,4 +1,4 @@
-static char sccsid[] = "@(#)diffreg.c 4.8 %G%";
+static char sccsid[] = "@(#)diffreg.c 4.9 %G%";
 
 #include "diff.h"
 /*
 
 #include "diff.h"
 /*
@@ -108,7 +108,6 @@ diffreg()
                perror(diffh);
                done();
        }
                perror(diffh);
                done();
        }
-       dummy = malloc(1);
        if ((stb1.st_mode & S_IFMT) == S_IFDIR)
                file1 = splice(file1, file2);
        else if ((stb2.st_mode & S_IFMT) == S_IFDIR)
        if ((stb1.st_mode & S_IFMT) == S_IFDIR)
                file1 = splice(file1, file2);
        else if ((stb2.st_mode & S_IFMT) == S_IFDIR)