Skip to content

Commit

Permalink
Fix utility::vsprintf
Browse files Browse the repository at this point in the history
Fix operator>> (I'm a derp)
  • Loading branch information
Antidote committed Oct 17, 2015
1 parent 1b67cce commit 8124d21
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion include/Athena/IStreamReader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1217,7 +1217,7 @@ class IStreamReader : public IStream
template <typename T>
IStreamReader& operator>>(IStreamReader& lhs, T& rhs)
{
rhs = lhs.readVal<T>(rhs);
rhs = lhs.readVal<T>();
return lhs;
}
}
Expand Down
13 changes: 7 additions & 6 deletions include/Athena/MemoryReader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ namespace io
*/
class MemoryReader : public IStreamReader
{
protected:
MemoryReader() = default;
public:
virtual ~MemoryReader();

Expand Down Expand Up @@ -83,10 +85,10 @@ class MemoryReader : public IStreamReader
atUint64 readUBytesToBuf(void* buf, atUint64 len);

protected:
const atUint8* m_data;
atUint64 m_length;
atUint64 m_position;
bool m_owns;
const atUint8* m_data = nullptr;
atUint64 m_length = 0;
atUint64 m_position = 0;
bool m_owns = false;
};

class MemoryCopyReader : public MemoryReader
Expand All @@ -104,8 +106,7 @@ class MemoryCopyReader : public MemoryReader
* \param filename The file to create the stream from
*/
MemoryCopyReader(const std::string& filename)
: MemoryReader(NULL, 0),
m_filepath(filename)
: m_filepath(filename)
{loadData();}

void setData(const atUint8* data, atUint64 length);
Expand Down
4 changes: 2 additions & 2 deletions src/Athena/Utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,15 @@ std::string vsprintf(const char* fmt, va_list list)
int size = 512;
char* buffer = 0;
buffer = new char[size];
int nsize = ::vsnprintf(buffer, size, fmt, list);
int nsize = ::vsprintf(buffer, fmt, list);

while (size <= nsize)
{
//fail delete buffer and try again
delete[] buffer;
buffer = 0;
buffer = new char[nsize + 1]; //+1 for /0
nsize = ::vsnprintf(buffer, size, fmt, list);
nsize = ::vsprintf(buffer, fmt, list);
}

std::string ret(buffer);
Expand Down

0 comments on commit 8124d21

Please sign in to comment.