[fidl][cpp] Use std:: types for non-nullable strings and vectors.
See: https://fuchsia-review.googlesource.com/c/garnet/+/236996
Test: built everything, CQ, booted and poked around
Change-Id: Ie2a50b80aefd5ab6ec4c62d14653badb90e0bb4f
diff --git a/util/env_fuchsia.cc b/util/env_fuchsia.cc
index 7f6689b..bcaedf1 100644
--- a/util/env_fuchsia.cc
+++ b/util/env_fuchsia.cc
@@ -461,7 +461,7 @@
while (bytes_read < n) {
size_t step = std::min(n - bytes_read, fuchsia::io::MAX_BUF);
zx_status_t read_status;
- fidl::VectorPtr<uint8_t> read_data;
+ std::vector<uint8_t> read_data;
zx_status_t fidl_status =
file_->ReadAt(step, offset + bytes_read, &read_status, &read_data);
if (fidl_status != ZX_OK) {
@@ -470,15 +470,15 @@
if (read_status != ZX_OK) {
return FuchsiaZxError(filename_, read_status);
}
- if (read_data->size() > step) {
+ if (read_data.size() > step) {
return Status::IOError(filename_, "Received more bytes than read");
}
- if (read_data->size() == 0) {
+ if (read_data.size() == 0) {
break;
}
- memcpy(scratch + bytes_read, reinterpret_cast<char*>(read_data->data()),
- read_data->size());
- bytes_read += read_data->size();
+ memcpy(scratch + bytes_read, reinterpret_cast<char*>(read_data.data()),
+ read_data.size());
+ bytes_read += read_data.size();
}
*result = Slice(scratch, bytes_read);
return Status::OK();
@@ -831,25 +831,25 @@
if (!s.ok()) {
return s;
}
- fidl::VectorPtr<uint8_t> buf;
+ std::vector<uint8_t> buf;
zx_status_t fidl_status;
zx_status_t read_status;
vdirent_t entry;
while ((fidl_status = d->ReadDirents(fuchsia::io::MAX_BUF, &read_status,
&buf)) == ZX_OK &&
- read_status == ZX_OK && buf->size() > 0) {
+ read_status == ZX_OK && buf.size() > 0) {
size_t offset = 0;
- while (offset + sizeof(vdirent_t) <= buf->size()) {
- memcpy(&entry, buf->data() + offset, sizeof(vdirent_t));
- if (sizeof(vdirent_t) + entry.size > buf->size() - offset) {
+ while (offset + sizeof(vdirent_t) <= buf.size()) {
+ memcpy(&entry, buf.data() + offset, sizeof(vdirent_t));
+ if (sizeof(vdirent_t) + entry.size > buf.size() - offset) {
break;
}
result->push_back(
- std::string((char*)buf->data() + offset + sizeof(vdirent_t),
+ std::string((char*)buf.data() + offset + sizeof(vdirent_t),
(size_t)entry.size));
offset += sizeof(vdirent_t) + entry.size;
}
- if (offset != buf->size()) {
+ if (offset != buf.size()) {
return Status::IOError(dir, "Malformed dirent");
}
}