2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
7 #include "TeamMemory.h"
15 TeamMemory::~TeamMemory()
21 TeamMemory::ReadMemoryString(target_addr_t address
, size_t maxLength
,
24 char buffer
[B_PAGE_SIZE
];
27 while (maxLength
> 0) {
28 // read at max maxLength bytes, but don't read across page bounds
29 size_t toRead
= std::min(maxLength
,
30 B_PAGE_SIZE
- size_t(address
% B_PAGE_SIZE
));
31 ssize_t bytesRead
= ReadMemory(address
, buffer
, toRead
);
33 return _string
.Length() == 0 ? bytesRead
: B_OK
;
36 return _string
.Length() == 0 ? B_BAD_ADDRESS
: B_OK
;
38 // append the bytes read
39 size_t length
= strnlen(buffer
, bytesRead
);
40 _string
.Append(buffer
, length
);
42 // stop at end of string
43 if (length
< (size_t)bytesRead
)
47 maxLength
-= bytesRead
;