Skip to content

Commit fe90355

Browse files
ttaylorrgitster
authored andcommitted
object: add object_array initializer helper function
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent fc23c39 commit fe90355

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

object.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,12 @@ void object_list_free(struct object_list **list)
356356
*/
357357
static char object_array_slopbuf[1];
358358

359+
void object_array_init(struct object_array *array)
360+
{
361+
struct object_array blank = OBJECT_ARRAY_INIT;
362+
memcpy(array, &blank, sizeof(*array));
363+
}
364+
359365
void add_object_array_with_path(struct object *obj, const char *name,
360366
struct object_array *array,
361367
unsigned mode, const char *path)

object.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ struct object_array {
5757

5858
#define OBJECT_ARRAY_INIT { 0 }
5959

60+
void object_array_init(struct object_array *array);
61+
6062
/*
6163
* object flag allocation:
6264
* revision.h: 0---------10 15 23------27

0 commit comments

Comments
 (0)