Skip to content

Commit 0f0f0ed

Browse files
pks-tgitster
authored andcommitted
reftable/writer: drop Git-specific QSORT() macro
The reftable writer accidentally uses the Git-specific `QSORT()` macro. This macro removes the need for the caller to provide the element size, but other than that it's mostly equivalent to `qsort()`. Replace the macro accordingly to make the library usable outside of Git. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent da1b402 commit 0f0f0ed

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

reftable/writer.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,8 @@ int reftable_writer_add_refs(struct reftable_writer *w,
399399
{
400400
int err = 0;
401401

402-
QSORT(refs, n, reftable_ref_record_compare_name);
402+
if (n)
403+
qsort(refs, n, sizeof(*refs), reftable_ref_record_compare_name);
403404

404405
for (size_t i = 0; err == 0 && i < n; i++)
405406
err = reftable_writer_add_ref(w, &refs[i]);
@@ -491,7 +492,8 @@ int reftable_writer_add_logs(struct reftable_writer *w,
491492
{
492493
int err = 0;
493494

494-
QSORT(logs, n, reftable_log_record_compare_key);
495+
if (n)
496+
qsort(logs, n, sizeof(*logs), reftable_log_record_compare_key);
495497

496498
for (size_t i = 0; err == 0 && i < n; i++)
497499
err = reftable_writer_add_log(w, &logs[i]);

0 commit comments

Comments
 (0)