Add HB_BUFFER_ASSERT_VAR
To be used in places we access buffer vars...
This commit is contained in:
parent
0ccf9b6473
commit
965c280de0
|
@ -129,6 +129,7 @@ struct hb_buffer_t {
|
|||
|
||||
HB_INTERNAL void allocate_var (unsigned int byte_i, unsigned int count, const char *owner);
|
||||
HB_INTERNAL void deallocate_var (unsigned int byte_i, unsigned int count, const char *owner);
|
||||
HB_INTERNAL void assert_var (unsigned int byte_i, unsigned int count, const char *owner);
|
||||
HB_INTERNAL void deallocate_var_all (void);
|
||||
|
||||
HB_INTERNAL void add (hb_codepoint_t codepoint,
|
||||
|
@ -198,6 +199,8 @@ struct hb_buffer_t {
|
|||
HB_BUFFER_XALLOCATE_VAR (b, allocate_var, var (), #var)
|
||||
#define HB_BUFFER_DEALLOCATE_VAR(b, var) \
|
||||
HB_BUFFER_XALLOCATE_VAR (b, deallocate_var, var (), #var)
|
||||
#define HB_BUFFER_ASSERT_VAR(b, var) \
|
||||
HB_BUFFER_XALLOCATE_VAR (b, assert_var, var (), #var)
|
||||
|
||||
|
||||
#endif /* HB_BUFFER_PRIVATE_HH */
|
||||
|
|
|
@ -523,6 +523,22 @@ void hb_buffer_t::deallocate_var (unsigned int byte_i, unsigned int count, const
|
|||
}
|
||||
}
|
||||
|
||||
void hb_buffer_t::assert_var (unsigned int byte_i, unsigned int count, const char *owner)
|
||||
{
|
||||
if (DEBUG (BUFFER))
|
||||
dump_var_allocation (this);
|
||||
|
||||
DEBUG_MSG (BUFFER, this,
|
||||
"Asserting var bytes %d..%d for %s",
|
||||
byte_i, byte_i + count - 1, owner);
|
||||
|
||||
assert (byte_i < 8 && byte_i + count <= 8);
|
||||
for (unsigned int i = byte_i; i < byte_i + count; i++) {
|
||||
assert (allocated_var_bytes[i]);
|
||||
assert (0 == strcmp (allocated_var_owner[i], owner));
|
||||
}
|
||||
}
|
||||
|
||||
void hb_buffer_t::deallocate_var_all (void)
|
||||
{
|
||||
memset (allocated_var_bytes, 0, sizeof (allocated_var_bytes));
|
||||
|
|
Loading…
Reference in New Issue