Skip to content

Commit b4ea30c

Browse files
author
David Catmull
committed
Use git_oid_tostr_s for GTOID.SHA
1 parent bbea49d commit b4ea30c

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

ObjectiveGit/GTOID.m

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,11 @@ - (const git_oid *)git_oid {
2727
}
2828

2929
- (NSString *)SHA {
30-
char *SHA = malloc(GIT_OID_HEXSZ);
31-
NSAssert(SHA != NULL, @"Failed to malloc SHA string");
32-
33-
git_oid_fmt(SHA, self.git_oid);
34-
35-
NSString *str = [[NSString alloc] initWithBytesNoCopy:SHA length:GIT_OID_HEXSZ encoding:NSUTF8StringEncoding freeWhenDone:YES];
36-
NSAssert(str != nil, @"Failed to allocate SHA string");
30+
char *SHA = git_oid_tostr_s(self.git_oid);
31+
NSString *str = [[NSString alloc] initWithBytes:SHA
32+
length:GIT_OID_HEXSZ
33+
encoding:NSUTF8StringEncoding];
34+
NSAssert(str != nil, @"Failed to create SHA string");
3735
return str;
3836
}
3937

0 commit comments

Comments
 (0)