diff options
author | Jeff King <peff@peff.net> | 2024-11-18 04:55:19 -0500 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2024-11-18 21:48:48 +0900 |
commit | e37feea00b2b81c0295fddb4f5137d12ea1825c0 (patch) | |
tree | 6be8ae727efc77f585c1b03f5b88d0d7bcf76081 /object-file.c | |
parent | 9202ffcf1064f883aacc4aba8016918e1d8d8243 (diff) |
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 <ps@pks.im>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'object-file.c')
-rw-r--r-- | object-file.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/object-file.c b/object-file.c index 67a6731066..ec62e5fb3b 100644 --- a/object-file.c +++ b/object-file.c @@ -327,14 +327,14 @@ static struct cached_object_entry { } *cached_objects; static int cached_object_nr, cached_object_alloc; -static struct cached_object *find_cached_object(const struct object_id *oid) +static const struct cached_object *find_cached_object(const struct object_id *oid) { - static struct cached_object empty_tree = { + static const struct cached_object empty_tree = { .type = OBJ_TREE, .buf = "", }; int i; - struct cached_object_entry *co = cached_objects; + const struct cached_object_entry *co = cached_objects; for (i = 0; i < cached_object_nr; i++, co++) { if (oideq(&co->oid, oid)) @@ -1629,7 +1629,7 @@ static int do_oid_object_info_extended(struct repository *r, struct object_info *oi, unsigned flags) { static struct object_info blank_oi = OBJECT_INFO_INIT; - struct cached_object *co; + const struct cached_object *co; struct pack_entry e; int rtype; const struct object_id *real = oid; |