summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2006-08-23 13:57:23 -0700
committerJunio C Hamano <junkio@cox.net>2006-08-23 13:57:23 -0700
commita8e0d16d85fb2ea53775f64549cac2396cd621a6 (patch)
treeccf97a33f1fc45501bbe56bedcd24e71783df8e5
parente702496e434a160f798447b95b9cea3cd138c140 (diff)
downloadgit-a8e0d16d85fb2ea53775f64549cac2396cd621a6.tar.gz
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>
-rw-r--r--blame.c2
-rw-r--r--builtin-update-ref.c2
-rw-r--r--cache.h4
-rw-r--r--diff-lib.c2
-rw-r--r--http-push.c2
-rw-r--r--sha1_name.c2
6 files changed, 9 insertions, 5 deletions
diff --git a/blame.c b/blame.c
index 5a8af72623..8968046b00 100644
--- a/blame.c
+++ b/blame.c
@@ -165,7 +165,7 @@ static int get_blob_sha1(struct tree *t, const char *pathname,
blame_file = pathname;
pathspec[0] = pathname;
pathspec[1] = NULL;
- memset(blob_sha1, 0, sizeof(blob_sha1));
+ hashclr(blob_sha1);
read_tree_recursive(t, "", 0, 0, pathspec, get_blob_sha1_internal);
for (i = 0; i < 20; i++) {
diff --git a/builtin-update-ref.c b/builtin-update-ref.c
index 5bd71825fd..90a3da53ad 100644
--- a/builtin-update-ref.c
+++ b/builtin-update-ref.c
@@ -44,7 +44,7 @@ int cmd_update_ref(int argc, const char **argv, const char *prefix)
if (get_sha1(value, sha1))
die("%s: not a valid SHA1", value);
- memset(oldsha1, 0, 20);
+ hashclr(oldsha1);
if (oldval && get_sha1(oldval, oldsha1))
die("%s: not a valid old SHA1", oldval);
diff --git a/cache.h b/cache.h
index cc3f00c2b8..e00505a343 100644
--- a/cache.h
+++ b/cache.h
@@ -222,6 +222,10 @@ static inline void hashcpy(unsigned char *sha_dst, const unsigned char *sha_src)
{
memcpy(sha_dst, sha_src, 20);
}
+static inline void hashclr(unsigned char *hash)
+{
+ memset(hash, 0, 20);
+}
int git_mkstemp(char *path, size_t n, const char *template);
diff --git a/diff-lib.c b/diff-lib.c
index 2fc41263ae..9edfa92626 100644
--- a/diff-lib.c
+++ b/diff-lib.c
@@ -48,7 +48,7 @@ int run_diff_files(struct rev_info *revs, int silent_on_removed)
memcpy(dpath->path, ce->name, path_len);
dpath->path[path_len] = '\0';
dpath->mode = 0;
- memset(dpath->sha1, 0, 20);
+ hashclr(dpath->sha1);
memset(&(dpath->parent[0]), 0,
sizeof(struct combine_diff_parent)*5);
diff --git a/http-push.c b/http-push.c
index ebfcc73a9e..8df7a0d576 100644
--- a/http-push.c
+++ b/http-push.c
@@ -2164,7 +2164,7 @@ static void fetch_symref(const char *path, char **symref, unsigned char *sha1)
if (*symref != NULL)
free(*symref);
*symref = NULL;
- memset(sha1, 0, 20);
+ hashclr(sha1);
if (buffer.posn == 0)
return;
diff --git a/sha1_name.c b/sha1_name.c
index 89b9e3b77a..3f6b77ccfa 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -159,7 +159,7 @@ static int get_short_sha1(const char *name, int len, unsigned char *sha1,
if (len < MINIMUM_ABBREV)
return -1;
- memset(res, 0, 20);
+ hashclr(res);
memset(canonical, 'x', 40);
for (i = 0; i < len ;i++) {
unsigned char c = name[i];