GLib.ByteArray¶
Fields¶
| Name | Type | Access | Description | 
|---|---|---|---|
| data | int | r/w | a pointer to the element data. The data may be moved as elements are added to the GLib.ByteArray | 
| len | int | r/w | the number of elements in the GLib.ByteArray | 
Methods¶
| class | free(array, free_segment) | 
| class | free_to_bytes(array) | 
| class | new() | 
| class | new_take(data) | 
| class | steal(array) | 
| class | unref(array) | 
Details¶
- 
class GLib.ByteArray¶
- Contains the public fields of a - GLib.ByteArray.- 
classmethod free(array, free_segment)[source]¶
- Parameters: - array (bytes) – aGLib.ByteArray
- free_segment (bool) – ifTruethe actual byte data is freed as well
 - Returns: - the element data if free_segment is - False, otherwise- None. The element data should be freed using- GLib.free().- Return type: - Frees the memory allocated by the - GLib.ByteArray. If free_segment is- Trueit frees the actual byte data. If the reference count of array is greater than one, the- GLib.ByteArraywrapper is preserved but the size of array will be set to zero.
- array (
 - 
classmethod free_to_bytes(array)[source]¶
- Parameters: - array ( - bytes) – a- GLib.ByteArray- Returns: - a new immutable - GLib.Bytesrepresenting same byte data that was in the array- Return type: - GLib.Bytes- Transfers the data from the - GLib.ByteArrayinto a new immutable- GLib.Bytes.- The - GLib.ByteArrayis freed unless the reference count of array is greater than one, the- GLib.ByteArraywrapper is preserved but the size of array will be set to zero.- This is identical to using - GLib.Bytes.new_take() and- GLib.ByteArray.free() together.- New in version 2.32. 
 - 
classmethod new()[source]¶
- Returns: - the new - GLib.ByteArray- Return type: - bytes- Creates a new - GLib.ByteArraywith a reference count of 1.
 - 
classmethod new_take(data)[source]¶
- Parameters: - data ( - bytes) – byte data for the array- Returns: - a new - GLib.ByteArray- Return type: - bytes- Create byte array containing the data. The data will be owned by the array and will be freed with - GLib.free(), i.e. it could be allocated using- GLib.strdup().- New in version 2.32. 
 - 
classmethod steal(array)[source]¶
- Parameters: - array ( - bytes) – a- GLib.ByteArray.- Returns: - the element data, which should be freed using - GLib.free().- len: - pointer to retrieve the number of elements of the original array - Return type: - ( - int, len:- int)- Frees the data in the array and resets the size to zero, while the underlying array is preserved for use elsewhere and returned to the caller. - New in version 2.64. 
 - 
classmethod unref(array)[source]¶
- Parameters: - array ( - bytes) – A- GLib.ByteArray- Atomically decrements the reference count of array by one. If the reference count drops to 0, all memory allocated by the array is released. This function is thread-safe and may be called from any thread. - New in version 2.22. 
 
- 
classmethod