提交 a989f3ed 编写于 作者: B Behdad Esfahbod

Add hb_blob_copy_writable_or_fail()

New API:
- hb_blob_copy_writable_or_fail()
上级 9046e924
......@@ -9,6 +9,7 @@ HB_EXTERN
<FILE>hb-blob</FILE>
hb_blob_create
hb_blob_create_sub_blob
hb_blob_copy_writable_or_fail
hb_blob_destroy
hb_blob_get_data
hb_blob_get_data_writable
......
......@@ -170,6 +170,31 @@ hb_blob_create_sub_blob (hb_blob_t *parent,
return blob;
}
/**
* hb_blob_copy_writable_or_fail:
* @blob: A blob.
*
* Makes a writable copy of @blob.
*
* Return value: New blob, or nullptr if allocation failed.
*
* Since: 1.8.0
**/
hb_blob_t *
hb_blob_copy_writable_or_fail (hb_blob_t *blob)
{
blob = hb_blob_create (blob->data,
blob->length,
HB_MEMORY_MODE_DUPLICATE,
nullptr,
nullptr);
if (unlikely (blob == hb_blob_get_empty ()))
blob = nullptr;
return blob;
}
/**
* hb_blob_get_empty:
*
......
......@@ -82,6 +82,9 @@ hb_blob_create_sub_blob (hb_blob_t *parent,
unsigned int offset,
unsigned int length);
HB_EXTERN hb_blob_t *
hb_blob_copy_writable_or_fail (hb_blob_t *blob);
HB_EXTERN hb_blob_t *
hb_blob_get_empty (void);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册