diff options
author | Pierre Habouzit <madcoder@debian.org> | 2007-09-16 00:32:36 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2007-09-18 17:42:17 -0700 |
commit | 182af8343c307436bb5364309aa6d4d46fa5911d (patch) | |
tree | 154c50047e12595027a0d61f54bfdd6ecd2305a5 /refs.c | |
parent | 39bd2eb56af89d43a08ba54699d9a1849ab57b39 (diff) | |
download | git-182af8343c307436bb5364309aa6d4d46fa5911d.tar.gz |
Use xmemdupz() in many places.
Signed-off-by: Pierre Habouzit <madcoder@debian.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'refs.c')
-rw-r--r-- | refs.c | 12 |
1 files changed, 4 insertions, 8 deletions
@@ -1246,15 +1246,11 @@ int create_symref(const char *ref_target, const char *refs_heads_master, static char *ref_msg(const char *line, const char *endp) { const char *ep; - char *msg; - line += 82; - for (ep = line; ep < endp && *ep != '\n'; ep++) - ; - msg = xmalloc(ep - line + 1); - memcpy(msg, line, ep - line); - msg[ep - line] = 0; - return msg; + ep = memchr(line, '\n', endp - line); + if (!ep) + ep = endp; + return xmemdupz(line, ep - line); } int read_ref_at(const char *ref, unsigned long at_time, int cnt, unsigned char *sha1, char **msg, unsigned long *cutoff_time, int *cutoff_tz, int *cutoff_cnt) |