test-dir-iterator: use path argument directly
authorRené Scharfe <l.s.r@web.de>
Wed, 7 Aug 2019 11:15:20 +0000 (13:15 +0200)
committerJunio C Hamano <gitster@pobox.com>
Wed, 7 Aug 2019 19:26:35 +0000 (12:26 -0700)
Avoid allocating and leaking a strbuf for holding a verbatim copy of the
path argument and pass the latter directly to dir_iterator_begin()
instead.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/helper/test-dir-iterator.c
index a5b96cb0dcfd0e5b493638bc5d6a310ffbf87db3..b421d2bf3864e9a5c35a1ef9f47cb4e452dd40d5 100644 (file)
@@ -10,7 +10,6 @@
  */
 int cmd__dir_iterator(int argc, const char **argv)
 {
-       struct strbuf path = STRBUF_INIT;
        struct dir_iterator *diter;
        unsigned int flags = 0;
        int iter_status;
@@ -27,8 +26,7 @@ int cmd__dir_iterator(int argc, const char **argv)
        if (!*argv || argc != 1)
                die("dir-iterator needs exactly one non-option argument");
 
-       strbuf_add(&path, *argv, strlen(*argv));
-       diter = dir_iterator_begin(path.buf, flags);
+       diter = dir_iterator_begin(*argv, flags);
 
        if (!diter) {
                printf("dir_iterator_begin failure: %d\n", errno);