[waffle] [PATCH 04/12] core: add JSON library

Emil Velikov emil.l.velikov at gmail.com
Sun Apr 24 10:18:36 UTC 2016


On 21 April 2016 at 21:25, Frank Henigman <fjhenigman at google.com> wrote:
> On Fri, Apr 8, 2016 at 7:38 PM, Chad Versace <chad.versace at intel.com> wrote:
>> On 01/08/2016 04:17 AM, Emil Velikov wrote:
>>> On 6 January 2016 at 21:56, Frank Henigman <fjhenigman at google.com> wrote:
>>>> A small library for building JSON strings.
>>>>
>>>> Signed-off-by: Frank Henigman <fjhenigman at google.com>
>>>> ---
>>>>  src/waffle/CMakeLists.txt |   1 +
>>>>  src/waffle/core/json.c    | 235 ++++++++++++++++++++++++++++++++++++++++++++++
>>>>  src/waffle/core/json.h    |  93 ++++++++++++++++++
>>
>>> Is the library is copied/derived from another project or written from
>>> scratch ? If the former should we move it to third_party/  ?
>>
>> I have the same question. Was this code copied from a public Google project?
>> If so, the we should place in third_party/ with a note explaining its origin
>> and explaining how to update it in the future. If not, the the current location
>> in src/waffle/core/ is appropriate.
>
> I wrote it.  I didn't really want to write a json lib, but I did want
> the json-building code (the code that calls a json lib) to be as clear
> and simple as I could make it, and it seemed I needed to write
> something to facilitate that.  I'm open to a third party solution, if
> it doesn't require uglier code to use it.  I didn't think of it at the
> time, but maybe a little wrapping around some third party lib could do
> the job.  But by now I don't remember anything about the third party
> libs I looked at.
I think it's fine as is (i.e. not replying upon (linking against)
third party libs). Just asking because I have a few suggestions if
it's an waffle specific implementation:

Namely:
Pipe through all the memory allocation functions -
malloc/calloc/strdup via the waffle wrappers. They will set the error
state, thus you won't need to bother up the call chain (as mentioned
in other patch). Just need to propagate if the function(s) has failed
or not.

Also, please don't use goto statements to jump back [in time].
Thinking about the case in json_append().

Thanks
Emil


More information about the waffle mailing list