erickson [Mon, 11 Feb 2008 18:47:54 +0000 (18:47 +0000)]
rolling back one change to oilsEventFree, which was causing a double-free. as noted in a new comment, if event->json is generated, it will contain a pointer to event->payload, which will cause event->payload to be automatically freed at ->payload free time
miker [Mon, 11 Feb 2008 12:52:04 +0000 (12:52 +0000)]
Patch from Scott McKellar which 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
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.
erickson [Wed, 6 Feb 2008 03:57:01 +0000 (03:57 +0000)]
getting closer on the circmatrixmatchpoint editing
- using edit_inline on foreign keys to allow for up-front editing of
objects which link to circmatrixmatchpoint
- updated some of the __str__ methods to use gettext's unique brand of string interpolation
- added some blank=False flags for non-required fields
miker [Sun, 3 Feb 2008 19:08:44 +0000 (19:08 +0000)]
Patch from Scott McKellar:
1. In setSavepoint(), releaseSavepoint() and rollbackSavepoint()
we were leaking spName.
2. Deep in doCreate() we were passing the return value of
jsonObjectToSimpleString() directly to strcmp(), resulting in a leak.
The strcmp() was inside a complex if condition. which I rearranged so
as to capture the string and free it.
Also: I captured and reused the return value from
jsonObjectGetKeyConst() so as to avoid duplicated calls.
Aso: I reversed the sense of the if condition and swapped the branches,
so that it tests for equality rather than inequality. To my eyes this
arrangement is more readable.
3. doRetrieve() was leaking id.
4. jsonNumberToDBString() was passing the return value of
jsonObjectToSimpleString() directly to atol() and atof(), thereby
leaking the memory. I captured the pointers and freed them.
5. searchFieldTransform() was leaking val.
6. In searchJOIN() we were leaking type and filter_op in the case of
some early returns. I moved the allocations past the early returns
so that we don't allocate them until we need them. I also free them
as soon as we are done with them. As a side benefit, I was able to
avoid allocating filter_op at all in some cases.
I gave similar treatment to table, although that wasn't being leaked.
As a result I could avoid having to free it in the early returns.
A couple of the early returns would leak field or fkey. I plugged
those leaks as well.
I moved the declarations of filter and join_filter to their points
of first use, in the interest of clarity.
7. In buildSELECT(): we were passing the return value of
jsonObjectToSimpleString() directly to osrfHashGet(), thereby leaking
the memory. I captured the pointer and freed it.
8. In doFieldmapperSearch() a do/while loop allocates pkey_val but
in some cases wasn't freeing it.
miker [Sun, 3 Feb 2008 03:51:59 +0000 (03:51 +0000)]
initial in-db circ and hold stuff. this codifies the circ_modifier, and requires that values be registered before importing items that use them. so, word to the wise, and the importer. there is some example SQL that will be useful for upgrading embedded in the script files right now.
phasefx [Fri, 1 Feb 2008 17:25:05 +0000 (17:25 +0000)]
single-row refresh does not realize when an item needs to move between lists, as in the Item Outs interface with Mark Lost or Claimed Returned. This is a quick fix, needs testing
miker [Thu, 31 Jan 2008 20:13:05 +0000 (20:13 +0000)]
put source include files in front of installed, system include files in the -I list (avoids mis-matched definition errors when const, etc is corrected)
miker [Thu, 31 Jan 2008 19:01:25 +0000 (19:01 +0000)]
1. In main() we allocate a growing_buffer named "json". I added a
line to free it.
2. In commitTransaction() and rollbackTransaction() I eliminated
a layer of jsonObjectClone(), along with the associated
jsonObjectFree(). Now we extract the string we want directly from
the original object without making an unnecessary copy.
3. I renamed the four macros starting with "E" so as to start
with "E_" instead.
4. All functions (other than main()) are now static, as are the three
variables that had been declared at global scope.
miker [Thu, 31 Jan 2008 18:34:42 +0000 (18:34 +0000)]
Patch from Scott McKellar:
1. I added the const qualifier to a number of function parameters.
2. I moved the prototype for _oilsEventParseEvents() from the header
into the implementation file, and made the function static. No other
source file calls it, nor should it.
3. I removed an extra leading underscore from each of _oilsEventEvents
and _oilsEventDescriptions, and made them static.
3. I removed an unhelpful cast from a call to safe_malloc().
4. I made sure to initialize every member of a new oilsEvent.
5. In several spots where we update pointer members of an oilsEvent,
I preceded the update with a free, in order to avoid potential
memory leaks.
6. I replaced calls to oilsEventSetPermission() and
oilsEventSetPayload() with the equivalent inline code.
7. In oilsEventFree(), the original code would free the json member
or the payload member but not both. We now free both. We also
free the event member, which we didn't do before.
dbs [Tue, 29 Jan 2008 19:14:29 +0000 (19:14 +0000)]
Return explicit nulls if no matching username / barcode is found (and modify tests accordingly).
We suspect JSON::XS started returning '0' instead of 0, which threw off our logic.