From 88d5a6f6cd1b63e1637027322cdfdbeefe38c3ed Mon Sep 17 00:00:00 2001 From: Jeff King Date: Thu, 22 May 2014 05:44:09 -0400 Subject: daemon/config: factor out duplicate xstrdup_tolower We have two implementations of the same function; let's drop that to one. We take the name from daemon.c, but the implementation (which is just slightly more efficient) from the config code. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- strbuf.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'strbuf.c') diff --git a/strbuf.c b/strbuf.c index 1170d01c43..e26cb2c7fa 100644 --- a/strbuf.c +++ b/strbuf.c @@ -570,3 +570,16 @@ int fprintf_ln(FILE *fp, const char *fmt, ...) return -1; return ret + 1; } + +char *xstrdup_tolower(const char *string) +{ + char *result; + size_t len, i; + + len = strlen(string); + result = xmalloc(len + 1); + for (i = 0; i < len; i++) + result[i] = tolower(string[i]); + result[i] = '\0'; + return result; +} -- cgit v1.2.3