Merge branch 'dl/flex-str-cocci'
authorJunio C Hamano <gitster@pobox.com>
Mon, 22 Apr 2019 02:14:47 +0000 (11:14 +0900)
committerJunio C Hamano <gitster@pobox.com>
Mon, 22 Apr 2019 02:14:48 +0000 (11:14 +0900)
Code clean-up.

* dl/flex-str-cocci:
cocci: FLEX_ALLOC_MEM to FLEX_ALLOC_STR
midx.c: convert FLEX_ALLOC_MEM to FLEX_ALLOC_STR

contrib/coccinelle/flex_alloc.cocci [new file with mode: 0644]
midx.c
diff --git a/contrib/coccinelle/flex_alloc.cocci b/contrib/coccinelle/flex_alloc.cocci
new file mode 100644 (file)
index 0000000..e9f7f6d
--- /dev/null
@@ -0,0 +1,13 @@
+@@
+expression str;
+identifier x, flexname;
+@@
+- FLEX_ALLOC_MEM(x, flexname, str, strlen(str));
++ FLEX_ALLOC_STR(x, flexname, str);
+
+@@
+expression str;
+identifier x, ptrname;
+@@
+- FLEXPTR_ALLOC_MEM(x, ptrname, str, strlen(str));
++ FLEXPTR_ALLOC_STR(x, ptrname, str);
diff --git a/midx.c b/midx.c
index f1cd868f8cf997c85996d69e5945bae64b02c9f6..f1137eb6ee7bb2d16062399965671cfda0e95e52 100644 (file)
--- a/midx.c
+++ b/midx.c
@@ -71,7 +71,7 @@ struct multi_pack_index *load_multi_pack_index(const char *object_dir, int local
 
        midx_map = xmmap(NULL, midx_size, PROT_READ, MAP_PRIVATE, fd, 0);
 
-       FLEX_ALLOC_MEM(m, object_dir, object_dir, strlen(object_dir));
+       FLEX_ALLOC_STR(m, object_dir, object_dir);
        m->fd = fd;
        m->data = midx_map;
        m->data_len = midx_size;