char *git_path_basename(const char *path) { git_buf buf = GIT_BUF_INIT; char *basename; git_path_basename_r(&buf, path); basename = git_buf_detach(&buf); git_buf_free(&buf); /* avoid memleak if error occurs */ return basename; }
static void check_basename(const char *A, const char *B) { git_buf base = GIT_BUF_INIT; char *base2; cl_assert(git_path_basename_r(&base, A) >= 0); cl_assert_equal_s(B, base.ptr); git_buf_dispose(&base); cl_assert((base2 = git_path_basename(A)) != NULL); cl_assert_equal_s(B, base2); git__free(base2); }