reftable/record: constify some parts of the interface

We're about to convert reftable records to stop storing their object IDs as allocated hashes. Prepare for this refactoring by constifying some parts of the interface that will be impacted by this. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Patrick Steinhardt committed Jan 3, 2024 at 07:22 UTC 88f59d9e310799b2da9d6ea0bd98ab325f515c9e
2 files changed +6 -6
reftable/record.c
+4 -4
@@ -76,7 +76,7 @@ int reftable_is_block_type(uint8_t typ)
76 return 0;
77 }
78
79 -uint8_t *reftable_ref_record_val1(const struct reftable_ref_record *rec)
79 +const unsigned char *reftable_ref_record_val1(const struct reftable_ref_record *rec)
80 {
81 switch (rec->value_type) {
82 case REFTABLE_REF_VAL1:
@@ -88,7 +88,7 @@ uint8_t *reftable_ref_record_val1(const struct reftable_ref_record *rec)
88 }
89 }
90
91 -uint8_t *reftable_ref_record_val2(const struct reftable_ref_record *rec)
91 +const unsigned char *reftable_ref_record_val2(const struct reftable_ref_record *rec)
92 {
93 switch (rec->value_type) {
94 case REFTABLE_REF_VAL2:
@@ -242,7 +242,7 @@ static char hexdigit(int c)
242 return 'a' + (c - 10);
243 }
244
245 -static void hex_format(char *dest, uint8_t *src, int hash_size)
245 +static void hex_format(char *dest, const unsigned char *src, int hash_size)
246 {
247 assert(hash_size > 0);
248 if (src) {
@@ -1164,7 +1164,7 @@ int reftable_record_equal(struct reftable_record *a, struct reftable_record *b,
1164 reftable_record_data(a), reftable_record_data(b), hash_size);
1165 }
1166
1167 -static int hash_equal(uint8_t *a, uint8_t *b, int hash_size)
1167 +static int hash_equal(const unsigned char *a, const unsigned char *b, int hash_size)
1168 {
1169 if (a && b)
1170 return !memcmp(a, b, hash_size);
reftable/reftable-record.h
+2 -2
@@ -49,11 +49,11 @@ struct reftable_ref_record {
49
50 /* Returns the first hash, or NULL if `rec` is not of type
51 * REFTABLE_REF_VAL1 or REFTABLE_REF_VAL2. */
52 -uint8_t *reftable_ref_record_val1(const struct reftable_ref_record *rec);
52 +const unsigned char *reftable_ref_record_val1(const struct reftable_ref_record *rec);
53
54 /* Returns the second hash, or NULL if `rec` is not of type
55 * REFTABLE_REF_VAL2. */
56 -uint8_t *reftable_ref_record_val2(const struct reftable_ref_record *rec);
56 +const unsigned char *reftable_ref_record_val2(const struct reftable_ref_record *rec);
57
58 /* returns whether 'ref' represents a deletion */
59 int reftable_ref_record_is_deletion(const struct reftable_ref_record *ref);