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 /mem-pool.h
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 'mem-pool.h')
-rw-r--r--mem-pool.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/mem-pool.h b/mem-pool.h
index 999d3c3a52..ca062c9070 100644
--- a/mem-pool.h
+++ b/mem-pool.h
@@ -42,6 +42,12 @@ void *mem_pool_alloc(struct mem_pool *pool, size_t len);
void *mem_pool_calloc(struct mem_pool *pool, size_t count, size_t size);
/*
+ * Allocate memory from the memory pool and copy str into it.
+ */
+char *mem_pool_strdup(struct mem_pool *pool, const char *str);
+char *mem_pool_strndup(struct mem_pool *pool, const char *str, size_t len);
+
+/*
* Move the memory associated with the 'src' pool to the 'dst' pool. The 'src'
* pool will be empty and not contain any memory. It still needs to be free'd
* with a call to `mem_pool_discard`.