Are "_ref" and "_unref" not necessarily called in pairs?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thanks for your clarification, Col!

> -----Original Message-----
> From: pulseaudio-discuss-bounces at mail.0pointer.de
> [mailto:pulseaudio-discuss-bounces at mail.0pointer.de] On Behalf Of Colin
> Guthrie
> Sent: Thursday, May 12, 2011 5:06 PM
> To: pulseaudio-discuss at mail.0pointer.de
> Subject: Re: [pulseaudio-discuss] Are "_ref" and "_unref" not necessarily
> called in pairs?
> 
> Hiya,
> 
> 
> As per the subject question... Yes, they are supposed to be called in
> pairs... BUT....
> 
> 'Twas brillig, and Lin, Mengdong at 12/05/11 09:31 did gyre and gimble:
> > For example, in file ?module-suspend-on-idle.c ?, why does the slot
> > function ?sink_input_state_changed_hook_cb? only reference the sink
> > input but never unreference it?
> >
> > So the reference count of the sink input will only increase? Does it matter?
> >
> > Here is the code:
> >
> > static pa_hook_result_t sink_input_state_changed_hook_cb(pa_core *c,
> > pa_sink_input *s, struct userdata *u) {
> >
> >     struct device_info *d;
> >
> >     pa_sink_input_state_t state;
> >
> >
> >
> >     pa_assert(c);
> >
> >     pa_sink_input_assert_ref(s);  ? the sink input is referenced here.
> > But where pa_sink_input_unref(s) is called?
> 
> 
> 
> This is not the same as pa_sink_input_ref(). Note the word "assert" in
> the "function" call in the code above (it's actually a define, not a
> function but I won't split hairs with myself :D).
> 
> Here all that is happening is ensuring that the sink_input object is
> referenced...
> 
> The code is in pulsecore/object.h
> 
> See lines 91, and 69.
> 
> The code basically means assert if the object is not referenced. This is
> a safefy thing to ensure good programming of modules etc.
> 
> Hope that clarifies things.
> 
> Col
> 
> 
> 
> --
> 
> Colin Guthrie
> gmane(at)colin.guthr.ie
> http://colin.guthr.ie/
> 
> Day Job:
>   Tribalogic Limited [http://www.tribalogic.net/]
> Open Source:
>   Mageia Contributor [http://www.mageia.org/]
>   PulseAudio Hacker [http://www.pulseaudio.org/]
>   Trac Hacker [http://trac.edgewall.org/]
> 
> _______________________________________________
> pulseaudio-discuss mailing list
> pulseaudio-discuss at mail.0pointer.de
> https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss


[Index of Archives]     [Linux Audio Users]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux