Extend ValueLoader::LoadStringValue() to accept a max length

parameter. When a CStringValue is representing an array, use
the array's length to limit how many bytes we read.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39795 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Rene Gollent
2010-12-09 23:45:13 +00:00
parent 72a249a942
commit 2f9d5a5aa6
3 changed files with 10 additions and 6 deletions
+3 -3
View File
@@ -188,10 +188,10 @@ ValueLoader::LoadValue(ValueLocation* location, type_code valueType,
status_t
ValueLoader::LoadStringValue(BVariant& location, BString& _value)
ValueLoader::LoadStringValue(BVariant& location, size_t maxSize, BString& _value)
{
static const size_t kMaxStringSize = 255;
return fTeamMemory->ReadMemoryString(location.ToUInt64(), kMaxStringSize,
_value);
return fTeamMemory->ReadMemoryString(location.ToUInt64(),
maxSize > kMaxStringSize ? kMaxStringSize : maxSize, _value);
}
+1 -1
View File
@@ -32,7 +32,7 @@ public:
BVariant& _value);
status_t LoadStringValue(BVariant& location,
BString& _value);
size_t maxSize, BString& _value);
private:
Architecture* fArchitecture;
@@ -69,16 +69,20 @@ CStringValueNode::ResolvedLocationAndValue(ValueLoader* valueLoader,
BVariant addressData;
BString valueData;
status_t error = B_OK;
size_t maxSize = 255;
if (dynamic_cast<AddressType*>(fType) != NULL) {
error = valueLoader->LoadValue(location, valueType, false,
addressData);
} else
} else {
addressData.SetTo(location->PieceAt(0).address);
maxSize = dynamic_cast<ArrayType*>(fType)
->DimensionAt(0)->CountElements();
}
if (error != B_OK)
return error;
error = valueLoader->LoadStringValue(addressData, valueData);
error = valueLoader->LoadStringValue(addressData, maxSize, valueData);
if (error != B_OK)
return error;