shorten_unambiguous_ref(): tighten up pointer arithmetic
[gitweb.git] / object.c
index 5f792cbfd38c0b30d763902ba5f9399992ddab89..584f7acb36b68d17678b3fd6251105241794ea48 100644 (file)
--- a/object.c
+++ b/object.c
@@ -262,18 +262,16 @@ int object_list_contains(struct object_list *list, struct object *obj)
        return 0;
 }
 
-void add_object_array(struct object *obj, const char *name, struct object_array *array)
-{
-       add_object_array_with_mode(obj, name, array, S_IFINVALID);
-}
-
 /*
  * A zero-length string to which object_array_entry::name can be
  * initialized without requiring a malloc/free.
  */
 static char object_array_slopbuf[1];
 
-void add_object_array_with_mode(struct object *obj, const char *name, struct object_array *array, unsigned mode)
+static void add_object_array_with_mode_context(struct object *obj, const char *name,
+                                              struct object_array *array,
+                                              unsigned mode,
+                                              struct object_context *context)
 {
        unsigned nr = array->nr;
        unsigned alloc = array->alloc;
@@ -296,9 +294,28 @@ void add_object_array_with_mode(struct object *obj, const char *name, struct obj
        else
                entry->name = xstrdup(name);
        entry->mode = mode;
+       entry->context = context;
        array->nr = ++nr;
 }
 
+void add_object_array(struct object *obj, const char *name, struct object_array *array)
+{
+       add_object_array_with_mode(obj, name, array, S_IFINVALID);
+}
+
+void add_object_array_with_mode(struct object *obj, const char *name, struct object_array *array, unsigned mode)
+{
+       add_object_array_with_mode_context(obj, name, array, mode, NULL);
+}
+
+void add_object_array_with_context(struct object *obj, const char *name, struct object_array *array, struct object_context *context)
+{
+       if (context)
+               add_object_array_with_mode_context(obj, name, array, context->mode, context);
+       else
+               add_object_array_with_mode_context(obj, name, array, S_IFINVALID, context);
+}
+
 void object_array_filter(struct object_array *array,
                         object_array_each_func_t want, void *cb_data)
 {