Skip to content

Commit

Permalink
BamWriter: use sizeof(uint32_t) increment to swap bytes for big endia…
Browse files Browse the repository at this point in the history
…n architectures.

Closes: #236
  • Loading branch information
vpa1977 authored and SoapZA committed Jul 12, 2024
1 parent 46ed2fc commit 1ce1d52
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/api/internal/bam/BamWriter_p.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ void BamWriterPrivate::WriteAlignment(const BamAlignment& al)
char* cigarData = new char[packedCigarLength]();
std::memcpy(cigarData, packedCigar.data(), packedCigarLength);
if (m_isBigEndian) {
for (size_t i = 0; i < packedCigarLength; ++i) {
for (size_t i = 0; i < packedCigarLength; i += sizeof(uint32_t)) {
BamTools::SwapEndian_32p(&cigarData[i]);
}
}
Expand Down Expand Up @@ -500,8 +500,7 @@ void BamWriterPrivate::WriteAlignment(const BamAlignment& al)
char* cigarData = new char[packedCigarLength]();
std::memcpy(cigarData, packedCigar.data(), packedCigarLength);
if (m_isBigEndian) {
for (size_t i = 0; i < packedCigarLength;
++i) { // FIXME: similarly, this should be "i += 4", not "++i"
for (size_t i = 0; i < packedCigarLength; i += sizeof(uint32_t)) {
BamTools::SwapEndian_32p(&cigarData[i]);
}
}
Expand Down

0 comments on commit 1ce1d52

Please sign in to comment.