Skip to content

Commit

Permalink
Rename KSORT template to avoid collision with minimap2/map.c's
Browse files Browse the repository at this point in the history
The name given to KSORT_INIT determines the names of the functions
generated to implement the heap. Distinct heaps in different translation
units need different names in order for the translation units to be
able to be (static-)linked together.
  • Loading branch information
jmarshall authored and armintoepfer committed Feb 12, 2019
1 parent f36ff06 commit 5c82c99
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions third-party/bam_sort.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ static inline int heap_lt(const heap1_t a, const heap1_t b)
return a.idx > b.idx;
}

KSORT_INIT(heap, heap1_t, heap_lt)
KSORT_INIT(bam_sort_heap, heap1_t, heap_lt)

typedef struct merged_header
{
Expand Down Expand Up @@ -1448,7 +1448,7 @@ int bam_merge_core2(int by_qname, char *sort_tag, const char *out, const char *m
if (!(flag & MERGE_UNCOMP)) hts_set_threads(fpout, n_threads);

// Begin the actual merge
ks_heapmake(heap, n, heap);
ks_heapmake(bam_sort_heap, n, heap);
while (heap->pos != HEAP_EMPTY) {
bam1_t *b = heap->entry.bam_record;
if (flag & MERGE_RG) {
Expand Down Expand Up @@ -1481,7 +1481,7 @@ int bam_merge_core2(int by_qname, char *sort_tag, const char *out, const char *m
print_error(cmd, "\"%s\" is truncated", fn[heap->i]);
goto fail;
}
ks_heapadjust(heap, 0, n, heap);
ks_heapadjust(bam_sort_heap, 0, n, heap);
}

// Clean up and close
Expand Down Expand Up @@ -1677,7 +1677,7 @@ static int bam_merge_simple(int by_qname, char *sort_tag, const char *out, const
}

// Now do the merge
ks_heapmake(heap, heap_size, heap);
ks_heapmake(bam_sort_heap, heap_size, heap);
while (heap->pos != HEAP_EMPTY) {
bam1_t *b = heap->entry.bam_record;
if (sam_write1(fpout, hout, b) < 0) {
Expand All @@ -1690,7 +1690,7 @@ static int bam_merge_simple(int by_qname, char *sort_tag, const char *out, const
print_error(cmd, "Error reading \"%s\" : %s", fn[heap->i], strerror(errno));
goto fail;
}
ks_heapadjust(heap, 0, heap_size, heap);
ks_heapadjust(bam_sort_heap, 0, heap_size, heap);
}
// Clean up and close
for (i = 0; i < n; i++) {
Expand Down

0 comments on commit 5c82c99

Please sign in to comment.