aboutsummaryrefslogtreecommitdiffstats
path: root/strvec.c
diff options
context:
space:
mode:
authorJohannes Schindelin <johannes.schindelin@gmx.de>2024-07-13 21:08:19 +0000
committerJunio C Hamano <gitster@pobox.com>2024-07-13 16:23:36 -0700
commitce68178a0ae222b71fe5f89f05dc7113267c079b (patch)
tree375b67d03cd841b318b06e9cce2894d72329d931 /strvec.c
parentrun-command: refactor getting the Unix shell path into its own function (diff)
downloadgit-ce68178a0ae222b71fe5f89f05dc7113267c079b.tar.gz
git-ce68178a0ae222b71fe5f89f05dc7113267c079b.zip
strvec: declare the `strvec_push_nodup()` function globally
This function differs from `strvec_push()` in that it takes ownership of the allocated string that is passed as second argument. This is useful when appending elements to the string array that have been freshly allocated and serve no further other purpose after that. Without declaring this function globally, call sites would allocate the memory, only to have `strvec_push()` duplicate the string, and then the first copy would need to be released. Having this function globally avoids that kind of unnecessary work. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'strvec.c')
-rw-r--r--strvec.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/strvec.c b/strvec.c
index d4073ec9fa..f712070f57 100644
--- a/strvec.c
+++ b/strvec.c
@@ -10,7 +10,7 @@ void strvec_init(struct strvec *array)
memcpy(array, &blank, sizeof(*array));
}
-static void strvec_push_nodup(struct strvec *array, const char *value)
+void strvec_push_nodup(struct strvec *array, char *value)
{
if (array->v == empty_strvec)
array->v = NULL;