ULONGEST offset = 0;
/* The buffer holding the cache contents. */
- gdb_byte *buf = nullptr;
- /* The buffer's size. We try to read as much as fits into a packet
- at a time. */
- size_t bufsize = 0;
+ gdb::byte_vector buf;
/* Cache hit and miss counters. */
ULONGEST hit_count = 0;
{
if (this->fd == fd
&& this->offset <= offset
- && offset < this->offset + this->bufsize)
+ && offset < this->offset + this->buf.size ())
{
- ULONGEST max = this->offset + this->bufsize;
+ ULONGEST max = this->offset + this->buf.size ();
if (offset + len > max)
len = max - offset;
- memcpy (read_buf, this->buf + offset - this->offset, len);
+ memcpy (read_buf, &this->buf[offset - this->offset], len);
return len;
}
cache->fd = fd;
cache->offset = offset;
- cache->bufsize = get_remote_packet_size ();
- cache->buf = (gdb_byte *) xrealloc (cache->buf, cache->bufsize);
+ cache->buf.resize (get_remote_packet_size ());
- ret = remote_hostio_pread_vFile (cache->fd, cache->buf, cache->bufsize,
+ ret = remote_hostio_pread_vFile (cache->fd, &cache->buf[0],
+ cache->buf.size (),
cache->offset, remote_errno);
if (ret <= 0)
{
return ret;
}
- cache->bufsize = ret;
+ cache->buf.resize (ret);
return cache->pread (fd, read_buf, len, offset);
}