[OPEN-ILS-DEV] PATCH: osrfConfig.c (default configuration)

Scott McKellar mck9 at swbell.net
Sat May 26 14:25:55 EDT 2007


This patch tidies up the treatment of __osrfConfigDefault, which is a
pointer to the default configuration, if there is one.

1. I declared this variable static so that it will be local to the
source file in which it appears.  No other source files refer to it,
nor should they.

2. I changed the name by removing the two leading underscores.
Identifiers beginning with two leading underscores are reserved for
use by the implementation.

3. In the osrfConfigSetDefaultConfig function I free the default
configuration, if there is one, before installing the new one.  This
change goes hand in hand with the next one:

4. In osrfConfigInit() I deleted the line that frees the prior
default configuration.  This function has nothing otherwise to do 
with the default configuration.  It creates a new configuration,
but does not install it as the default.  It has no business freeing
the default if it is not going to replace it.

At worst, this change could result in a memory leak, but only in
an improbable sequence of events: the application (a) installs a
default configuration, (b) creates a new configuration, and (c) 
does not install the new one as the default.  However I looked at
all the code that currently calls osrfConfigInit() and satisfied 
myself that no such memory leak would occur.

If for some reason we really do need to free the default configuration
at this point, we should at least set the pointer to NULL afterwards.
It's asking for trouble to leave a pointer lying around pointing to
something that doesn't exist any more.

5. I also fixed an obvious typo in one of the error messages.

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: osrfConfig_c_1.patch
Type: text/x-patch
Size: 2771 bytes
Desc: 668227266-osrfConfig_c_1.patch
Url : http://list.georgialibraries.org/pipermail/open-ils-dev/attachments/20070526/31baf444/osrfConfig_c_1.bin


More information about the Open-ils-dev mailing list