X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=convert-cache.c;h=77f8bff9ac0cd61412e69921c610e7301f7c350b;hb=af3f929f9546268ede788b4217ff0b6a655ab62a;hp=7102e455163563894448fd7090d2409e379ed314;hpb=a44c9a5e2e6d4108452f2c64dbd11f74a83745af;p=git.git diff --git a/convert-cache.c b/convert-cache.c index 7102e4551..77f8bff9a 100644 --- a/convert-cache.c +++ b/convert-cache.c @@ -18,8 +18,7 @@ static struct entry * convert_entry(unsigned char *sha1); static struct entry *insert_new(unsigned char *sha1, int pos) { - struct entry *new = malloc(sizeof(struct entry)); - + struct entry *new = xmalloc(sizeof(struct entry)); memset(new, 0, sizeof(*new)); memcpy(new->old_sha1, sha1, 20); memmove(convert + pos + 1, convert + pos, (nr_convert - pos) * sizeof(struct entry *)); @@ -68,7 +67,7 @@ static void convert_ascii_sha1(void *buffer) static int write_subdirectory(void *buffer, unsigned long size, const char *base, int baselen, unsigned char *result_sha1) { - char *new = malloc(size); + char *new = xmalloc(size); unsigned long newlen = 0; unsigned long used; @@ -100,7 +99,7 @@ static int write_subdirectory(void *buffer, unsigned long size, const char *base continue; } - newlen += sprintf(new + newlen, "%o %.*s", S_IFDIR, slash - path, path); + newlen += sprintf(new + newlen, "%o %.*s", S_IFDIR, (int)(slash - path), path); new[newlen++] = 0; sha1 = (unsigned char *)(new + newlen); newlen += 20; @@ -226,9 +225,9 @@ static int convert_date_line(char *dst, void **buf, unsigned long *sp) static void convert_date(void *buffer, unsigned long size, unsigned char *result_sha1) { - char *new = malloc(size + 100); + char *new = xmalloc(size + 100); unsigned long newlen = 0; - + // "tree \n" memcpy(new + newlen, buffer, 46); newlen += 46; @@ -283,7 +282,7 @@ static struct entry * convert_entry(unsigned char *sha1) if (!data) die("unable to read object %s", sha1_to_hex(sha1)); - buffer = malloc(size); + buffer = xmalloc(size); memcpy(buffer, data, size); if (!strcmp(type, "blob")) { @@ -304,8 +303,8 @@ int main(int argc, char **argv) unsigned char sha1[20]; struct entry *entry; - if (argc != 2 || get_sha1_hex(argv[1], sha1)) - usage("convert-cache "); + if (argc != 2 || get_sha1(argv[1], sha1)) + usage("git-convert-cache "); entry = convert_entry(sha1); printf("new sha1: %s\n", sha1_to_hex(entry->new_sha1));