Browse Source

MT#55283 add extra typed GPtrArray methods

Change-Id: If67ac73a5f7f7e767d8f8eb09a77ca552ab81148
pull/1910/head
Richard Fuchs 10 months ago
parent
commit
bebec5eee4
1 changed files with 15 additions and 1 deletions
  1. +15
    -1
      lib/containers.h

+ 15
- 1
lib/containers.h View File

@ -425,6 +425,7 @@ static inline void g_queue_clear_full(GQueue *q, GDestroyNotify free_func) {
contained_type **pdata; \
unsigned int len; \
}; \
const contained_type *__ct; \
} type_name; \
static_assert(sizeof(GPtrArray) == sizeof(type_name), "sizeof ptrarray type mismatch"); \
static_assert(G_STRUCT_OFFSET(GPtrArray, pdata) == G_STRUCT_OFFSET(type_name, pdata), \
@ -437,7 +438,11 @@ static inline void g_queue_clear_full(GQueue *q, GDestroyNotify free_func) {
} \
static inline type_name *type_name##_new(void) { \
return type_name##_new_sized(0); \
}
} \
static inline void type_name##_destroy_ptr(type_name *A) { \
g_ptr_array_free(&(A)->a, TRUE); \
} \
G_DEFINE_AUTOPTR_CLEANUP_FUNC(type_name, type_name##_destroy_ptr)
#define TYPED_GPTRARRAY(type_name, contained_type) \
TYPED_GPTRARRAY_FULL(type_name, contained_type, NULL)
@ -446,6 +451,11 @@ static inline void g_queue_clear_full(GQueue *q, GDestroyNotify free_func) {
g_ptr_array_set_size(&(A)->a, l); \
})
#define t_ptr_array_sort(A, f) ({ \
int (*__f)(__typeof__((A)->__ct), __typeof__((A)->__ct)) = f; \
g_ptr_array_sort(&(A)->a, (GCompareFunc) __f); \
})
#define t_ptr_array_free(A, fd) ({ \
g_ptr_array_free(&(A)->a, fd); \
})
@ -455,5 +465,9 @@ static inline void g_queue_clear_full(GQueue *q, GDestroyNotify free_func) {
g_ptr_array_add(&(A)->a, __e); \
})
#define t_ptr_array_remove_index(A, i) ({ \
g_ptr_array_remove_index(&(A)->a, i); \
})
#endif

Loading…
Cancel
Save