本文整理汇总了C++中block::reset方法的典型用法代码示例。如果您正苦于以下问题:C++ block::reset方法的具体用法?C++ block::reset怎么用?C++ block::reset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类block
的用法示例。
在下文中一共展示了block::reset方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: deallocate
/**
* Frees the given block and resets it.
* \param b Block to be freed.
*/
void deallocate(block &b)
{
if (b) {
::free(b.ptr);
b.reset();
}
}
示例2: deallocate
/**
* Frees the given block back to the system. The block gets nulled.
* \param b The block, describing what memory shall be freed.
*/
void deallocate(block &b) noexcept
{
if (b) {
#ifdef _MSC_VER
_aligned_free(b.ptr);
#else
::free(b.ptr);
#endif
b.reset();
}
}
示例3: deallocate
/**
* The given block gets deallocated. If Prefix or Sufix are defined then
* their d'tor(s) are called.
* \param b The Block that should be freed.
*/
void deallocate(block &b) noexcept
{
if (!b) {
return;
}
if (prefix_size > 0) {
outerToPrefix(b)->~Prefix();
}
if (sufix_size > 0) {
outerToSufix(b)->~Sufix();
}
auto innerBlock(toInnerBlock(b));
_allocator.deallocate(innerBlock);
b.reset();
}
示例4: deallocate
/**
* The given block gets deallocated. If Prefix or Sufix are defined then
* their d'tor(s) are called.
* \param b The Block that should be freed.
*/
void deallocate(block &b) noexcept
{
if (!b) {
return;
}
if (prefix_size > 0) {
outer_to_prefix(b)->~Prefix();
}
if (sufix_size > 0) {
outer_to_sufix(b)->~Sufix();
}
auto innerBlock(to_inner_block(b));
allocator_.deallocate(innerBlock);
b.reset();
}
示例5: deallocate
void deallocate(block &b) noexcept
{
if (!b) {
return;
}
if (!owns(b)) {
assert(false);
return;
}
// If it was the most recent allocated MemoryBlock, then we can re-use the
// memory. Otherwise this freed MemoryBlock is not available for further
// allocations. Since all happens on the stack this is not a leak!
if (isLastUsedBlock(b)) {
_p = static_cast<char *>(b.ptr);
}
b.reset();
}