Code

url: add str wrapper for end_url_with_slash()
authorTay Ray Chuan <rctay89@gmail.com>
Thu, 25 Nov 2010 08:21:05 +0000 (16:21 +0800)
committerJunio C Hamano <gitster@pobox.com>
Fri, 26 Nov 2010 22:50:45 +0000 (14:50 -0800)
Helped-by: Johnathan Nieder <jrnieder@gmail.com>
Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
url.c
url.h

diff --git a/url.c b/url.c
index 7cebc6471b1aea9b001cb44e57a5d0c9a4d8757a..6a5495960f03ded65f0f5f8b8bd5c7cd98c0b05e 100644 (file)
--- a/url.c
+++ b/url.c
@@ -132,3 +132,10 @@ void end_url_with_slash(struct strbuf *buf, const char *url)
        if (buf->len && buf->buf[buf->len - 1] != '/')
                strbuf_addstr(buf, "/");
 }
+
+void str_end_url_with_slash(const char *url, char **dest) {
+       struct strbuf buf = STRBUF_INIT;
+       end_url_with_slash(&buf, url);
+       free(*dest);
+       *dest = strbuf_detach(&buf, NULL);
+}
diff --git a/url.h b/url.h
index 8cb74d4a0a8b30afcbf03650cd511cad27e8e4d1..7100e3215a97b234c8ab93b76f7f86518f7c3382 100644 (file)
--- a/url.h
+++ b/url.h
@@ -8,5 +8,6 @@ extern char *url_decode_parameter_name(const char **query);
 extern char *url_decode_parameter_value(const char **query);
 
 extern void end_url_with_slash(struct strbuf *buf, const char *url);
+extern void str_end_url_with_slash(const char *url, char **dest);
 
 #endif /* URL_H */