@matheusbsbs / matheus-bagliano / commits / ec640ed1cf
Fork 0

remove dead code from the csum-file interface

The provided name argument is always constant and valid in every caller's context, so no need to have an array of PATH_MAX chars to copy it into when a simple pointer will do. Unfortunately that means getting rid of wascally wabbits too. The 'error' field is also unused. Signed-off-by: Nicolas Pitre <nico@cam.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Nicolas Pitre committed Nov 4, 2007 at 22:54 UTC ec640ed1cf1d62730555705ec18b785c43e81f62
2 files changed +5 -15
csum-file.c
+2 -12
@@ -88,22 +88,12 @@ struct sha1file *sha1fd(int fd, const char *name)
88
89 struct sha1file *sha1fd_throughput(int fd, const char *name, struct progress *tp)
90 {
91 - struct sha1file *f;
92 - unsigned len;
93 -
94 - f = xmalloc(sizeof(*f));
95 -
96 - len = strlen(name);
97 - if (len >= PATH_MAX)
98 - die("you wascally wabbit, you");
99 - f->namelen = len;
100 - memcpy(f->name, name, len+1);
101 -
91 + struct sha1file *f = xmalloc(sizeof(*f));
92 f->fd = fd;
103 - f->error = 0;
93 f->offset = 0;
94 f->total = 0;
95 f->tp = tp;
96 + f->name = name;
97 f->do_crc = 0;
98 SHA1_Init(&f->ctx);
99 return f;
csum-file.h
+3 -3
@@ -5,12 +5,12 @@ struct progress;
5
6 /* A SHA1-protected file */
7 struct sha1file {
8 - int fd, error;
9 - unsigned int offset, namelen;
8 + int fd;
9 + unsigned int offset;
10 SHA_CTX ctx;
11 off_t total;
12 struct progress *tp;
13 - char name[PATH_MAX];
13 + const char *name;
14 int do_crc;
15 uint32_t crc32;
16 unsigned char buffer[8192];