···492492 array->nr = array->alloc = 0;
493493}
494494495495-/*
496496- * Return true if array already contains an entry.
497497- */
498498-static int contains_object(struct object_array *array,
499499- const struct object *item, const char *name)
500500-{
501501- unsigned nr = array->nr, i;
502502- struct object_array_entry *object = array->objects;
503503-504504- for (i = 0; i < nr; i++, object++)
505505- if (item == object->item && !strcmp(object->name, name))
506506- return 1;
507507- return 0;
508508-}
509509-510510-void object_array_remove_duplicates(struct object_array *array)
511511-{
512512- unsigned nr = array->nr, src;
513513- struct object_array_entry *objects = array->objects;
514514-515515- array->nr = 0;
516516- for (src = 0; src < nr; src++) {
517517- if (!contains_object(array, objects[src].item,
518518- objects[src].name)) {
519519- if (src != array->nr)
520520- objects[array->nr] = objects[src];
521521- array->nr++;
522522- } else {
523523- object_array_release_entry(&objects[src]);
524524- }
525525- }
526526-}
527527-528495void clear_object_flags(struct repository *repo, unsigned flags)
529496{
530497 int i;
531498532532- for (i=0; i < repo->parsed_objects->obj_hash_size; i++) {
499499+ for (i = 0; i < repo->parsed_objects->obj_hash_size; i++) {
533500 struct object *obj = repo->parsed_objects->obj_hash[i];
534501 if (obj)
535502 obj->flags &= ~flags;
-6
object.h
···327327 object_array_each_func_t want, void *cb_data);
328328329329/*
330330- * Remove from array all but the first entry with a given name.
331331- * Warning: this function uses an O(N^2) algorithm.
332332- */
333333-void object_array_remove_duplicates(struct object_array *array);
334334-335335-/*
336330 * Remove any objects from the array, freeing all used memory; afterwards
337331 * the array is ready to store more objects with add_object_array().
338332 */