本文整理汇总了C++中memory_cptr::is_free方法的典型用法代码示例。如果您正苦于以下问题:C++ memory_cptr::is_free方法的具体用法?C++ memory_cptr::is_free怎么用?C++ memory_cptr::is_free使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类memory_cptr
的用法示例。
在下文中一共展示了memory_cptr::is_free方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: compression_x
void
header_removal_compressor_c::compress(memory_cptr &buffer) {
if (!m_bytes.is_set() || (0 == m_bytes->get_size()))
return;
size_t size = m_bytes->get_size();
if (buffer->get_size() < size)
throw mtx::compression_x(boost::format(Y("Header removal compression not possible because the buffer contained %1% bytes "
"which is less than the size of the headers that should be removed, %2%.")) % buffer->get_size() % size);
unsigned char *buffer_ptr = buffer->get_buffer();
unsigned char *bytes_ptr = m_bytes->get_buffer();
if (memcmp(buffer_ptr, bytes_ptr, size)) {
std::string b_buffer, b_bytes;
size_t i;
for (i = 0; size > i; ++i) {
b_buffer += (boost::format(" %|1$02x|") % static_cast<unsigned int>(buffer_ptr[i])).str();
b_bytes += (boost::format(" %|1$02x|") % static_cast<unsigned int>(bytes_ptr[i])).str();
}
throw mtx::compression_x(boost::format(Y("Header removal compression not possible because the buffer did not start with the bytes that should be removed. "
"Wanted bytes:%1%; found:%2%.")) % b_bytes % b_buffer);
}
size_t new_size = buffer->get_size() - size;
if (buffer->is_free()) {
memmove(buffer_ptr, buffer_ptr + size, new_size);
buffer->set_size(new_size);
} else
buffer = clone_memory(buffer_ptr + size, new_size);
}