本文整理汇总了C++中DataBufferSP::reset方法的典型用法代码示例。如果您正苦于以下问题:C++ DataBufferSP::reset方法的具体用法?C++ DataBufferSP::reset怎么用?C++ DataBufferSP::reset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataBufferSP
的用法示例。
在下文中一共展示了DataBufferSP::reset方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetDescriptor
Error
File::Read (size_t &num_bytes, off_t &offset, bool null_terminate, DataBufferSP &data_buffer_sp)
{
Error error;
if (num_bytes > 0)
{
int fd = GetDescriptor();
if (fd != kInvalidDescriptor)
{
struct stat file_stats;
if (::fstat (fd, &file_stats) == 0)
{
if (file_stats.st_size > offset)
{
const size_t bytes_left = file_stats.st_size - offset;
if (num_bytes > bytes_left)
num_bytes = bytes_left;
size_t num_bytes_plus_nul_char = num_bytes + (null_terminate ? 1 : 0);
std::unique_ptr<DataBufferHeap> data_heap_ap;
data_heap_ap.reset(new DataBufferHeap());
data_heap_ap->SetByteSize(num_bytes_plus_nul_char);
if (data_heap_ap.get())
{
error = Read (data_heap_ap->GetBytes(), num_bytes, offset);
if (error.Success())
{
// Make sure we read exactly what we asked for and if we got
// less, adjust the array
if (num_bytes_plus_nul_char < data_heap_ap->GetByteSize())
data_heap_ap->SetByteSize(num_bytes_plus_nul_char);
data_buffer_sp.reset(data_heap_ap.release());
return error;
}
}
}
else
error.SetErrorString("file is empty");
}
else
error.SetErrorToErrno();
}
else
error.SetErrorString("invalid file handle");
}
else
error.SetErrorString("invalid file handle");
num_bytes = 0;
data_buffer_sp.reset();
return error;
}
示例2: ReadAllRegisterValues
bool RegisterContextPOSIXProcessMonitor_powerpc::ReadAllRegisterValues(
DataBufferSP &data_sp) {
bool success = false;
data_sp.reset(new DataBufferHeap(REG_CONTEXT_SIZE, 0));
if (data_sp && ReadGPR() && ReadFPR()) {
uint8_t *dst = data_sp->GetBytes();
success = dst != 0;
if (success) {
::memcpy(dst, &m_gpr_powerpc, GetGPRSize());
dst += GetGPRSize();
}
}
return success;
}