Andreas Rheinhardt (12023-10-06): > Do you mean a template that generates functions like > > HEVCVPS *ff_hevc_vps_ref(HEVCVPS *vps) > { > return ff_refstruct_ref(vps); > } > > automatically? Yes, but better, directly: void ff_hevc_vps_unref(HEVCVPS *vps) { if (atomic_fetch_sub_explicit(&(*vps)->AVRC_FIELD, 1, memory_order_acq_rel) == 1) { AVRC_FREE(*vps); *vps = NULL; } } Apart from the type safety, I see a significant benefit in having the free function hard-coded in the unref function rather than having to spare a pointer for it. Regards, -- Nicolas George