Fix compilation with the Clang compiler.
Fix type mismatches between types in sizeof() in malloc/calloc/realloc calls. This generates a warning in the clang analyzer, designed to catch incorrectly sized memory allocations.

The allocation at bam_plcmd.c:208 is twice as big as it needs to be, and has been fixed.
Update for htslib API change: hts_open() has only two parameters

Use hts_set_fai_filename() where appropriate.
Some initial comments whilst I think how to fix this.
Split out syncing of mate flags
First draft of fixed fixmates program
Raise error if give @HD SO:coordinate to 'samtools fixmate'

The (minimal) documentation does tell you 'samtools fixmate' requires query name
sorted reads (in fact grouped by query name is enough), but doesn't actually raise
an error if given coordinate sorted reads (it just silently fails to fix them).

This change raises an explicit error is the @HD line contains SO:coordinate
Second draft of revised fixmates
Add code to disable proper pair check.
Clean up tabs vs spaces so we're consistant for the whole of bam_mate.c.
Polish by adding a little info to manual page, ensuring unmapped unpaired reads are treated the same as paired ones and adding details to how things work comment.
Fix assert > to >=.
Remove extra tid check
Set the PAIRED flag once we have a pair
Fix edge case where last read in BAM is unpaired.
Fix case where cur was updated when pre was meant.
Fix compiler warning about \!
Fix accidently inverted flag check for unmapped
Add a few tests for fixmate
Add GPL header template.
Add comment to bam_template_cigar to explain what it does.
Add brackets around bam_mating core unmapped check to avoid warning.
Fix edge case where pos = 1, caused by fact bam1_t is 0 based whilst sam text format is 1 based.
Correct flag check
Add version number to test