mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-28 06:27:16 +00:00
Modified Deserializer::ReadCStr to allow C-strings to be read into a
std::vector<char> starting from any index in the vector. llvm-svn: 45129
This commit is contained in:
parent
b33d6155da
commit
28a75d4674
@ -156,7 +156,7 @@ public:
|
||||
}
|
||||
|
||||
char* ReadCStr(char* cstr = NULL, unsigned MaxLen=0, bool isNullTerm=true);
|
||||
void ReadCStr(std::vector<char>& buff, bool isNullTerm=false);
|
||||
void ReadCStr(std::vector<char>& buff, bool isNullTerm=false, unsigned Idx=0);
|
||||
|
||||
template <typename T>
|
||||
inline T* ReadOwnedPtr(bool AutoRegister = true) {
|
||||
|
@ -329,11 +329,18 @@ char* Deserializer::ReadCStr(char* cstr, unsigned MaxLen, bool isNullTerm) {
|
||||
return cstr;
|
||||
}
|
||||
|
||||
void Deserializer::ReadCStr(std::vector<char>& buff, bool isNullTerm) {
|
||||
void Deserializer::ReadCStr(std::vector<char>& buff, bool isNullTerm,
|
||||
unsigned Idx) {
|
||||
|
||||
unsigned len = ReadInt();
|
||||
|
||||
buff.clear();
|
||||
buff.reserve(len);
|
||||
// If Idx is beyond the current before size, reduce Idx to refer to the
|
||||
// element after the last element.
|
||||
if (Idx > buff.size())
|
||||
Idx = buff.size();
|
||||
|
||||
buff.reserve(len+Idx);
|
||||
buff.resize(Idx);
|
||||
|
||||
for (unsigned i = 0; i < len; ++i)
|
||||
buff.push_back((char) ReadInt());
|
||||
|
Loading…
Reference in New Issue
Block a user