Update ObjFileParser.cpp
parent
e30823fb1d
commit
d3506c24e7
|
@ -458,11 +458,14 @@ void ObjFileParser::getFace(aiPrimitiveType type) {
|
||||||
//OBJ USES 1 Base ARRAYS!!!!
|
//OBJ USES 1 Base ARRAYS!!!!
|
||||||
int iVal;
|
int iVal;
|
||||||
auto end = m_DataIt;
|
auto end = m_DataIt;
|
||||||
|
// find either the buffer end or the '\0'
|
||||||
while (end < m_DataItEnd && *end != '\0')
|
while (end < m_DataItEnd && *end != '\0')
|
||||||
++end;
|
++end;
|
||||||
|
// avoid temporary string allocation if there is a zero
|
||||||
if (end != m_DataItEnd) {
|
if (end != m_DataItEnd) {
|
||||||
iVal = ::atoi(&(*m_DataIt));
|
iVal = ::atoi(&(*m_DataIt));
|
||||||
} else {
|
} else {
|
||||||
|
// otherwise make a zero terminated copy, which is safe to pass to atoi
|
||||||
std::string number(&(*m_DataIt), m_DataItEnd - m_DataIt);
|
std::string number(&(*m_DataIt), m_DataItEnd - m_DataIt);
|
||||||
iVal = ::atoi(number.c_str());
|
iVal = ::atoi(number.c_str());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue