Skip to content

Commit 8d9d382

Browse files
peffdscho
authored andcommitted
object-file: treat cached_object values as const
The cached-object API maps oids to in-memory entries. Once inserted, these entries should be immutable. Let's return them from the find_cached_object() call with a const tag to make this clear. Suggested-by: Patrick Steinhardt <[email protected]> Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0d85f8d commit 8d9d382

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

object-file.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -327,14 +327,14 @@ static struct cached_object_entry {
327327
} *cached_objects;
328328
static int cached_object_nr, cached_object_alloc;
329329

330-
static struct cached_object *find_cached_object(const struct object_id *oid)
330+
static const struct cached_object *find_cached_object(const struct object_id *oid)
331331
{
332-
static struct cached_object empty_tree = {
332+
static const struct cached_object empty_tree = {
333333
.type = OBJ_TREE,
334334
.buf = "",
335335
};
336336
int i;
337-
struct cached_object_entry *co = cached_objects;
337+
const struct cached_object_entry *co = cached_objects;
338338

339339
for (i = 0; i < cached_object_nr; i++, co++) {
340340
if (oideq(&co->oid, oid))
@@ -1629,7 +1629,7 @@ static int do_oid_object_info_extended(struct repository *r,
16291629
struct object_info *oi, unsigned flags)
16301630
{
16311631
static struct object_info blank_oi = OBJECT_INFO_INIT;
1632-
struct cached_object *co;
1632+
const struct cached_object *co;
16331633
struct pack_entry e;
16341634
int rtype;
16351635
const struct object_id *real = oid;

0 commit comments

Comments
 (0)