if (!*size) {
/* mmap() is forbidden on empty files */
error(_("object file %s is empty"), path);
+ close(fd);
return NULL;
}
map = xmmap(NULL, *size, PROT_READ, MAP_PRIVATE, fd, 0);
const struct object_id *oid)
{
int subdir_nr = oid->hash[0];
- odb_load_loose_cache(odb, subdir_nr);
- return &odb->loose_objects_cache;
-}
-
-void odb_load_loose_cache(struct object_directory *odb, int subdir_nr)
-{
struct strbuf buf = STRBUF_INIT;
if (subdir_nr < 0 ||
BUG("subdir_nr out of range");
if (odb->loose_objects_subdir_seen[subdir_nr])
- return;
+ return &odb->loose_objects_cache[subdir_nr];
strbuf_addstr(&buf, odb->path);
for_each_file_in_obj_subdir(subdir_nr, &buf,
append_loose_object,
NULL, NULL,
- &odb->loose_objects_cache);
+ &odb->loose_objects_cache[subdir_nr]);
odb->loose_objects_subdir_seen[subdir_nr] = 1;
strbuf_release(&buf);
+ return &odb->loose_objects_cache[subdir_nr];
}
void odb_clear_loose_cache(struct object_directory *odb)
{
- oid_array_clear(&odb->loose_objects_cache);
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(odb->loose_objects_cache); i++)
+ oid_array_clear(&odb->loose_objects_cache[i]);
memset(&odb->loose_objects_subdir_seen, 0,
sizeof(odb->loose_objects_subdir_seen));
}