reftable: make reftable-record.h function signatures const correct
Signed-off-by: Han-Wen Nienhuys <hanwen@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Han-Wen Nienhuys committed
Jan 20, 2022 at 15:12 UTC
a94b94506b3318f6a04b4afb19f7f6779ce34f6e
2 files changed
+14
-14
reftable/record.c
+7
-7
@@ -72,7 +72,7 @@ int reftable_is_block_type(uint8_t typ)
72
return 0;
73
}
74
75
-uint8_t *reftable_ref_record_val1(struct reftable_ref_record *rec)
75
+uint8_t *reftable_ref_record_val1(const struct reftable_ref_record *rec)
76
{
77
switch (rec->value_type) {
78
case REFTABLE_REF_VAL1:
@@ -84,7 +84,7 @@ uint8_t *reftable_ref_record_val1(struct reftable_ref_record *rec)
84
}
85
}
86
87
-uint8_t *reftable_ref_record_val2(struct reftable_ref_record *rec)
87
+uint8_t *reftable_ref_record_val2(const struct reftable_ref_record *rec)
88
{
89
switch (rec->value_type) {
90
case REFTABLE_REF_VAL2:
@@ -251,7 +251,7 @@ static void hex_format(char *dest, uint8_t *src, int hash_size)
251
}
252
}
253
254
-void reftable_ref_record_print(struct reftable_ref_record *ref,
254
+void reftable_ref_record_print(const struct reftable_ref_record *ref,
255
uint32_t hash_id)
256
{
257
char hex[GIT_MAX_HEXSZ + 1] = { 0 }; /* BUG */
@@ -881,8 +881,8 @@ static int zero_hash_eq(uint8_t *a, uint8_t *b, int sz)
881
return !memcmp(a, b, sz);
882
}
883
884
-int reftable_log_record_equal(struct reftable_log_record *a,
885
- struct reftable_log_record *b, int hash_size)
884
+int reftable_log_record_equal(const struct reftable_log_record *a,
885
+ const struct reftable_log_record *b, int hash_size)
886
{
887
if (!(null_streq(a->refname, b->refname) &&
888
a->update_index == b->update_index &&
@@ -1150,8 +1150,8 @@ static int hash_equal(uint8_t *a, uint8_t *b, int hash_size)
1150
return a == b;
1151
}
1152
1153
-int reftable_ref_record_equal(struct reftable_ref_record *a,
1154
- struct reftable_ref_record *b, int hash_size)
1153
+int reftable_ref_record_equal(const struct reftable_ref_record *a,
1154
+ const struct reftable_ref_record *b, int hash_size)
1155
{
1156
assert(hash_size > 0);
1157
if (!null_streq(a->refname, b->refname))
reftable/reftable-record.h
+7
-7
@@ -49,25 +49,25 @@ 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(struct reftable_ref_record *rec);
52
+uint8_t *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(struct reftable_ref_record *rec);
56
+uint8_t *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);
60
61
/* prints a reftable_ref_record onto stdout. Useful for debugging. */
62
-void reftable_ref_record_print(struct reftable_ref_record *ref,
62
+void reftable_ref_record_print(const struct reftable_ref_record *ref,
63
uint32_t hash_id);
64
65
/* frees and nulls all pointer values inside `ref`. */
66
void reftable_ref_record_release(struct reftable_ref_record *ref);
67
68
/* returns whether two reftable_ref_records are the same. Useful for testing. */
69
-int reftable_ref_record_equal(struct reftable_ref_record *a,
70
- struct reftable_ref_record *b, int hash_size);
69
+int reftable_ref_record_equal(const struct reftable_ref_record *a,
70
+ const struct reftable_ref_record *b, int hash_size);
71
72
/* reftable_log_record holds a reflog entry */
73
struct reftable_log_record {
@@ -104,8 +104,8 @@ int reftable_log_record_is_deletion(const struct reftable_log_record *log);
104
void reftable_log_record_release(struct reftable_log_record *log);
105
106
/* returns whether two records are equal. Useful for testing. */
107
-int reftable_log_record_equal(struct reftable_log_record *a,
108
- struct reftable_log_record *b, int hash_size);
107
+int reftable_log_record_equal(const struct reftable_log_record *a,
108
+ const struct reftable_log_record *b, int hash_size);
109
110
/* dumps a reftable_log_record on stdout, for debugging/testing. */
111
void reftable_log_record_print(struct reftable_log_record *log,