Buffer.with_owner
Description:
[ CCode ( has_construct_function = false ) ]
public Buffer.with_owner (uint8[] data, void* owner, DestroyNotify? owner_dnotify)
public Buffer.with_owner (uint8[] data, void* owner, DestroyNotify? owner_dnotify)
Creates a new Buffer containing data.length bytes from data
.
When the Buffer is freed, it will call owner_dnotify, passing
owner to it. You must ensure that data will remain valid until owner_dnotify is called.
For example, you could use this to create a buffer containing data returned from libxml without needing to do an extra copy:
xmlDocDumpMemory (doc, &xmlbody, &len);
return soup_buffer_new_with_owner (xmlbody, len, xmlbody,
(GDestroyNotify)xmlFree);
In this example, data and owner are the same, but in other cases they would be different (eg, owner
would be a object, and data would be a pointer to one of the object's fields).
Parameters:
| data |
data |
| owner |
pointer to an object that owns |
| owner_dnotify |
a function to free/unref |
| length |
length of |
Returns:
|
the new Buffer. |