test-dir-iterator: use path argument directly
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>
This commit is contained in:
parent
9b7b0295f9
commit
7df3bd462a
@ -10,7 +10,6 @@
|
|||||||
*/
|
*/
|
||||||
int cmd__dir_iterator(int argc, const char **argv)
|
int cmd__dir_iterator(int argc, const char **argv)
|
||||||
{
|
{
|
||||||
struct strbuf path = STRBUF_INIT;
|
|
||||||
struct dir_iterator *diter;
|
struct dir_iterator *diter;
|
||||||
unsigned int flags = 0;
|
unsigned int flags = 0;
|
||||||
int iter_status;
|
int iter_status;
|
||||||
@ -27,8 +26,7 @@ int cmd__dir_iterator(int argc, const char **argv)
|
|||||||
if (!*argv || argc != 1)
|
if (!*argv || argc != 1)
|
||||||
die("dir-iterator needs exactly one non-option argument");
|
die("dir-iterator needs exactly one non-option argument");
|
||||||
|
|
||||||
strbuf_add(&path, *argv, strlen(*argv));
|
diter = dir_iterator_begin(*argv, flags);
|
||||||
diter = dir_iterator_begin(path.buf, flags);
|
|
||||||
|
|
||||||
if (!diter) {
|
if (!diter) {
|
||||||
printf("dir_iterator_begin failure: %d\n", errno);
|
printf("dir_iterator_begin failure: %d\n", errno);
|
||||||
|
Loading…
Reference in New Issue
Block a user