[OPEN-ILS-DEV] PATCH: oils_cstore.c (memory leaks)
mck9 at swbell.net
Sun Feb 10 23:32:52 EST 2008
This patch plugs a couple of memory leaks, and applies some minor
optimizations, as much for clarity as for performance.
1. In buildSELECT() we were leaking defaultselhash in the case of an
2. In doFieldmapperSearch() we were leaking flesh_blob in the case
of an early return.
3. In doFieldmapperSearch() I rearranged the logic a bit. First,
I performed a single search of meta to get a method type and saved
the result for reuse, instead of performing the identical search
repeatedly. Second, I turned a series of ifs into a series of
if/elses. That way we stop searching when we find a match. More
importantly, the if/else structure makes it more clear to the reader
that we're really just branching on method type in a case structure.
This latter change requires that none of the branches changes the
contents of ctx->method->userData. So far as I can tell by tracing
out all the branches, this condition is satisfied, as one would
4. Also in doFieldmapperSearch(): I increased the size of the
growing_buffer sel_list from 16 characters to 64. Since the
formatted string is at least 13 characters long, depending on the
length of the class name and primary key, I suspect that 16
characters will almost never be big enough. Even 64 characters
might be too short. I don't know how long the values typically
are in practice.
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...
Size: 3227 bytes
Url : http://list.georgialibraries.org/pipermail/open-ils-dev/attachments/20080210/617b8857/oils_cstore_c_4.bin
More information about the Open-ils-dev