[OPEN-ILS-DEV] PATCH: osrf_chat.c

Scott McKellar mck9 at swbell.net
Sun Jun 10 18:25:46 EDT 2007


This patch closes some memory leaks and rearranges a few other things.

1. I made __osrfChatXMLErrorOcurred and __osrfChatClientSentDisconnect
static, and removed the leading underscores from their names.  No other
source files refer to them.

2. In osrfNewChatServer() I explicitly initialize the port member to
zero -- which is already happening implicitly due to the memset() in
safe_malloc().

3. Also in osrfNewChatServer(): the existing code populates the secret
member only if the secret parameter is not NULL, and leaves it
uninitialized otherwise.  However if the secret parameter were NULL
we would have already performed an early exit.  I populate the secret
member unconditionally, just as we do with the domain member.  I also
moved this assignment up with the other assignments, for a more
readable flow.

4. In osrfChatServerFree(), the existing code leaves several memory
references dangling, without freeing them.  I added code to free the
domain member, the deadNodes member, and finally the osrfChatServer 
itself.

---------------

However there is still a memory leak.

The deadNodes member points to an osrfList, which points to an array
of pointers to nodes.  With my patch we will free the osrfList and
the array of pointers.  However since we don't install a callback
function to destroy the nodes themselves, they never get freed, nor
do the various bits and scraps of memory owned by those nodes.

There is a comment about not being able to free the parser context
for a dead Node.  I haven't gotten far enough to figure out what
that's all about.  However even if there's something that we can't
free, we should be able to free more than we do.

Scott McKellar
http://home.swbell.net/mck9/aargh/

Developer's Certificate of Origin 1.1 By making a contribution to
this project, I certify that:

(a) The contribution was created in whole or in part by me and I
have the right to submit it under the open source license indicated
in the file; or

(b) The contribution is based upon previous work that, to the best
of my knowledge, is covered under an appropriate open source license
and I have the right under that license to submit that work with
modifications, whether created in whole or in part by me, under the
same open source license (unless I am permitted to submit under a
different license), as indicated in the file; or

(c) The contribution was provided directly to me by some other person
who certified (a), (b) or (c) and I have not modified it; and

(d) In the case of each of (a), (b), or (c), I understand and agree
that this project and the contribution are public and that a record
of the contribution (including all personal information I submit
with it, including my sign-off) is maintained indefinitely and may
be redistributed consistent with this project or the open source
license indicated in the file.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: osrf_chat_c_1.patch
Type: text/x-patch
Size: 3170 bytes
Desc: 2562237034-osrf_chat_c_1.patch
Url : http://list.georgialibraries.org/pipermail/open-ils-dev/attachments/20070610/6c49eb44/osrf_chat_c_1.bin


More information about the Open-ils-dev mailing list