mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-19 08:35:45 +00:00
Modified Deserializer::ReadCStr to allow C-strings to be read into a
std::vector<char> starting from any index in the vector. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45129 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user