]> git.evergreen-ils.org Git - OpenSRF.git/commit
Patch from Scott McKellar:
authormiker <miker@9efc2488-bf62-4759-914b-345cdb29e865>
Mon, 10 Mar 2008 02:54:12 +0000 (02:54 +0000)
committermiker <miker@9efc2488-bf62-4759-914b-345cdb29e865>
Mon, 10 Mar 2008 02:54:12 +0000 (02:54 +0000)
commitb3c7a1c55ee0210bb3b076480b38d723e730462d
treec8738dfa249edb885ac1d410394efcc692b6cf30
parent6a7a11135d3a6bc875c118dc63a43c2c1e87e3dd
Patch from Scott McKellar:

These patches mostly concern the jsonObjectFindPath function in
osrf_json_tools.c, along with a couple of related functions.  They
plug some memory leaks and boost performance.

1. In osrf_json.h: I moved the nested #includes inside the compilation
guard.

2. In osrf_json_utils.h: I added a compilation guard.

3. I moved the declarations of _jsonObjectF_jsonObjectFindPathRecurse
and __jsonObjectF_jsonObjectFindPathRecurse out of the header and into
the implementation file, and made them both static.

4. I also renamed those functions to findMultiPath and
findMultiPathRecurse, respectively, so that their names wouldn't be
confusingly similar.

5. In both functions, and in the parent function jsonObjectFindPath(),
I added the const qualifier to the character pointer parameters.

6. In jsonObjectFindPath(): we were leaking pathcopy in the case of
an early return.  Besides plugging that leak, I rearranged the logic
so that we don't allocate pathcopy unless we actually have a use for
it.

7. Also in jsonObjectFindPath(): I eliminated a call to strlen(), and
the redundant variable t.

8. In _jsonObjectFindPathRecurse() (now findMultiPath()) we were
leaking newarr in the case of an early return.  Besides plugging that
leak, I rearranged the logic so that we don't allocate newarr unless
we actually have a use for it.

9. In a couple of spots I replaced "jsonParseString("[]")" with
"jsonNewObjectType(JSON_ARRAY)", a call that produces the same result
with a lot less overhead.

git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@1270 9efc2488-bf62-4759-914b-345cdb29e865
include/opensrf/osrf_json.h
include/opensrf/osrf_json_utils.h
src/libopensrf/osrf_json_tools.c