[OPEN-ILS-DEV] PATCH: oils_cstore.c (memory leaks)
Mike Rylander
mrylander at gmail.com
Mon Feb 11 08:29:29 EST 2008
On Feb 10, 2008 11:32 PM, Scott McKellar <mck9 at swbell.net> wrote:
> This patch plugs a couple of memory leaks, and applies some minor
> optimizations, as much for clarity as for performance.
Applied, with thanks as usual. :)
>
> 1. In buildSELECT() we were leaking defaultselhash in the case of an
> early return.
>
> 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
> intuitively expect.
>
> 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.
>
> Scott McKellar
> http://home.swbell.net/mck9/ct/
> 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.
--
Mike Rylander
| VP, Research and Design
| Equinox Software, Inc. / The Evergreen Experts
| phone: 1-877-OPEN-ILS (673-6457)
| email: miker at esilibrary.com
| web: http://www.esilibrary.com
More information about the Open-ils-dev
mailing list