At 03:43 AM 05/25/02 -0700, Cristiano Corsani wrote:
>1 - open a connection by sw = SwishOpen(...) the returns a "SWISH* sw"
pointer;
>2 - launch a search by SwishSearch(sw, ...);
>3 - retrive information by res = SwishNext(sw, ...), that returns a "struct
>result* res" pointer;
>4 - retrive property by prop = getResultPropValue(sw, res, ...), that
>returns a "PropValue* prop" pointer and repeat 3 - 4 till I need;
Step 4 will require freeing memory for each call to getResultPropValue.
Take a look at result_output.c. The "pv" returned from getResultPropValue
can have a string attached to it, but there's also a flag in pv that says
if the string should be freed or not.
It may be a day or so before I can get to it, but let me add a
FreeResultPropValue() function as that would be a cleaner way to deal with
that.
>5 - free the memory allocated by SwishNext (efree(res)) and
>getResultPropValue (efree(prop)) on point 3;
I don't have time to look right now, but I'm not sure if that's all that
needs to be done or not. There's also a data structure that caches the
pointers into the .prop file. I'm just not sure at this time if that needs
to be freed separately.
>6 - Close the connection by SwishClose(sw, ...).
If you are running in a persistent environment then I'd try to keep the
connection open between requests. But not without careful check of memory
usage.
>Sometimes it crashs. I have some doubts on point 5, probably
>SwishClose(...) frees the memory allocated for sw and for res and for prop.
No, I think SwishClose only deals with the sw object.
Unfortunately, the library was implemented after the program -- instead of
basing the program on the library. I suspect there's a few small memory
leaks with the library. Can you give me a day or so to look at it?
Thanks,
--
Bill Moseley
mailto:moseley@hank.org
Received on Sat May 25 13:34:52 2002