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

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElijah Newren <newren@gmail.com>2020-08-15 20:37:55 +0300
committerJunio C Hamano <gitster@pobox.com>2020-08-18 22:14:37 +0300
commita762c8c1e1e5b6352f027db80be4ca1c0077403d (patch)
treef2ce4542c00e8d27d94a0855edd0c0cc5eb5ae2d /fast-import.c
parent2befe97201e1f3175cce557866c5822793624b5a (diff)
mem-pool: add convenience functions for strdup and strndup
fast-import had a special mem_pool_strdup() convenience function that I want to be able to use from the new merge algorithm I am writing. Move it from fast-import to mem-pool, and also add a mem_pool_strndup() while at it that I also want to use. Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'fast-import.c')
-rw-r--r--fast-import.c12
1 files changed, 2 insertions, 10 deletions
diff --git a/fast-import.c b/fast-import.c
index ce47794db6..c45fe7474c 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -526,14 +526,6 @@ static unsigned int hc_str(const char *s, size_t len)
return r;
}
-static char *pool_strdup(const char *s)
-{
- size_t len = strlen(s) + 1;
- char *r = mem_pool_alloc(&fi_mem_pool, len);
- memcpy(r, s, len);
- return r;
-}
-
static void insert_mark(struct mark_set *s, uintmax_t idnum, struct object_entry *oe)
{
while ((idnum >> s->shift) >= 1024) {
@@ -615,7 +607,7 @@ static struct branch *new_branch(const char *name)
die("Branch name doesn't conform to GIT standards: %s", name);
b = mem_pool_calloc(&fi_mem_pool, 1, sizeof(struct branch));
- b->name = pool_strdup(name);
+ b->name = mem_pool_strdup(&fi_mem_pool, name);
b->table_next_branch = branch_table[hc];
b->branch_tree.versions[0].mode = S_IFDIR;
b->branch_tree.versions[1].mode = S_IFDIR;
@@ -2806,7 +2798,7 @@ static void parse_new_tag(const char *arg)
t = mem_pool_alloc(&fi_mem_pool, sizeof(struct tag));
memset(t, 0, sizeof(struct tag));
- t->name = pool_strdup(arg);
+ t->name = mem_pool_strdup(&fi_mem_pool, arg);
if (last_tag)
last_tag->next_tag = t;
else