m[blob] Move immutable check to C API boundary

Similarly to 08ed9e3f779253e3b5f01c38d44d0e5db2d5e7aa
This commit is contained in:
Behdad Esfahbod committed 2021-02-19 18:40:48 -07:00
1 parent 4020c6b286
commit 82928d9cf6
1 file changed
+3 -7
+3 -7
View File
@@ -365,15 +365,14 @@ hb_blob_get_data (hb_blob_t *blob, unsigned int *length)
char *
hb_blob_get_data_writable (hb_blob_t *blob, unsigned int *length)
{
if (!blob->try_make_writable ())
if (hb_object_is_immutable (blob) ||
!blob->try_make_writable ())
{
if (length) *length = 0;
return nullptr;
}
if (length)
*length = blob->length;
if (length) *length = blob->length;
return const_cast<char *> (blob->data);
}
@@ -439,9 +438,6 @@ hb_blob_t::try_make_writable_inplace ()
bool
hb_blob_t::try_make_writable ()
{
if (hb_object_is_immutable (this))
return false;
if (unlikely (!length))
mode = HB_MEMORY_MODE_WRITABLE;