/[Apache-SVN]
ViewVC logotype

Revision 1242603


Jump to revision: Previous Next
Author: dcreager
Date: Thu Feb 9 23:26:32 2012 UTC (12 years, 2 months ago)
Changed paths: 7
Log Message:
AVRO-980. C: avro_schema_from_json_length

We now explicitly document that the length and error parameters are
unused in the avro_schema_from_json function.  (The error parameter
isn't needed, since any errors parsing or interpreting the JSON text are
available using the avro_strerror() function.)

This patch also adds the new avro_schema_from_json_length function.
This function actually uses its length parameter, and we explicitly
document that the length should *not* include any NUL terminator, if one
is present.  We also provide the avro_schema_from_json_literal helper
macro, which automatically calculates the size of a literal JSON string
at compile time.  (To work, the JSON string must be defined as a char[],
not a char *.)

We decided to fix this bug using a new function because there's existing
code out there that's already assuming that avro_schema_from_json's len
parameter is unused.  (Or at least, they're assuming different things
about what kind of value to pass in.)  This solution ensures that
existing code still works, while providing a new function for the
(needed) non-NUL-terminated case.  It comes at the expense of a sloppy
signature for the existing avro_schema_from_json function...but then,
the signature was already sloppy.  We're at least not adding any *new*
sloppiness.

We also now use the new avro_schema_from_json_length function when
reading an Avro object container file.  This means that we no longer
need to append a NUL terminator to the schema JSON when reading in the
container file's header.  (We don't *need to*, but we still do.  One
change at a time.)

Contributed by Michael Cooper, modified by dcreager


Changed paths

Path Details
Directoryavro/trunk/CHANGES.txt modified , text changed
Directoryavro/trunk/lang/c/examples/quickstop.c modified , text changed
Directoryavro/trunk/lang/c/src/avro/schema.h modified , text changed
Directoryavro/trunk/lang/c/src/datafile.c modified , text changed
Directoryavro/trunk/lang/c/src/schema.c modified , text changed
Directoryavro/trunk/lang/c/tests/test_avro_schema.c modified , text changed
Directoryavro/trunk/lang/c/tests/test_avro_values.c modified , text changed

infrastructure at apache.org
ViewVC Help
Powered by ViewVC 1.1.26