use stringstream instead og strstream (#398)

This commit is contained in:
tomosu 2016-06-09 12:45:20 +09:00 committed by Keisuke Ogaki
parent 52e40735cb
commit 5162807399

View file

@ -223,7 +223,7 @@ public:
ostream *m_os;
bool m_chanOwner;
bool m_compressed;
ostrstream m_ostrstream;
ostringstream m_ostringstream;
vector<std::string> m_tagStack;
int m_tab;
@ -244,7 +244,7 @@ TOStream::TOStream(const TFilePath &fp, bool compressed)
m_imp->m_filepath = fp;
if (compressed) {
m_imp->m_os = &m_imp->m_ostrstream;
m_imp->m_os = &m_imp->m_ostringstream;
m_imp->m_compressed = true;
m_imp->m_chanOwner = false;
} else {
@ -305,7 +305,9 @@ TOStream::~TOStream()
m_imp->m_justStarted = true;
} else {
if (m_imp->m_compressed) {
const void *in = (const void *)m_imp->m_ostrstream.str();
std::string tmp = m_imp->m_ostringstream.str();
const void *in = (const void *)tmp.c_str();
size_t in_len = strlen((char *)in);
size_t out_len = LZ4F_compressFrameBound(in_len, NULL);
@ -324,8 +326,6 @@ TOStream::~TOStream()
v = out_len;
os.write((char *)&v, sizeof v);
os.write((char *)out, out_len);
m_imp->m_ostrstream.freeze(0);
}
free(out);
@ -975,7 +975,7 @@ TIStream::TIStream(const TFilePath &fp)
if (check_len != out_len)
throw TException("corrupted file");
m_imp->m_is = new istrstream((char *)out, out_len);
m_imp->m_is = new istringstream((char *)out, out_len);
}
m_imp->m_chanOwner = true;
@ -1317,7 +1317,7 @@ bool TIStream::getTagParam(string paramName, int &value)
string svalue;
if (!getTagParam(paramName, svalue))
return false;
istrstream is(svalue.c_str(), svalue.length());
istringstream is(svalue.c_str(), svalue.length());
value = 0;
is >> value;
return true;