Git fork

reftable/writer: fix type used for number of records

Both `reftable_writer_add_refs()` and `reftable_writer_add_logs()`
accept an array of records that should be added to the new table.
Callers of this function are expected to also pass the number of such
records to the function to tell it how many such records it is supposed
to write.

But while all callers pass in a `size_t`, which is a sensible choice,
the function in fact accepts an `int` as argument, which is less so. Fix
this.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

authored by

Patrick Steinhardt and committed by
Junio C Hamano
9077923c e813a020

+11 -10
+2 -2
reftable/reftable-writer.h
··· 156 the records before adding them, reordering the records array passed in. 157 */ 158 int reftable_writer_add_refs(struct reftable_writer *w, 159 - struct reftable_ref_record *refs, int n); 160 161 /* 162 adds reftable_log_records. Log records are keyed by (refname, decreasing ··· 171 the records before adding them, reordering records array passed in. 172 */ 173 int reftable_writer_add_logs(struct reftable_writer *w, 174 - struct reftable_log_record *logs, int n); 175 176 /* reftable_writer_close finalizes the reftable. The writer is retained so 177 * statistics can be inspected. */
··· 156 the records before adding them, reordering the records array passed in. 157 */ 158 int reftable_writer_add_refs(struct reftable_writer *w, 159 + struct reftable_ref_record *refs, size_t n); 160 161 /* 162 adds reftable_log_records. Log records are keyed by (refname, decreasing ··· 171 the records before adding them, reordering records array passed in. 172 */ 173 int reftable_writer_add_logs(struct reftable_writer *w, 174 + struct reftable_log_record *logs, size_t n); 175 176 /* reftable_writer_close finalizes the reftable. The writer is retained so 177 * statistics can be inspected. */
+9 -8
reftable/writer.c
··· 395 } 396 397 int reftable_writer_add_refs(struct reftable_writer *w, 398 - struct reftable_ref_record *refs, int n) 399 { 400 int err = 0; 401 - int i = 0; 402 QSORT(refs, n, reftable_ref_record_compare_name); 403 - for (i = 0; err == 0 && i < n; i++) { 404 err = reftable_writer_add_ref(w, &refs[i]); 405 - } 406 return err; 407 } 408 ··· 486 } 487 488 int reftable_writer_add_logs(struct reftable_writer *w, 489 - struct reftable_log_record *logs, int n) 490 { 491 int err = 0; 492 - int i = 0; 493 QSORT(logs, n, reftable_log_record_compare_key); 494 495 - for (i = 0; err == 0 && i < n; i++) { 496 err = reftable_writer_add_log(w, &logs[i]); 497 - } 498 return err; 499 } 500
··· 395 } 396 397 int reftable_writer_add_refs(struct reftable_writer *w, 398 + struct reftable_ref_record *refs, size_t n) 399 { 400 int err = 0; 401 + 402 QSORT(refs, n, reftable_ref_record_compare_name); 403 + 404 + for (size_t i = 0; err == 0 && i < n; i++) 405 err = reftable_writer_add_ref(w, &refs[i]); 406 + 407 return err; 408 } 409 ··· 487 } 488 489 int reftable_writer_add_logs(struct reftable_writer *w, 490 + struct reftable_log_record *logs, size_t n) 491 { 492 int err = 0; 493 + 494 QSORT(logs, n, reftable_log_record_compare_key); 495 496 + for (size_t i = 0; err == 0 && i < n; i++) 497 err = reftable_writer_add_log(w, &logs[i]); 498 + 499 return err; 500 } 501