reftable/record: improve semantics when initializing records
According to our usual coding style, the `reftable_new_record()` function would indicate that it is allocating a new record. This is not the case though as the function merely initializes records without allocating any memory. Replace `reftable_new_record()` with a new `reftable_record_init()` function that takes a record pointer as input and initializes it accordingly. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
62d3c8e8c8
commit
3ddef475d0
@ -69,9 +69,6 @@ struct reftable_record_vtable {
|
||||
/* returns true for recognized block types. Block start with the block type. */
|
||||
int reftable_is_block_type(uint8_t typ);
|
||||
|
||||
/* return an initialized record for the given type */
|
||||
struct reftable_record reftable_new_record(uint8_t typ);
|
||||
|
||||
/* Encode `key` into `dest`. Sets `is_restart` to indicate a restart. Returns
|
||||
* number of bytes written. */
|
||||
int reftable_encode_key(int *is_restart, struct string_view dest,
|
||||
@ -100,8 +97,8 @@ struct reftable_obj_record {
|
||||
/* record is a generic wrapper for different types of records. It is normally
|
||||
* created on the stack, or embedded within another struct. If the type is
|
||||
* known, a fresh instance can be initialized explicitly. Otherwise, use
|
||||
* reftable_new_record() to initialize generically (as the index_record is not
|
||||
* valid as 0-initialized structure)
|
||||
* `reftable_record_init()` to initialize generically (as the index_record is
|
||||
* not valid as 0-initialized structure)
|
||||
*/
|
||||
struct reftable_record {
|
||||
uint8_t type;
|
||||
@ -113,6 +110,9 @@ struct reftable_record {
|
||||
} u;
|
||||
};
|
||||
|
||||
/* Initialize the reftable record for the given type */
|
||||
void reftable_record_init(struct reftable_record *rec, uint8_t typ);
|
||||
|
||||
/* see struct record_vtable */
|
||||
int reftable_record_equal(struct reftable_record *a, struct reftable_record *b, int hash_size);
|
||||
void reftable_record_print(struct reftable_record *rec, int hash_size);
|
||||
|
Reference in New Issue
Block a user