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

Convert memset(hash,0,20) to hashclr(hash).

In the same spirit as hashcmp() and hashcpy(). Signed-off-by: Junio C Hamano <junkio@cox.net>

Junio C Hamano committed Aug 23, 2006 at 13:57 UTC a8e0d16d85fb2ea53775f64549cac2396cd621a6
6 files changed +9 -5
blame.c
+1 -1
@@ -165,7 +165,7 @@ static int get_blob_sha1(struct tree *t, const char *pathname,
165 blame_file = pathname;
166 pathspec[0] = pathname;
167 pathspec[1] = NULL;
168 - memset(blob_sha1, 0, sizeof(blob_sha1));
168 + hashclr(blob_sha1);
169 read_tree_recursive(t, "", 0, 0, pathspec, get_blob_sha1_internal);
170
171 for (i = 0; i < 20; i++) {
builtin-update-ref.c
+1 -1
@@ -44,7 +44,7 @@ int cmd_update_ref(int argc, const char **argv, const char *prefix)
44
45 if (get_sha1(value, sha1))
46 die("%s: not a valid SHA1", value);
47 - memset(oldsha1, 0, 20);
47 + hashclr(oldsha1);
48 if (oldval && get_sha1(oldval, oldsha1))
49 die("%s: not a valid old SHA1", oldval);
50
cache.h
+4
@@ -222,6 +222,10 @@ static inline void hashcpy(unsigned char *sha_dst, const unsigned char *sha_src)
222 {
223 memcpy(sha_dst, sha_src, 20);
224 }
225 +static inline void hashclr(unsigned char *hash)
226 +{
227 + memset(hash, 0, 20);
228 +}
229
230 int git_mkstemp(char *path, size_t n, const char *template);
231
diff-lib.c
+1 -1
@@ -48,7 +48,7 @@ int run_diff_files(struct rev_info *revs, int silent_on_removed)
48 memcpy(dpath->path, ce->name, path_len);
49 dpath->path[path_len] = '\0';
50 dpath->mode = 0;
51 - memset(dpath->sha1, 0, 20);
51 + hashclr(dpath->sha1);
52 memset(&(dpath->parent[0]), 0,
53 sizeof(struct combine_diff_parent)*5);
54
http-push.c
+1 -1
@@ -2164,7 +2164,7 @@ static void fetch_symref(const char *path, char **symref, unsigned char *sha1)
2164 if (*symref != NULL)
2165 free(*symref);
2166 *symref = NULL;
2167 - memset(sha1, 0, 20);
2167 + hashclr(sha1);
2168
2169 if (buffer.posn == 0)
2170 return;
sha1_name.c
+1 -1
@@ -159,7 +159,7 @@ static int get_short_sha1(const char *name, int len, unsigned char *sha1,
159
160 if (len < MINIMUM_ABBREV)
161 return -1;
162 - memset(res, 0, 20);
162 + hashclr(res);
163 memset(canonical, 'x', 40);
164 for (i = 0; i < len ;i++) {
165 unsigned char c = name[i];