{
int cnt, pass;
struct strbuf sb = STRBUF_INIT;
- void *map;
- char *cp, *endp;
+ const char *cp, *endp;
ssize_t sz;
if (order)
sz = strbuf_read_file(&sb, orderfile, 0);
if (sz < 0)
die_errno(_("failed to read orderfile '%s'"), orderfile);
- map = strbuf_detach(&sb, NULL);
- endp = (char *) map + sz;
+ endp = sb.buf + sz;
for (pass = 0; pass < 2; pass++) {
cnt = 0;
- cp = map;
+ cp = sb.buf;
while (cp < endp) {
- char *ep;
+ const char *ep;
for (ep = cp; ep < endp && *ep != '\n'; ep++)
;
/* cp to ep has one line */
else if (pass == 0)
cnt++;
else {
- if (*ep == '\n') {
- *ep = 0;
- order[cnt] = cp;
- } else {
- order[cnt] = xmemdupz(cp, ep - cp);
- }
+ order[cnt] = xmemdupz(cp, ep - cp);
cnt++;
}
if (ep < endp)
ALLOC_ARRAY(order, cnt);
}
}
+
+ strbuf_release(&sb);
}
static int match_order(const char *path)
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
+TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
test_expect_success 'setup' '