Merge branch '2.1' into develop

This commit is contained in:
Markus Mäkelä
2017-03-22 15:20:21 +02:00
107 changed files with 3365 additions and 3638 deletions

View File

@ -136,7 +136,7 @@ uint64_t avro_length_integer(uint64_t val)
*
* @see maxavro_get_error
*/
char* maxavro_read_string(MAXAVRO_FILE* file)
char* maxavro_read_string(MAXAVRO_FILE* file, size_t* size)
{
char *key = NULL;
uint64_t len;
@ -149,6 +149,7 @@ char* maxavro_read_string(MAXAVRO_FILE* file)
memcpy(key, file->buffer_ptr, len);
key[len] = '\0';
file->buffer_ptr += len;
*size = len;
}
else
{
@ -282,19 +283,10 @@ MAXAVRO_MAP* maxavro_read_map_from_file(MAXAVRO_FILE *file)
{
for (long i = 0; i < blocks; i++)
{
size_t size;
MAXAVRO_MAP* val = calloc(1, sizeof(MAXAVRO_MAP));
uint64_t keylen;
uint64_t valuelen;
if (val && maxavro_read_integer_from_file(file, &keylen) &&
(val->key = MXS_MALLOC(keylen + 1)) &&
fread(val->key, 1, keylen, file->file) == keylen &&
maxavro_read_integer_from_file(file, &valuelen) &&
(val->value = MXS_MALLOC(valuelen + 1)) &&
fread(val->value, 1, valuelen, file->file) == valuelen)
if (val && (val->key = maxavro_read_string(file, &size)) && (val->value = maxavro_read_string(file, &size)))
{
val->key[keylen] = '\0';
val->value[valuelen] = '\0';
val->next = rval;
rval = val;
}

View File

@ -22,7 +22,7 @@
/** Reading primitives */
bool maxavro_read_integer(MAXAVRO_FILE *file, uint64_t *val);
char* maxavro_read_string(MAXAVRO_FILE *file);
char* maxavro_read_string(MAXAVRO_FILE *file, size_t *size);
bool maxavro_skip_string(MAXAVRO_FILE* file);
bool maxavro_read_float(MAXAVRO_FILE *file, float *dest);
bool maxavro_read_double(MAXAVRO_FILE *file, double *dest);

View File

@ -98,10 +98,11 @@ static json_t* read_and_pack_value(MAXAVRO_FILE *file, MAXAVRO_SCHEMA_FIELD *fie
case MAXAVRO_TYPE_BYTES:
case MAXAVRO_TYPE_STRING:
{
char *str = maxavro_read_string(file);
size_t len;
char *str = maxavro_read_string(file, &len);
if (str)
{
value = json_string(str);
value = json_stringn(str, len);
MXS_FREE(str);
}
}