mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-07-12 21:44:44 +03:00
bytecode_ptr: add shrink() member function
This commit is contained in:
parent
82b889f4a2
commit
d4146059db
@ -337,6 +337,7 @@ bytecode_ptr<FDRConfirm> getFDRConfirm(const vector<hwlmLiteral> &lits,
|
|||||||
size_t actual_size = ROUNDUP_N((size_t)(ptr - fdrc_base),
|
size_t actual_size = ROUNDUP_N((size_t)(ptr - fdrc_base),
|
||||||
alignof(FDRConfirm));
|
alignof(FDRConfirm));
|
||||||
assert(actual_size <= size);
|
assert(actual_size <= size);
|
||||||
|
fdrc.shrink(actual_size);
|
||||||
|
|
||||||
return fdrc;
|
return fdrc;
|
||||||
}
|
}
|
||||||
|
@ -101,6 +101,19 @@ public:
|
|||||||
swap(alignment, other.alignment);
|
swap(alignment, other.alignment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Reduces the apparent size of the memory region. Note that this
|
||||||
|
* does not reallocate and copy, it just changes the value returned by
|
||||||
|
* size().
|
||||||
|
*/
|
||||||
|
void shrink(size_t size) {
|
||||||
|
if (size > bytes) {
|
||||||
|
assert(0);
|
||||||
|
throw std::logic_error("Must shrink to a smaller value");
|
||||||
|
}
|
||||||
|
bytes = size;
|
||||||
|
}
|
||||||
|
|
||||||
/** \brief Returns size of the memory region in bytes. */
|
/** \brief Returns size of the memory region in bytes. */
|
||||||
size_t size() const { return bytes; }
|
size_t size() const { return bytes; }
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user