Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
is_refname_available(): convert local variable "dirname" to strbuf
author
Michael Haggerty
<mhagger@alum.mit.edu>
Mon, 11 May 2015 15:25:06 +0000
(17:25 +0200)
committer
Junio C Hamano
<gitster@pobox.com>
Mon, 11 May 2015 18:50:17 +0000
(11:50 -0700)
This change wouldn't be worth it by itself, but in a moment we will
use the strbuf for more string juggling.
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
refs.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
9ef6eaa
)
diff --git
a/refs.c
b/refs.c
index 9d87e84f4227c7640cbf733ebe1c8d26f9d502ee..faabd685c482bc76b5f45210f298675523f0fe41 100644
(file)
--- a/
refs.c
+++ b/
refs.c
@@
-887,9
+887,8
@@
static int is_refname_available(const char *refname,
struct ref_dir *dir)
{
const char *slash;
struct ref_dir *dir)
{
const char *slash;
- size_t len;
int pos;
int pos;
-
char *dirname
;
+
struct strbuf dirname = STRBUF_INIT
;
/*
* For the sake of comments in this function, suppose that
/*
* For the sake of comments in this function, suppose that
@@
-955,11
+954,10
@@
static int is_refname_available(const char *refname,
* names are in the "refs/foo/bar/" namespace, because they
* *do* conflict.
*/
* names are in the "refs/foo/bar/" namespace, because they
* *do* conflict.
*/
- len = strlen(refname);
- dirname = xmallocz(len + 1);
- sprintf(dirname, "%s/", refname);
- pos = search_ref_dir(dir, dirname, len + 1);
- free(dirname);
+ strbuf_addstr(&dirname, refname);
+ strbuf_addch(&dirname, '/');
+ pos = search_ref_dir(dir, dirname.buf, dirname.len);
+ strbuf_release(&dirname);
if (pos >= 0) {
/*
if (pos >= 0) {
/*