Class (GI Struct)

GLib-2.0GLibPtrArray

Contains the public fields of a GLib.PtrArray.

Index

Constructors

Properties

Methods

Constructors

Properties

len: number
pdata: any

Methods

  • Makes a full (deep) copy of a GLib.PtrArray.

    func, as a GLib.CopyFunc, takes two arguments, the data to be copied and a user_data pointer. On common processor architectures, it’s safe to pass NULL as user_data if the copy function takes only one argument. You may get compiler warnings from this though if compiling with GCC’s -Wcast-function-type warning.

    If func is NULL, then only the pointers (and not what they are pointing to) are copied to the new GLib.PtrArray.

    The copy of array will have the same GLib.DestroyNotify for its elements as array. The copy will also be NULL terminated if (and only if) the source array is.

    Parameters

    • array: any[]

      a pointer array to duplicate

    • func: CopyFunc | null

      a copy function used to copy every element in the array

    Returns any[]

  • Frees the memory allocated for the GLib.PtrArray. If free_segment is true it frees the memory block holding the elements as well. Pass false if you want to free the GLib.PtrArray wrapper but preserve the underlying array for use elsewhere. If the reference count of array is greater than one, the GLib.PtrArray wrapper is preserved but the size of array will be set to zero.

    If array contents point to dynamically-allocated memory, they should be freed separately if free_segment is true and no GLib.DestroyNotify function has been set for array.

    Note that if the array is NULL terminated and free_segment is false then this will always return an allocated NULL terminated buffer. If pdata is previously NULL, a new buffer will be allocated.

    This function is not thread-safe. If using a GLib.PtrArray from multiple threads, use only the atomic GLib.PtrArray.ref and GLib.PtrArray.unref functions.

    Parameters

    • array: any[]

      a pointer array

    • free_segment: boolean

      if true, the actual pointer array is freed as well

    Returns any[] | null

  • Atomically increments the reference count of array by one. This function is thread-safe and may be called from any thread.

    Parameters

    • array: any[]

      a pointer array

    Returns any[]

  • Atomically decrements the reference count of array by one. If the reference count drops to 0, the effect is the same as calling GLib.PtrArray.free with free_segment set to true. This function is thread-safe and may be called from any thread.

    Parameters

    • array: any[]

      a pointer array

    Returns void