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#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.

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:

void
varDelete(struct var *v)
{
    switch(v->datatype) {
    case 'S':
        es_deleteStr(v->d.estr);
        break;
    case 'A':
        cnfarrayContentDestruct(v->d.ar);
        free(v->d.ar);
        break;
    case 'J':
        json_object_put(v->d.json);  /* do you think it is wrong? */
        break;
    case 'N':
        break;
    default:
dbgprintf("warning: trying to delete a variable of unknown type '%c'\n", v->datatype);
        break;
    }
}


--
Pavel Levshin

_______________________________________________
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.

Reply via email to