daemon/config: factor out duplicate xstrdup_tolower
[gitweb.git] / strbuf.c
index 1170d01c4322b494cd900853279766edd030de32..e26cb2c7fa38318d6065b7779e448c9e8e662857 100644 (file)
--- 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;
+}