You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@avro.apache.org by cu...@apache.org on 2010/08/25 23:38:55 UTC
svn commit: r989379 - in /avro/trunk: CHANGES.txt lang/c/src/datafile.c
Author: cutting
Date: Wed Aug 25 21:38:55 2010
New Revision: 989379
URL: http://svn.apache.org/viewvc?rev=989379&view=rev
Log:
AVRO-510. C: Fix some memory leaks in datafile reader and writer. Contributed by Robert G. Jakabosky.
Modified:
avro/trunk/CHANGES.txt
avro/trunk/lang/c/src/datafile.c
Modified: avro/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/avro/trunk/CHANGES.txt?rev=989379&r1=989378&r2=989379&view=diff
==============================================================================
--- avro/trunk/CHANGES.txt (original)
+++ avro/trunk/CHANGES.txt Wed Aug 25 21:38:55 2010
@@ -184,6 +184,9 @@ Avro 1.4.0 (unreleased)
AVRO-86. Java: Fix NullPointerException when reflect API infers
schema for a class without a package. (cutting)
+ AVRO-510. C: Fix some memory leaks in datafile reader &
+ writer. (Robert G. Jakabosky via cutting)
+
Avro 1.3.3 (7 June 2010)
IMPROVEMENTS
Modified: avro/trunk/lang/c/src/datafile.c
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/src/datafile.c?rev=989379&r1=989378&r2=989379&view=diff
==============================================================================
--- avro/trunk/lang/c/src/datafile.c (original)
+++ avro/trunk/lang/c/src/datafile.c Wed Aug 25 21:38:55 2010
@@ -65,6 +65,7 @@ static int write_header(avro_file_writer
avro_writer_t schema_writer;
char schema_buf[64 * 1024];
const avro_encoding_t *enc = &avro_binary_encoding;
+ int64_t schema_len;
/* Generate random sync */
generate_sync(w);
@@ -84,9 +85,10 @@ static int write_header(avro_file_writer
avro_writer_free(schema_writer);
return rval;
}
+ schema_len = avro_writer_tell(schema_writer);
+ avro_writer_free(schema_writer);
check(rval,
- enc->write_bytes(w->writer, schema_buf,
- avro_writer_tell(schema_writer)));
+ enc->write_bytes(w->writer, schema_buf, schema_len));
check(rval, enc->write_long(w->writer, 0));
return write_sync(w);
}
@@ -108,7 +110,9 @@ file_writer_init_fp(const char *path, co
static int
file_writer_create(const char *path, avro_schema_t schema, avro_file_writer_t w)
{
- int rval = file_writer_init_fp(path, "wx", w);
+ int rval;
+ w->block_count = 0;
+ rval = file_writer_init_fp(path, "wx", w);
if (rval) {
check(rval, file_writer_init_fp(path, "w", w));
}
@@ -171,11 +175,12 @@ static int file_read_header(avro_reader_
if (rval) {
return EILSEQ;
}
+ avro_schema_decref(meta_schema);
check(rval, avro_map_get(meta, "avro.schema", &schema_bytes));
avro_bytes_get(schema_bytes, &p, &len);
check(rval,
avro_schema_from_json(p, len, writers_schema, &schema_error));
- avro_schema_decref(meta);
+ avro_datum_decref(meta);
return avro_read(reader, sync, synclen);
}
@@ -324,7 +329,9 @@ int avro_file_writer_close(avro_file_wri
{
int rval;
check(rval, avro_file_writer_flush(w));
+ avro_writer_free(w->datum_writer);
avro_writer_free(w->writer);
+ free(w);
return 0;
}
@@ -357,6 +364,8 @@ int avro_file_reader_read(avro_file_read
int avro_file_reader_close(avro_file_reader_t reader)
{
+ avro_schema_decref(reader->writers_schema);
avro_reader_free(reader->reader);
+ free(reader);
return 0;
}