Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2013-08-22 01:10:27 +0400
committerRussell Belfer <rb@github.com>2013-08-22 01:10:27 +0400
commit24c71f14b4dcb696d9d87330322c12fd2c185317 (patch)
tree779a0dcb86c051b5722aa60c784020e4b171fc80 /src/refs.c
parenta4977169e1e1920ed33f10a77e5dd8706f103f4f (diff)
Add internal ref set_name fn instead of realloc
The refdb_fs implementation calls realloc directly on a reference object when it wants to rename it. It is not a public object, so this doesn't mess with the immutability of references, but it does assume certain constraints on the reference representation. This commit wraps that assumption in an isolated API to isolate it.
Diffstat (limited to 'src/refs.c')
-rw-r--r--src/refs.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/refs.c b/src/refs.c
index c0e460cc3..e59b34aae 100644
--- a/src/refs.c
+++ b/src/refs.c
@@ -88,6 +88,17 @@ git_reference *git_reference__alloc(
return ref;
}
+git_reference *git_reference__set_name(
+ git_reference *ref, const char *name)
+{
+ size_t namelen = strlen(name);
+ git_reference *rewrite =
+ git__realloc(ref, sizeof(git_reference) + namelen + 1);
+ if (rewrite != NULL)
+ memcpy(rewrite->name, name, namelen + 1);
+ return rewrite;
+}
+
void git_reference_free(git_reference *reference)
{
if (reference == NULL)