Use xmalloc instead of malloc
[gitweb.git] / send-pack.c
index 43e10b0a620cc3d51d8905a9de36350ca6b67966..ac4501d34154301030cf98ff122eb233095417b7 100644 (file)
@@ -53,7 +53,7 @@ static void exec_rev_list(struct ref *refs)
                if (900 < i)
                        die("git-rev-list environment overflow");
                if (!is_zero_sha1(ref->new_sha1)) {
-                       char *buf = malloc(100);
+                       char *buf = xmalloc(100);
                        args[i++] = buf;
                        snprintf(buf, 50, "%s", sha1_to_hex(ref->new_sha1));
                        buf += 50;
@@ -75,7 +75,7 @@ static void exec_rev_list(struct ref *refs)
                if (is_zero_sha1(ref->new_sha1) &&
                    !is_zero_sha1(ref->old_sha1) &&
                    has_sha1_file(ref->old_sha1)) {
-                       char *buf = malloc(42);
+                       char *buf = xmalloc(42);
                        args[i++] = buf;
                        snprintf(buf, 42, "^%s", sha1_to_hex(ref->old_sha1));
                }
@@ -185,7 +185,7 @@ static int one_local_ref(const char *refname, const unsigned char *sha1)
        struct ref *ref;
        int len = strlen(refname) + 1;
        ref = xcalloc(1, sizeof(*ref) + len);
-       memcpy(ref->new_sha1, sha1, 20);
+       hashcpy(ref->new_sha1, sha1);
        memcpy(ref->name, refname, len);
        *local_tail = ref;
        local_tail = &ref->next;
@@ -265,7 +265,7 @@ static int send_pack(int in, int out, int nr_refspec, char **refspec)
                char old_hex[60], *new_hex;
                if (!ref->peer_ref)
                        continue;
-               if (!memcmp(ref->old_sha1, ref->peer_ref->new_sha1, 20)) {
+               if (!hashcmp(ref->old_sha1, ref->peer_ref->new_sha1)) {
                        if (verbose)
                                fprintf(stderr, "'%s': up-to-date\n", ref->name);
                        continue;
@@ -310,7 +310,7 @@ static int send_pack(int in, int out, int nr_refspec, char **refspec)
                                continue;
                        }
                }
-               memcpy(ref->new_sha1, ref->peer_ref->new_sha1, 20);
+               hashcpy(ref->new_sha1, ref->peer_ref->new_sha1);
                if (is_zero_sha1(ref->new_sha1)) {
                        error("cannot happen anymore");
                        ret = -3;