summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
3618763)
Don't use dynamic stack allocation (variable length arrays).
Rename bamtools target to bamtools_cmd to not conflict with BamTools target (they differ only in case).
bamtools_cmd only compiles if I remove bamtools_filter.cpp, which I haven't committed.
I also had to manually configure the include directory for zlib,
but that's probably due to having multiple copies floating around my machine.
set (LIBRARY_OUTPUT_PATH "${CMAKE_SOURCE_DIR}/lib")
# define compiler flags for all code
set (LIBRARY_OUTPUT_PATH "${CMAKE_SOURCE_DIR}/lib")
# define compiler flags for all code
-add_definitions (-Wall -O2 -D_FILE_OFFSET_BITS=64)
+set (CMAKE_BUILD_TYPE Release)
+add_definitions (-Wall -D_FILE_OFFSET_BITS=64)
# add our includes root path
include_directories (src)
# add our includes root path
include_directories (src)
// otherwise, copy tag data to temp buffer
string newTag = tag + type + value;
const int newTagDataLength = tagDataLength + newTag.size() + 1; // leave room for null-term
// otherwise, copy tag data to temp buffer
string newTag = tag + type + value;
const int newTagDataLength = tagDataLength + newTag.size() + 1; // leave room for null-term
- char originalTagData[newTagDataLength];
+ char* originalTagData = new char[newTagDataLength];
memcpy(originalTagData, TagData.c_str(), tagDataLength + 1); // '+1' for TagData null-term
memcpy(originalTagData, TagData.c_str(), tagDataLength + 1); // '+1' for TagData null-term
// append newTag
strcat(originalTagData + tagDataLength, newTag.data()); // removes original null-term, appends newTag + null-term
// append newTag
strcat(originalTagData + tagDataLength, newTag.data()); // removes original null-term, appends newTag + null-term
// store temp buffer back in TagData
const char* newTagData = (const char*)originalTagData;
TagData.assign(newTagData, newTagDataLength);
// store temp buffer back in TagData
const char* newTagData = (const char*)originalTagData;
TagData.assign(newTagData, newTagDataLength);
+ delete[] originalTagData;
+
// return success
return true;
}
// return success
return true;
}
// copy original tag data to temp buffer
string newTag = tag + type;
const int newTagDataLength = tagDataLength + newTag.size() + 4; // leave room for new integer
// copy original tag data to temp buffer
string newTag = tag + type;
const int newTagDataLength = tagDataLength + newTag.size() + 4; // leave room for new integer
- char originalTagData[newTagDataLength];
+ char* originalTagData = new char[newTagDataLength];
memcpy(originalTagData, TagData.c_str(), tagDataLength + 1); // '+1' for TagData null-term
// append newTag
memcpy(originalTagData, TagData.c_str(), tagDataLength + 1); // '+1' for TagData null-term
// append newTag
// store temp buffer back in TagData
const char* newTagData = (const char*)originalTagData;
TagData.assign(newTagData, newTagDataLength);
// store temp buffer back in TagData
const char* newTagData = (const char*)originalTagData;
TagData.assign(newTagData, newTagDataLength);
+ delete[] originalTagData;
// return success
return true;
// return success
return true;
// copy original tag data to temp buffer
string newTag = tag + type;
const int newTagDataLength = tagDataLength + newTag.size() + 4; // leave room for new float
// copy original tag data to temp buffer
string newTag = tag + type;
const int newTagDataLength = tagDataLength + newTag.size() + 4; // leave room for new float
- char originalTagData[newTagDataLength];
+ char* originalTagData = new char[newTagDataLength];
memcpy(originalTagData, TagData.c_str(), tagDataLength + 1); // '+1' for TagData null-term
// append newTag
memcpy(originalTagData, TagData.c_str(), tagDataLength + 1); // '+1' for TagData null-term
// append newTag
const char* newTagData = (const char*)originalTagData;
TagData.assign(newTagData, newTagDataLength);
const char* newTagData = (const char*)originalTagData;
TagData.assign(newTagData, newTagDataLength);
+ delete[] originalTagData;
+
// return success
return true;
}
// return success
return true;
}
const int newTagDataLength = tagDataLength +
Constants::BAM_TAG_ARRAYBASE_SIZE +
numElements*sizeof(uint8_t);
const int newTagDataLength = tagDataLength +
Constants::BAM_TAG_ARRAYBASE_SIZE +
numElements*sizeof(uint8_t);
- char originalTagData[newTagDataLength];
+ char* originalTagData = new char[newTagDataLength];
memcpy(originalTagData, TagData.c_str(), tagDataLength+1); // '+1' for TagData's null-term
// write newTagBase (removes old null term)
memcpy(originalTagData, TagData.c_str(), tagDataLength+1); // '+1' for TagData's null-term
// write newTagBase (removes old null term)
const char* newTagData = (const char*)originalTagData;
TagData.assign(newTagData, newTagDataLength);
const char* newTagData = (const char*)originalTagData;
TagData.assign(newTagData, newTagDataLength);
+ delete[] originalTagData;
+
// return success
return true;
}
// return success
return true;
}
const int newTagDataLength = tagDataLength +
Constants::BAM_TAG_ARRAYBASE_SIZE +
numElements*sizeof(int8_t);
const int newTagDataLength = tagDataLength +
Constants::BAM_TAG_ARRAYBASE_SIZE +
numElements*sizeof(int8_t);
- char originalTagData[newTagDataLength];
+ char* originalTagData = new char[newTagDataLength];
memcpy(originalTagData, TagData.c_str(), tagDataLength+1); // '+1' for TagData's null-term
// write newTagBase (removes old null term)
memcpy(originalTagData, TagData.c_str(), tagDataLength+1); // '+1' for TagData's null-term
// write newTagBase (removes old null term)
const char* newTagData = (const char*)originalTagData;
TagData.assign(newTagData, newTagDataLength);
const char* newTagData = (const char*)originalTagData;
TagData.assign(newTagData, newTagDataLength);
+ delete[] originalTagData;
+
// return success
return true;
}
// return success
return true;
}
const int newTagDataLength = tagDataLength +
Constants::BAM_TAG_ARRAYBASE_SIZE +
numElements*sizeof(uint16_t);
const int newTagDataLength = tagDataLength +
Constants::BAM_TAG_ARRAYBASE_SIZE +
numElements*sizeof(uint16_t);
- char originalTagData[newTagDataLength];
+ char* originalTagData = new char[newTagDataLength];
memcpy(originalTagData, TagData.c_str(), tagDataLength+1); // '+1' for TagData's null-term
// write newTagBase (removes old null term)
memcpy(originalTagData, TagData.c_str(), tagDataLength+1); // '+1' for TagData's null-term
// write newTagBase (removes old null term)
const char* newTagData = (const char*)originalTagData;
TagData.assign(newTagData, newTagDataLength);
const char* newTagData = (const char*)originalTagData;
TagData.assign(newTagData, newTagDataLength);
+ delete[] originalTagData;
+
// return success
return true;
}
// return success
return true;
}
const int newTagDataLength = tagDataLength +
Constants::BAM_TAG_ARRAYBASE_SIZE +
numElements*sizeof(int16_t);
const int newTagDataLength = tagDataLength +
Constants::BAM_TAG_ARRAYBASE_SIZE +
numElements*sizeof(int16_t);
- char originalTagData[newTagDataLength];
+ char* originalTagData = new char[newTagDataLength];
memcpy(originalTagData, TagData.c_str(), tagDataLength+1); // '+1' for TagData's null-term
// write newTagBase (removes old null term)
memcpy(originalTagData, TagData.c_str(), tagDataLength+1); // '+1' for TagData's null-term
// write newTagBase (removes old null term)
const char* newTagData = (const char*)originalTagData;
TagData.assign(newTagData, newTagDataLength);
const char* newTagData = (const char*)originalTagData;
TagData.assign(newTagData, newTagDataLength);
+ delete[] originalTagData;
+
// return success
return true;
}
// return success
return true;
}
const int newTagDataLength = tagDataLength +
Constants::BAM_TAG_ARRAYBASE_SIZE +
numElements*sizeof(uint32_t);
const int newTagDataLength = tagDataLength +
Constants::BAM_TAG_ARRAYBASE_SIZE +
numElements*sizeof(uint32_t);
- char originalTagData[newTagDataLength];
+ char* originalTagData = new char[newTagDataLength];
memcpy(originalTagData, TagData.c_str(), tagDataLength+1); // '+1' for TagData's null-term
// write newTagBase (removes old null term)
memcpy(originalTagData, TagData.c_str(), tagDataLength+1); // '+1' for TagData's null-term
// write newTagBase (removes old null term)
const char* newTagData = (const char*)originalTagData;
TagData.assign(newTagData, newTagDataLength);
const char* newTagData = (const char*)originalTagData;
TagData.assign(newTagData, newTagDataLength);
+ delete[] originalTagData;
+
// return success
return true;
}
// return success
return true;
}
const int newTagDataLength = tagDataLength +
Constants::BAM_TAG_ARRAYBASE_SIZE +
numElements*sizeof(int32_t);
const int newTagDataLength = tagDataLength +
Constants::BAM_TAG_ARRAYBASE_SIZE +
numElements*sizeof(int32_t);
- char originalTagData[newTagDataLength];
+ char* originalTagData = new char[newTagDataLength];
memcpy(originalTagData, TagData.c_str(), tagDataLength+1); // '+1' for TagData's null-term
// write newTagBase (removes old null term)
memcpy(originalTagData, TagData.c_str(), tagDataLength+1); // '+1' for TagData's null-term
// write newTagBase (removes old null term)
const char* newTagData = (const char*)originalTagData;
TagData.assign(newTagData, newTagDataLength);
const char* newTagData = (const char*)originalTagData;
TagData.assign(newTagData, newTagDataLength);
+ delete[] originalTagData;
+
// return success
return true;
}
// return success
return true;
}
const int newTagDataLength = tagDataLength +
Constants::BAM_TAG_ARRAYBASE_SIZE +
numElements*sizeof(float);
const int newTagDataLength = tagDataLength +
Constants::BAM_TAG_ARRAYBASE_SIZE +
numElements*sizeof(float);
- char originalTagData[newTagDataLength];
+ char* originalTagData = new char[newTagDataLength];
memcpy(originalTagData, TagData.c_str(), tagDataLength+1); // '+1' for TagData's null-term
// write newTagBase (removes old null term)
memcpy(originalTagData, TagData.c_str(), tagDataLength+1); // '+1' for TagData's null-term
// write newTagBase (removes old null term)
const char* newTagData = (const char*)originalTagData;
TagData.assign(newTagData, newTagDataLength);
const char* newTagData = (const char*)originalTagData;
TagData.assign(newTagData, newTagDataLength);
+ delete[] originalTagData;
+
// return success
return true;
}
// return success
return true;
}
if ( FindTag(tag, pTagData, originalTagDataLength, numBytesParsed) ) {
// make sure array is more than big enough
if ( FindTag(tag, pTagData, originalTagDataLength, numBytesParsed) ) {
// make sure array is more than big enough
- char newTagData[originalTagDataLength + value.size()];
+ char* newTagData = new char[originalTagDataLength + value.size()];
// copy original tag data up til desired tag
const unsigned int beginningTagDataLength = numBytesParsed;
// copy original tag data up til desired tag
const unsigned int beginningTagDataLength = numBytesParsed;
// save new tag data
TagData.assign(newTagData, endTagOffset + endTagDataLength);
// save new tag data
TagData.assign(newTagData, endTagOffset + endTagDataLength);
+
+ delete[] newTagData;
+
if ( FindTag(tag, pTagData, originalTagDataLength, numBytesParsed) ) {
// make sure array is more than big enough
if ( FindTag(tag, pTagData, originalTagDataLength, numBytesParsed) ) {
// make sure array is more than big enough
- char newTagData[originalTagDataLength + sizeof(value)];
+ char* newTagData = new char[originalTagDataLength + sizeof(value)];
// copy original tag data up til desired tag
const unsigned int beginningTagDataLength = numBytesParsed;
// copy original tag data up til desired tag
const unsigned int beginningTagDataLength = numBytesParsed;
// save new tag data
TagData.assign(newTagData, endTagOffset + endTagDataLength);
// save new tag data
TagData.assign(newTagData, endTagOffset + endTagDataLength);
+
+ delete[] newTagData;
+
if ( FindTag(tag, pTagData, originalTagDataLength, numBytesParsed) ) {
// make sure array is more than big enough
if ( FindTag(tag, pTagData, originalTagDataLength, numBytesParsed) ) {
// make sure array is more than big enough
- char newTagData[originalTagDataLength + sizeof(value)];
+ char* newTagData = new char[originalTagDataLength + sizeof(value)];
// copy original tag data up til desired tag
const unsigned int beginningTagDataLength = numBytesParsed;
// copy original tag data up til desired tag
const unsigned int beginningTagDataLength = numBytesParsed;
// save new tag data
TagData.assign(newTagData, endTagOffset + endTagDataLength);
// save new tag data
TagData.assign(newTagData, endTagOffset + endTagDataLength);
+
+ delete[] newTagData;
+
// if tag found
if ( FindTag(tag, pTagData, originalTagDataLength, numBytesParsed) ) {
// if tag found
if ( FindTag(tag, pTagData, originalTagDataLength, numBytesParsed) ) {
- char newTagData[originalTagDataLength];
+ char* newTagData = new char[originalTagDataLength];
// copy original tag data up til desired tag
pTagData -= 3;
// copy original tag data up til desired tag
pTagData -= 3;
// save new tag data
TagData.assign(newTagData, beginningTagDataLength + endTagDataLength);
// save new tag data
TagData.assign(newTagData, beginningTagDataLength + endTagDataLength);
+
+ delete[] newTagData;
+
target_link_libraries( BamTools-static z )
# set library install destinations
target_link_libraries( BamTools-static z )
# set library install destinations
-install( TARGETS BamTools LIBRARY DESTINATION "lib/bamtools")
+install( TARGETS BamTools LIBRARY DESTINATION "lib/bamtools" RUNTIME DESTINATION "bin")
install( TARGETS BamTools-static ARCHIVE DESTINATION "lib/bamtools")
# export API headers
install( TARGETS BamTools-static ARCHIVE DESTINATION "lib/bamtools")
# export API headers
)
# compile main bamtools application
)
# compile main bamtools application
-add_executable ( bamtools
+add_executable ( bamtools_cmd
bamtools_convert.cpp
bamtools_count.cpp
bamtools_coverage.cpp
bamtools_convert.cpp
bamtools_count.cpp
bamtools_coverage.cpp
bamtools_merge.cpp
bamtools_random.cpp
bamtools_resolve.cpp
bamtools_merge.cpp
bamtools_random.cpp
bamtools_resolve.cpp
bamtools_sort.cpp
bamtools_split.cpp
bamtools_stats.cpp
bamtools_sort.cpp
bamtools_split.cpp
bamtools_stats.cpp
)
# set BamTools application properties
)
# set BamTools application properties
-set_target_properties( BamTools PROPERTIES
+set_target_properties( bamtools_cmd PROPERTIES
)
# make version info available in application
configure_file(bamtools_version.h.in ${BamTools_SOURCE_DIR}/src/toolkit/bamtools_version.h)
# define libraries to link
)
# make version info available in application
configure_file(bamtools_version.h.in ${BamTools_SOURCE_DIR}/src/toolkit/bamtools_version.h)
# define libraries to link
-target_link_libraries ( bamtools BamTools BamTools-utils jsoncpp )
+target_link_libraries ( bamtools_cmd BamTools BamTools-utils jsoncpp )
# set application install destinations
# set application install destinations
-install( TARGETS bamtools DESTINATION "bin")
+install( TARGETS bamtools_cmd DESTINATION "bin")
#include <vector>
using namespace std;
#include <vector>
using namespace std;
+#ifdef _MSC_VER
+ #define ftello _ftelli64
+ #define fseeko _fseeki64
+#endif
+
struct Fasta::FastaPrivate {
struct FastaIndexData {
struct Fasta::FastaPrivate {
struct FastaIndexData {
vector<string> fields;
char* tok;
vector<string> fields;
char* tok;
- char cchars [source.size()+1];
+ char* cchars = new char[source.size()+1];
char* cstr = &cchars[0];
strcpy(cstr, source.c_str());
tok = strtok(cstr, delims.c_str());
char* cstr = &cchars[0];
strcpy(cstr, source.c_str());
tok = strtok(cstr, delims.c_str());
tok = strtok(NULL, delims.c_str());
}
tok = strtok(NULL, delims.c_str());
}