[OPEN-ILS-DEV] PATCH: osrf_json_object.c (miscellaneous)

Bill Erickson erickson at esilibrary.com
Sun Dec 9 09:06:35 EST 2007


Mike Rylander wrote:
> On Dec 8, 2007 6:19 PM, Scott McKellar <mck9 at swbell.net> wrote:
>   
>> --- Mike Rylander <mrylander at gmail.com> wrote:
>>
>> <snip>
>>
>>     
>>> (FWIW, that last one is where we're leaking a bit, to the tune of
>>> around 10k objects ... my guess is that json_query is to blame.)
>>>       
>> Indeed.
>>
>> In doJSONSearch() we call jsonObjectGetIndex() and assign the result
>> to hash, but we never free hash.
>>     
>
> While that's true, I believe that registered methods are not
> responsible (and shouldn't) free parts of the ctx object.  AFAICT,
> jsonObjectGetIndex() just returns a pointer to an existing object, in
> this case the first element from the ARRAY type jsonObject that lives
> at ctx->params.  Though I could be misunderstanding you ... Bill, care
> to weigh in?
>   

Correct.  Don't free anything in the context object.  In this case, you 
may need to clone the param before it goes into the hash.
> The other part that I'm not positive about, but I believe to be true
> (and coded for),  is that osrfAppRespond() takes care of destroying
> the object it is passed.  Basically, I'm not freeing anything that
> comes out of the ctx object (hash, and all its descendants), nor
> anything I return to the client.
>   

osrfAppRespond() does not free any memory it doesn't create.  IOW, any 
memory created in the method will need to be freed in the method before 
exiting.

-- 
Bill Erickson
| VP, Software Development & Integration
| Equinox Software, Inc. / The Evergreen Experts
| phone: 877-OPEN-ILS (673-6457)
| email: erickson at esilibrary.com
| web: http://esilibrary.com



More information about the Open-ils-dev mailing list