diff options
author | Junio C Hamano <gitster@pobox.com> | 2013-01-23 21:19:06 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2013-01-23 21:19:06 -0800 |
commit | f12e49ae877ad0644b9b9939b7cb742da98691d2 (patch) | |
tree | 27ba91f64f9e126b4d9da2d5b1ec1c1d36f0118c | |
parent | fa2f83c654f36d666ef7c07e40e0d62a02fbfa06 (diff) | |
parent | c971ddfdcd319fb5cad95aa7047c54ebe6a22d1a (diff) | |
download | git-f12e49ae877ad0644b9b9939b7cb742da98691d2.tar.gz git-f12e49ae877ad0644b9b9939b7cb742da98691d2.tar.xz |
Merge branch 'rs/clarify-entry-cmp-sslice'
* rs/clarify-entry-cmp-sslice:
refs: use strncmp() instead of strlen() and memcmp()
-rw-r--r-- | refs.c | 10 |
1 files changed, 4 insertions, 6 deletions
@@ -333,14 +333,12 @@ struct string_slice { static int ref_entry_cmp_sslice(const void *key_, const void *ent_) { - struct string_slice *key = (struct string_slice *)key_; - struct ref_entry *ent = *(struct ref_entry **)ent_; - int entlen = strlen(ent->name); - int cmplen = key->len < entlen ? key->len : entlen; - int cmp = memcmp(key->str, ent->name, cmplen); + const struct string_slice *key = key_; + const struct ref_entry *ent = *(const struct ref_entry * const *)ent_; + int cmp = strncmp(key->str, ent->name, key->len); if (cmp) return cmp; - return key->len - entlen; + return '\0' - (unsigned char)ent->name[key->len]; } /* |