behdad/harfbuzz — pull request #30 by jensl (2014-03-13 08:27:02+00:00)
Title: Make hb_buffer_pre_allocate() allocate exactly requested size

Normally, hb_buffer_t::enlarge() quantizes allocations by calculating
a new allocation size as "current_allocation_size * 2 + 32". When
called on an empty buffer (with allocated=0) it will at least allocate
space for 32 characters.

If a caller knows exactly how many characters will ever be written
into the buffer, it is useful if they can use hb_buffer_pre_allocate()
to pre-allocate enough space while avoiding this quantization. Thus,
modify hb_buffer_pre_allocate()'s behavior to allocate space for the
requested size exactly. This is implemented using a new argument to
hb_buffer_t::enlarge(), 'exact', which disables the quantization.