From fa929eb7c96270ad9a58e17bb858c47f4fb85fe2 Mon Sep 17 00:00:00 2001 From: Morgan Schweers Date: Sat, 24 Oct 2009 00:58:20 -0700 Subject: [PATCH] Use the libgit2 allocfmt method, instead of hacking it by hand. --- PBGitCommit.m | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/PBGitCommit.m b/PBGitCommit.m index 0abc3f0..632d97a 100644 --- a/PBGitCommit.m +++ b/PBGitCommit.m @@ -22,11 +22,9 @@ NSMutableArray *p = [NSMutableArray arrayWithCapacity:nParents]; for (i = 0; i < nParents; ++i) { - char s[41]; - git_oid_fmt(s, parentShas + i); - s[40] = 0; + char *s = git_oid_allocfmt(parentShas + i); [p addObject:[NSString stringWithUTF8String:s]]; -// free(s); + free(s); } return p; } @@ -123,12 +121,9 @@ - (NSString *)realSha { - char hex[41]; - git_oid_fmt(hex, &sha); - hex[40] = 0; -// char *hex = git_oid_mkhex(&sha); + char *hex = git_oid_allocfmt(&sha); NSString *str = [NSString stringWithUTF8String:hex]; -// free(hex); + free(hex); return str; }