From 5bb1cda5f73988963e7470f3cd75a380751f6d99 Mon Sep 17 00:00:00 2001 From: Rene Scharfe Date: Fri, 11 Aug 2006 14:01:45 +0200 Subject: drop length argument of has_extension As Fredrik points out the current interface of has_extension() is potentially confusing. Its parameters include both a nul-terminated string and a length-limited string. This patch drops the length argument, requiring two nul-terminated strings; all callsites are updated. I checked that all of them indeed provide nul-terminated strings. Filenames need to be nul-terminated anyway if they are to be passed to open() etc. The performance penalty of the additional strlen() is negligible compared to the system calls which inevitably surround has_extension() calls. Additionally, change has_extension() to use size_t inside instead of int, as that is the exact type strlen() returns and memcmp() expects. Signed-off-by: Rene Scharfe Signed-off-by: Junio C Hamano --- index-pack.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'index-pack.c') diff --git a/index-pack.c b/index-pack.c index a91e39ecd6..b20659c259 100644 --- a/index-pack.c +++ b/index-pack.c @@ -447,7 +447,7 @@ int main(int argc, char **argv) usage(index_pack_usage); if (!index_name) { int len = strlen(pack_name); - if (!has_extension(pack_name, len, ".pack")) + if (!has_extension(pack_name, ".pack")) die("packfile name '%s' does not end with '.pack'", pack_name); index_name_buf = xmalloc(len); -- cgit v1.2.3