Browse Source

MT#55283 clarify _destroy_ptr

Change-Id: Ib453648d21e907bffd7120a9c9b50275f7bf0846
(cherry picked from commit 08239c9510)
(cherry picked from commit 48999b1fdf)
mr13.4.1
Richard Fuchs 4 months ago
parent
commit
d5275c5d98
2 changed files with 10 additions and 6 deletions
  1. +3
    -4
      daemon/media_socket.c
  2. +7
    -2
      lib/containers.h

+ 3
- 4
daemon/media_socket.c View File

@ -1522,7 +1522,7 @@ typedef struct {
} kernelize_state; } kernelize_state;
static void kernelize_state_clear(kernelize_state *s) { static void kernelize_state_clear(kernelize_state *s) {
rtp_stats_arr_destroy_ptr(s->payload_types);
rtp_stats_arr_destroy_ptr(&s->payload_types);
t_queue_clear_full(&s->outputs, t_queue_clear_full(&s->outputs,
(void (*)(struct rtpengine_destination_info *)) g_free); // should always be empty (void (*)(struct rtpengine_destination_info *)) g_free); // should always be empty
} }
@ -1885,8 +1885,7 @@ static void kernelize(struct packet_stream *stream) {
// record number of RTP destinations up to now // record number of RTP destinations up to now
unsigned int num_rtp_dests = s.reti.num_destinations; unsigned int num_rtp_dests = s.reti.num_destinations;
// ignore RTP payload types // ignore RTP payload types
rtp_stats_arr_destroy_ptr(s.payload_types);
s.payload_types = NULL;
rtp_stats_arr_destroy_ptr(&s.payload_types);
for (__auto_type l = stream->rtcp_sinks.head; l; l = l->next) { for (__auto_type l = stream->rtcp_sinks.head; l; l = l->next) {
struct sink_handler *sh = l->data; struct sink_handler *sh = l->data;
bool ok = kernelize_one_sink_handler(&s, stream, sh); bool ok = kernelize_one_sink_handler(&s, stream, sh);
@ -1925,7 +1924,7 @@ no_kernel:
restart: // handle detected deadlock restart: // handle detected deadlock
rtp_stats_arr_destroy_ptr(s.payload_types);
rtp_stats_arr_destroy_ptr(&s.payload_types);
while ((redi = t_queue_pop_head(&s.outputs))) while ((redi = t_queue_pop_head(&s.outputs)))
g_free(redi); g_free(redi);


+ 7
- 2
lib/containers.h View File

@ -444,11 +444,16 @@ static inline void g_queue_clear_full(GQueue *q, GDestroyNotify free_func) {
static inline type_name *type_name##_new(void) { \ static inline type_name *type_name##_new(void) { \
return type_name##_new_sized(0); \ return type_name##_new_sized(0); \
} \ } \
static inline void type_name##_destroy_ptr(type_name *A) { \
static inline void type_name##_destroy(type_name *A) { \
if (A) \ if (A) \
g_ptr_array_free(&(A)->a, TRUE); \ g_ptr_array_free(&(A)->a, TRUE); \
} \ } \
G_DEFINE_AUTOPTR_CLEANUP_FUNC(type_name, type_name##_destroy_ptr)
static inline void type_name##_destroy_ptr(type_name **A) { \
if (*A) \
g_ptr_array_free(&(*A)->a, TRUE); \
*A = NULL; \
} \
G_DEFINE_AUTOPTR_CLEANUP_FUNC(type_name, type_name##_destroy)
#define TYPED_GPTRARRAY(type_name, contained_type) \ #define TYPED_GPTRARRAY(type_name, contained_type) \
TYPED_GPTRARRAY_FULL(type_name, contained_type, NULL) TYPED_GPTRARRAY_FULL(type_name, contained_type, NULL)


Loading…
Cancel
Save