• Thomas Haller's avatar
    array: add support for %NULL termination in GPtrArray · ee247c0a
    Thomas Haller authored and Philip Withnall's avatar Philip Withnall committed
    GArray supports a "zero_terminated" flag, but GPtrArray doesn't.
    This is odd, because especially for a pointer array it makes sense
    to have a %NULL sentinel. This would be for example useful to track
    or construct a strv array with a GPtrArray.
    
    As workaround for this missing feature you could use a GArray instead
    (ugly) or to explicitly add the %NULL element. However the latter increases
    the "len" of the array, which can be problematic if you want to still use
    the GPtrArray for other purposes.
    
    Add API for marking a GPtrArray as %NULL terminated. In that case, the
    API will ensure that there is always a valid %NULL sentinel after the
    array. Note that the API does not enforce that a %NULL terminated API
    actually has any data allocated. That means, even with a %NULL terminated
    array, pdata can still be %NULL (only if len is zero).
    
    Add g_ptr_array_new_null_terminated() constructor. The null-terminated flag
    cannot be cleared. Once the GPtrArray is flagged ...
    ee247c0a