On Fri, Oct 25, 2013 at 4:04 PM, Pavel Levshin <[email protected]> wrote:
> > 25.10.2013 17:37, Rainer Gerhards: > > > Argh... I thought you were right, but actually we use >> json_object_object_get() to obtain the value, which does not increment the >> reference count. So json_object_put() [free] is not required nor permitted >> here. Doc: http://json-c.github.io/json-**c/json-c-0.10/doc/html/json__** >> object_8h.html#**acc3628d97c6308dc967006e4268c4**e7f<http://json-c.github.io/json-c/json-c-0.10/doc/html/json__object_8h.html#acc3628d97c6308dc967006e4268c4e7f> >> > > > I'll look at it. > > But if you are going to allow such constructs: > > set $!var = func( func_returning_object () ) > > then you need to free temporary object somewhere. Reference counting is a > simplest way to do it. > > well. json_object_object_get() is the only function that does not add a new reference, so there is no (kind of) temporary object created. As I said, I thought there's a bug and "fixed" it. It turned out that the fix does double-frees, and so I went back to the doc... > > There should be some varFree() function for this. >>> >>> Anyhow, that's a good suggestion and I will add it. But it will be equal >>> >> to the current code, except that it is easier to extend in the future. >> > > You already have it, it is named varDelete. I would generalize it like > that: > > argh, I simply believed you there were currently none (I implied that, the var issue seems to take its toll...). So I added a second one. OK, will clean up again. > void > varDelete(struct var *v) > { > switch(v->datatype) { > case 'S': > es_deleteStr(v->d.estr); > break; > case 'A': > cnfarrayContentDestruct(v->d.**ar <http://d.ar>); > free(v->d.ar); > break; > case 'J': > json_object_put(v->d.json); /* do you think it is wrong? */ > Definitely! Read the doc link I posted. > break; > case 'N': > break; > default: > dbgprintf("warning: trying to delete a variable of unknown type > '%c'\n", v->datatype); > break; > > } > } > > The question still remains why I did not use that function. Usually, there is a reason for this. But that's not any more for today. Thanks, Rainer > > -- > Pavel Levshin > > ______________________________**_________________ > rsyslog mailing list > http://lists.adiscon.net/**mailman/listinfo/rsyslog<http://lists.adiscon.net/mailman/listinfo/rsyslog> > http://www.rsyslog.com/**professional-services/<http://www.rsyslog.com/professional-services/> > What's up with rsyslog? Follow https://twitter.com/rgerhards > NOTE WELL: This is a PUBLIC mailing list, posts are ARCHIVED by a myriad > of sites beyond our control. PLEASE UNSUBSCRIBE and DO NOT POST if you > DON'T LIKE THAT. > _______________________________________________ rsyslog mailing list http://lists.adiscon.net/mailman/listinfo/rsyslog http://www.rsyslog.com/professional-services/ What's up with rsyslog? Follow https://twitter.com/rgerhards NOTE WELL: This is a PUBLIC mailing list, posts are ARCHIVED by a myriad of sites beyond our control. PLEASE UNSUBSCRIBE and DO NOT POST if you DON'T LIKE THAT.

