]> git.ipfire.org Git - thirdparty/git.git/commitdiff
object: add object_array initializer helper function
authorTaylor Blau <me@ttaylorr.com>
Mon, 8 May 2023 17:38:06 +0000 (13:38 -0400)
committerJunio C Hamano <gitster@pobox.com>
Mon, 8 May 2023 19:05:55 +0000 (12:05 -0700)
The object_array API has an OBJECT_ARRAY_INIT macro, but lacks a
function to initialize an object_array at a given location in memory.

Introduce `object_array_init()` to implement such a function.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
object.c
object.h

index 6d4ef1524defed90be95ee17372e37ed099cd27e..f1adb458b636532b6f64d4a10190b5a2ef963825 100644 (file)
--- a/object.c
+++ b/object.c
@@ -356,6 +356,12 @@ void object_list_free(struct object_list **list)
  */
 static char object_array_slopbuf[1];
 
+void object_array_init(struct object_array *array)
+{
+       struct object_array blank = OBJECT_ARRAY_INIT;
+       memcpy(array, &blank, sizeof(*array));
+}
+
 void add_object_array_with_path(struct object *obj, const char *name,
                                struct object_array *array,
                                unsigned mode, const char *path)
index 96e52e24fb1b777592373e955e07002f5c64ee1d..c335435f9cd8952db5a9d068ad64fde69db5bfdb 100644 (file)
--- a/object.h
+++ b/object.h
@@ -57,6 +57,8 @@ struct object_array {
 
 #define OBJECT_ARRAY_INIT { 0 }
 
+void object_array_init(struct object_array *array);
+
 /*
  * object flag allocation:
  * revision.h:               0---------10         15             23------27