summaryrefslogtreecommitdiff
path: root/connect.c
diff options
context:
space:
mode:
authorLibravatar René Scharfe <rene.scharfe@lsrfire.ath.cx>2008-10-18 10:41:33 +0200
committerLibravatar Junio C Hamano <gitster@pobox.com>2008-10-18 06:53:47 -0700
commitb0b44bc7b26c8c4b4221a377ce6ba174b843cb8d (patch)
tree511f98f4017d7ce38a775dfecaa91abb7b8b532f /connect.c
parentadd alloc_ref_with_prefix() (diff)
downloadtgif-b0b44bc7b26c8c4b4221a377ce6ba174b843cb8d.tar.xz
use alloc_ref_from_str() everywhere
Replace pairs of alloc_ref() and strcpy() with alloc_ref_from_str(), simplifying the code. In connect.c, also a pair of alloc_ref() and memcpy() is replaced -- the additional cost of a strlen() call should not have too much of an impact. Consistency and simplicity are more important. In remote.c, the code was allocating 11 bytes more than needed for the name part, but I couldn't see them being used for anything. Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'connect.c')
-rw-r--r--connect.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/connect.c b/connect.c
index 67d2cd86a8..b69060bca0 100644
--- a/connect.c
+++ b/connect.c
@@ -90,9 +90,8 @@ struct ref **get_remote_heads(int in, struct ref **list,
continue;
if (nr_match && !path_match(name, nr_match, match))
continue;
- ref = alloc_ref(name_len + 1);
+ ref = alloc_ref_from_str(buffer + 41);
hashcpy(ref->old_sha1, old_sha1);
- memcpy(ref->name, buffer + 41, name_len + 1);
*list = ref;
list = &ref->next;
}