Skip to content

Commit

Permalink
Make module data struct rtpp_refcnt * instead of void * and
Browse files Browse the repository at this point in the history
add deallocation calls.
  • Loading branch information
sobomax committed May 12, 2020
1 parent 6e74acc commit 430fbc9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion src/rtpp_stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ struct rtpp_stream_priv
/* Remote source address */
struct rtpp_netaddr *rem_addr;
/* Placeholder for per-module structures */
_Atomic(void *) pmod_data[];
unsigned int nmodules;
_Atomic(struct rtpp_refcnt *) pmod_data[];
};

static void rtpp_stream_dtor(struct rtpp_stream_priv *);
Expand Down Expand Up @@ -217,6 +218,7 @@ rtpp_stream_ctor(const struct r_stream_ctor_args *ap)
atomic_init(&(pvt->pmod_data[i]), NULL);
}
pvt->pub.pmod_data = &(pvt->pmod_data[0]);
pvt->nmodules = ap->nmodules;
CALL_SMETHOD(pvt->pub.rcnt, attach, (rtpp_refcnt_dtor_t)&rtpp_stream_dtor,
pvt);
return (&pvt->pub);
Expand Down Expand Up @@ -316,6 +318,13 @@ rtpp_stream_dtor(struct rtpp_stream_priv *pvt)
RTPP_OBJ_DECREF(pub->rrc);
if (pub->pcount != NULL)
RTPP_OBJ_DECREF(pub->pcount);
for (unsigned int i = 0; i < pvt->nmodules; i++) {
struct rtpp_refcnt *mdata_rcnt;
mdata_rcnt = atomic_load(&(pvt->pmod_data[i]));
if (mdata_rcnt != NULL) {
CALL_SMETHOD(mdata_rcnt, decref);
}
}
if (pub->ttl != NULL)
RTPP_OBJ_DECREF(pub->ttl);
RTPP_OBJ_DECREF(pub->pcnt_strm);
Expand Down
2 changes: 1 addition & 1 deletion src/rtpp_stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ struct rtpp_stream {
/* Public methods */
const struct rtpp_stream_smethods *smethods;
/* Placeholder for per-module structures */
_Atomic(void *) *pmod_data;
_Atomic(struct rtpp_refcnt *) *pmod_data;
};

struct r_stream_ctor_args {
Expand Down

0 comments on commit 430fbc9

Please sign in to comment.