[pulseaudio-discuss] [PATCH 1/4] format: Don't _put() objects obtained with json_object_object_get()

Peter Meerwald pmeerw at pmeerw.net
Thu Aug 21 04:18:22 PDT 2014


> > json-c documentation states that "No reference counts will be changed.
> > There is no need to manually adjust reference counts through the
> > json_object_put/json_object_get methods unless..."
> > 
> > hence fix pa_format_info_get_prop_type() and pa_format_info_get_prop_int_range();
> > note that pa_format_info_prop_compatible() is OK
> > 
> > Signed-off-by: Peter Meerwald <pmeerw at pmeerw.net>
> > ---
> >  src/pulse/format.c |    4 ----
> >  1 file changed, 4 deletions(-)
> > 
> > diff --git a/src/pulse/format.c b/src/pulse/format.c
> > index 729c2d2..a61ba37 100644
> > --- a/src/pulse/format.c
> > +++ b/src/pulse/format.c
> > @@ -289,14 +289,12 @@ pa_prop_type_t pa_format_info_get_prop_type(const pa_format_info *f, const char
> >                  type = PA_PROP_TYPE_INVALID;
> >                  break;
> >              }
> > -            json_object_put(o1);
> >  
> >              o1 = json_object_object_get(o, PA_JSON_MAX_KEY);
> >              if (!o1) {
> >                  type = PA_PROP_TYPE_INVALID;
> >                  break;
> >              }
> > -            json_object_put(o1);
> >  
> >              type = PA_PROP_TYPE_INT_RANGE;
> >              break;
> > @@ -367,13 +365,11 @@ int pa_format_info_get_prop_int_range(const pa_format_info *f, const char *key,
> >          goto out;
> >  
> >      *min = json_object_get_int(o1);
> > -    json_object_put(o1);
> >  
> >      if (!(o1 = json_object_object_get(o, PA_JSON_MAX_KEY)))
> >          goto out;
> >  
> >      *max = json_object_get_int(o1);
> > -    json_object_put(o1);
> >  
> >      ret = 0;
> 
> I'm hoping something changed in the json-c side, and that I didn't write
> such horribly wrong code. :)
> 
> There's one more json_object_put() that needs removal (as reported by
> valgrind) in pa_format_info_get_prop_type() under the 'json_type_array'
> case. If you'd like to, please go ahead and add this in, else I'll check
> in a fix after the rest of yours are pushed.

thanks for reviewing, I'll apply this evening

p.

-- 

Peter Meerwald
+43-664-2444418 (mobile)


More information about the pulseaudio-discuss mailing list