diff --git a/daemon/control_ng.c b/daemon/control_ng.c index d09d54526..03195172f 100644 --- a/daemon/control_ng.c +++ b/daemon/control_ng.c @@ -143,7 +143,7 @@ int control_ng_process(str *buf, const endpoint_t *sin, char *addr, const sockad void (*cb)(str *, str *, const endpoint_t *, const sockaddr_t *, void *), void *p1, struct obj *ref) { - AUTO_CLEANUP(ng_buffer *ngbuf, ng_buffer_auto_release) = NULL; + g_autoptr(ng_buffer) ngbuf = NULL; bencode_item_t *dict, *resp; str cmd = STR_NULL, cookie, data, reply, *to_send, callid; const char *errstr, *resultstr; diff --git a/daemon/janus.c b/daemon/janus.c index dbb770659..cec5e2d8e 100644 --- a/daemon/janus.c +++ b/daemon/janus.c @@ -1631,7 +1631,7 @@ static const char *janus_trickle(JsonReader *reader, struct janus_session *sessi // top-level structures first, with auto cleanup AUTO_CLEANUP(GQueue streams, sdp_streams_free) = G_QUEUE_INIT; - AUTO_CLEANUP(ng_buffer *ngbuf, ng_buffer_auto_release) = ng_buffer_new(NULL); + g_autoptr(ng_buffer) ngbuf = ng_buffer_new(NULL); g_auto(sdp_ng_flags) flags; call_ng_flags_init(&flags, OP_OTHER); diff --git a/include/control_ng.h b/include/control_ng.h index 7f89c26fb..f419625c3 100644 --- a/include/control_ng.h +++ b/include/control_ng.h @@ -79,10 +79,7 @@ ng_buffer *ng_buffer_new(struct obj *ref); INLINE void ng_buffer_release(ng_buffer *ngbuf) { obj_put(ngbuf); } -INLINE void ng_buffer_auto_release(ng_buffer **ngbuf) { - if (*ngbuf) - ng_buffer_release(*ngbuf); -} +G_DEFINE_AUTOPTR_CLEANUP_FUNC(ng_buffer, ng_buffer_release) extern mutex_t rtpe_cngs_lock; extern GHashTable *rtpe_cngs_hash;