Lines Matching defs:blob
29 #include "hb-blob.hh"
44 * SECTION: hb-blob
45 * @title: hb-blob
58 * @data: Pointer to blob data.
64 * Creates a new "blob" object wrapping @data. The @mode parameter is used
67 * Return value: New blob, or the empty blob if something failed or if @length is
79 hb_blob_t *blob;
83 !(blob = hb_object_create<hb_blob_t> ())) {
89 blob->data = data;
90 blob->length = length;
91 blob->mode = mode;
93 blob->user_data = user_data;
94 blob->destroy = destroy;
96 if (blob->mode == HB_MEMORY_MODE_DUPLICATE) {
97 blob->mode = HB_MEMORY_MODE_READONLY;
98 if (!blob->try_make_writable ()) {
99 hb_blob_destroy (blob);
104 return blob;
115 * @parent: Parent blob.
116 * @offset: Start offset of sub-blob within @parent, in bytes.
117 * @length: Length of sub-blob.
119 * Returns a blob that represents a range of bytes in @parent. The new
120 * blob is always created with %HB_MEMORY_MODE_READONLY, meaning that it
121 * will never modify data in the parent blob. The parent data is not
127 * Return value: New blob, or the empty blob if something failed or if
138 hb_blob_t *blob;
145 blob = hb_blob_create (parent->data + offset,
151 return blob;
156 * @blob: A blob.
158 * Makes a writable copy of @blob.
160 * Return value: New blob, or nullptr if allocation failed.
165 hb_blob_copy_writable_or_fail (hb_blob_t *blob)
167 blob = hb_blob_create (blob->data,
168 blob->length,
173 if (unlikely (blob == hb_blob_get_empty ()))
174 blob = nullptr;
176 return blob;
182 * Returns the singleton empty blob.
186 * Return value: (transfer full): the empty blob.
198 * @blob: a blob.
200 * Increases the reference count on @blob.
204 * Return value: @blob.
209 hb_blob_reference (hb_blob_t *blob)
211 return hb_object_reference (blob);
216 * @blob: a blob.
218 * Decreases the reference count on @blob, and if it reaches zero, destroys
219 * @blob, freeing all memory, possibly calling the destroy-callback the blob
227 hb_blob_destroy (hb_blob_t *blob)
229 if (!hb_object_destroy (blob)) return;
231 blob->fini_shallow ();
233 free (blob);
238 * @blob: a blob.
249 hb_blob_set_user_data (hb_blob_t *blob,
255 return hb_object_set_user_data (blob, key, data, destroy, replace);
260 * @blob: a blob.
270 hb_blob_get_user_data (hb_blob_t *blob,
273 return hb_object_get_user_data (blob, key);
279 * @blob: a blob.
286 hb_blob_make_immutable (hb_blob_t *blob)
288 if (hb_object_is_immutable (blob))
291 hb_object_make_immutable (blob);
296 * @blob: a blob.
305 hb_blob_is_immutable (hb_blob_t *blob)
307 return hb_object_is_immutable (blob);
313 * @blob: a blob.
317 * Return value: the length of blob data in bytes.
322 hb_blob_get_length (hb_blob_t *blob)
324 return blob->length;
329 * @blob: a blob.
339 hb_blob_get_data (hb_blob_t *blob, unsigned int *length)
342 *length = blob->length;
344 return blob->data;
349 * @blob: a blob.
352 * Tries to make blob data writable (possibly copying it) and
355 * Fails if blob has been made immutable, or if memory allocation
358 * Returns: (transfer none) (array length=length): Writable blob data,
364 hb_blob_get_data_writable (hb_blob_t *blob, unsigned int *length)
366 if (!blob->try_make_writable ()) {
374 *length = blob->length;
376 return const_cast<char *> (blob->data);
396 DEBUG_MSG_FUNC (BLOB, this, "failed to get pagesize: %s", strerror (errno));
399 DEBUG_MSG_FUNC (BLOB, this, "pagesize is %lu", (unsigned long) pagesize);
404 DEBUG_MSG_FUNC (BLOB, this,
408 DEBUG_MSG_FUNC (BLOB, this, "mprotect failed: %s", strerror (errno));
414 DEBUG_MSG_FUNC (BLOB, this,
426 DEBUG_MSG_FUNC (BLOB, this, "making writable inplace\n");
431 DEBUG_MSG_FUNC (BLOB, this, "making writable -> FAILED\n");
454 DEBUG_MSG_FUNC (BLOB, this, "current data is -> %p\n", this->data);
462 DEBUG_MSG_FUNC (BLOB, this, "dupped successfully -> %p\n", this->data);