You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@avro.apache.org by ma...@apache.org on 2010/01/22 20:03:00 UTC
svn commit: r902221 - in /hadoop/avro/trunk: ./ lang/c/ lang/c/src/
lang/c/tests/
Author: massie
Date: Fri Jan 22 19:02:59 2010
New Revision: 902221
URL: http://svn.apache.org/viewvc?rev=902221&view=rev
Log:
AVRO-367. Complete memory management for the C implementation
Added:
hadoop/avro/trunk/lang/c/tests/test_valgrind (with props)
Modified:
hadoop/avro/trunk/CHANGES.txt
hadoop/avro/trunk/lang/c/src/avro.h
hadoop/avro/trunk/lang/c/src/datum.c
hadoop/avro/trunk/lang/c/src/datum.h
hadoop/avro/trunk/lang/c/src/datum_equal.c
hadoop/avro/trunk/lang/c/src/datum_read.c
hadoop/avro/trunk/lang/c/src/schema.c
hadoop/avro/trunk/lang/c/src/schema.h
hadoop/avro/trunk/lang/c/tests/Makefile.am
hadoop/avro/trunk/lang/c/tests/test_avro_data.c
hadoop/avro/trunk/lang/c/tests/test_avro_schema.c
hadoop/avro/trunk/lang/c/version.sh
Modified: hadoop/avro/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/CHANGES.txt?rev=902221&r1=902220&r2=902221&view=diff
==============================================================================
--- hadoop/avro/trunk/CHANGES.txt (original)
+++ hadoop/avro/trunk/CHANGES.txt Fri Jan 22 19:02:59 2010
@@ -242,6 +242,8 @@
AVRO-364. Add support for encoding/decoding records (massie)
+ AVRO-367. Complete memory management for the C implementation (massie)
+
OPTIMIZATIONS
AVRO-172. More efficient schema processing (massie)
Modified: hadoop/avro/trunk/lang/c/src/avro.h
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/lang/c/src/avro.h?rev=902221&r1=902220&r2=902221&view=diff
==============================================================================
--- hadoop/avro/trunk/lang/c/src/avro.h (original)
+++ hadoop/avro/trunk/lang/c/src/avro.h Fri Jan 22 19:02:59 2010
@@ -136,6 +136,9 @@
avro_schema_t avro_schema_copy(avro_schema_t schema);
int avro_schema_equal(avro_schema_t a, avro_schema_t b);
+avro_schema_t avro_schema_incref(avro_schema_t schema);
+void avro_schema_decref(avro_schema_t schema);
+
void avro_schema_printf(avro_schema_t schema, FILE * fp);
/*
@@ -165,7 +168,11 @@
*/
typedef struct avro_obj_t *avro_datum_t;
avro_datum_t avro_string(const char *str);
+avro_datum_t avro_wrapstring(const char *str);
+avro_datum_t avro_givestring(const char *str);
avro_datum_t avro_bytes(const char *buf, int64_t len);
+avro_datum_t avro_wrapbytes(const char *buf, int64_t len);
+avro_datum_t avro_givebytes(const char *buf, int64_t len);
avro_datum_t avro_int(int32_t i);
avro_datum_t avro_long(int64_t l);
avro_datum_t avro_float(float f);
Modified: hadoop/avro/trunk/lang/c/src/datum.c
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/lang/c/src/datum.c?rev=902221&r1=902220&r2=902221&view=diff
==============================================================================
--- hadoop/avro/trunk/lang/c/src/datum.c (original)
+++ hadoop/avro/trunk/lang/c/src/datum.c Fri Jan 22 19:02:59 2010
@@ -17,10 +17,7 @@
#include <stdlib.h>
#include <string.h>
#include <errno.h>
-#include <limits.h>
-#include <assert.h>
#include "avro.h"
-#include "schema.h"
#include "datum.h"
#include "encoding.h"
@@ -31,38 +28,76 @@
datum->refcount = 1;
}
-avro_datum_t avro_string(const char *str)
+static avro_datum_t avro_string_private(char *str,
+ void (*string_free) (void *ptr))
{
struct avro_string_datum_t *datum =
malloc(sizeof(struct avro_string_datum_t));
if (!datum) {
return NULL;
}
- datum->s = strdup(str);
+ datum->s = str;
+ datum->free = string_free;
avro_datum_init(&datum->obj, AVRO_STRING);
return &datum->obj;
}
-avro_datum_t avro_bytes(const char *bytes, int64_t size)
+avro_datum_t avro_string(const char *str)
{
- struct avro_bytes_datum_t *datum =
- malloc(sizeof(struct avro_bytes_datum_t));
- if (!datum) {
+ char *p = strdup(str);
+ if (!p) {
return NULL;
}
- datum->bytes = malloc(size);
- if (!datum->bytes) {
- free(datum);
+ return avro_string_private(p, free);
+}
+
+avro_datum_t avro_givestring(const char *str)
+{
+ return avro_string_private((char *)str, free);
+}
+
+avro_datum_t avro_wrapstring(const char *str)
+{
+ return avro_string_private((char *)str, NULL);
+}
+
+static avro_datum_t avro_bytes_private(char *bytes, int64_t size,
+ void (*bytes_free) (void *ptr))
+{
+ struct avro_bytes_datum_t *datum;
+ datum = malloc(sizeof(struct avro_bytes_datum_t));
+ if (!datum) {
return NULL;
}
- memcpy(datum->bytes, bytes, size);
+ datum->bytes = bytes;
datum->size = size;
+ datum->free = bytes_free;
avro_datum_init(&datum->obj, AVRO_BYTES);
return &datum->obj;
}
+avro_datum_t avro_bytes(const char *bytes, int64_t size)
+{
+ char *bytes_copy = malloc(size);
+ if (!bytes_copy) {
+ return NULL;
+ }
+ memcpy(bytes_copy, bytes, size);
+ return avro_bytes_private(bytes_copy, size, free);
+}
+
+avro_datum_t avro_givebytes(const char *bytes, int64_t size)
+{
+ return avro_bytes_private((char *)bytes, size, free);
+}
+
+avro_datum_t avro_wrapbytes(const char *bytes, int64_t size)
+{
+ return avro_bytes_private((char *)bytes, size, NULL);
+}
+
avro_datum_t avro_int(int32_t i)
{
struct avro_int_datum_t *datum =
@@ -173,10 +208,27 @@
avro_record_field_set(const avro_datum_t datum,
const char *field_name, const avro_datum_t field_value)
{
+ char *key = (char *)field_name;
+ union {
+ avro_datum_t old_value;
+ st_data_t data;
+ } val;
+
if (is_avro_datum(datum) && is_avro_record(datum)) {
struct avro_record_datum_t *record =
avro_datum_to_record(datum);
- st_insert(record->fields, (st_data_t) field_name,
+ if (st_lookup
+ (record->fields, (st_data_t) field_name, &val.data)) {
+ /* Overriding old value */
+ avro_datum_decref(val.old_value);
+ } else {
+ /* Inserting new value */
+ key = strdup(field_name);
+ if (!key) {
+ return ENOMEM;
+ }
+ }
+ st_insert(record->fields, (st_data_t) key,
(st_data_t) field_value);
return 0;
}
@@ -232,13 +284,29 @@
avro_map_set(const avro_datum_t datum, const char *key,
const avro_datum_t value)
{
+ char *save_key = (char *)key;
struct avro_map_datum_t *map;
+ union {
+ st_data_t data;
+ avro_datum_t old_datum;
+ } val;
+
if (!is_avro_datum(datum) || !is_avro_map(datum) || !key
|| !is_avro_datum(value)) {
return EINVAL;
}
map = avro_datum_to_map(datum);
- st_insert(map->map, (st_data_t) key, (st_data_t) value);
+ if (st_lookup(map->map, (st_data_t) key, &(val.data))) {
+ /* Overwriting an old value */
+ avro_datum_decref(val.old_datum);
+ } else {
+ /* Inserting a new value */
+ save_key = strdup(key);
+ if (!save_key) {
+ return ENOMEM;
+ }
+ }
+ st_insert(map->map, (st_data_t) save_key, (st_data_t) value);
return 0;
}
@@ -277,17 +345,143 @@
return 0;
}
-avro_datum_t avro_datum_incref(avro_datum_t value)
+static int char_datum_free_foreach(char *key, avro_datum_t datum, void *arg)
{
- /*
- * TODO
- */
- return value;
+ avro_datum_decref(datum);
+ free(key);
+ return ST_DELETE;
+}
+
+static void avro_datum_free(avro_datum_t datum)
+{
+ if (is_avro_datum(datum)) {
+ switch (avro_typeof(datum)) {
+ case AVRO_STRING:{
+ struct avro_string_datum_t *string;
+ string = avro_datum_to_string(datum);
+ if (string->free) {
+ string->free(string->s);
+ }
+ free(string);
+ }
+ break;
+ case AVRO_BYTES:{
+ struct avro_bytes_datum_t *bytes;
+ bytes = avro_datum_to_bytes(datum);
+ if (bytes->free) {
+ bytes->free(bytes->bytes);
+ }
+ free(bytes);
+ }
+ break;
+ case AVRO_INT:{
+ struct avro_int_datum_t *i;
+ i = avro_datum_to_int(datum);
+ free(i);
+ }
+ break;
+ case AVRO_LONG:{
+ struct avro_long_datum_t *l;
+ l = avro_datum_to_long(datum);
+ free(l);
+ }
+ break;
+ case AVRO_FLOAT:{
+ struct avro_float_datum_t *f;
+ f = avro_datum_to_float(datum);
+ free(f);
+ }
+ break;
+ case AVRO_DOUBLE:{
+ struct avro_double_datum_t *d;
+ d = avro_datum_to_double(datum);
+ free(d);
+ }
+ break;
+ case AVRO_BOOLEAN:{
+ struct avro_boolean_datum_t *b;
+ b = avro_datum_to_boolean(datum);
+ free(b);
+ }
+ break;
+ case AVRO_NULL:
+ /* Nothing allocated */
+ break;
+
+ case AVRO_RECORD:{
+ struct avro_record_datum_t *record;
+ record = avro_datum_to_record(datum);
+ free((void *)record->name);
+ st_foreach(record->fields,
+ char_datum_free_foreach, 0);
+ st_free_table(record->fields);
+ free(record);
+ }
+ break;
+ case AVRO_ENUM:{
+ struct avro_enum_datum_t *enump;
+ enump = avro_datum_to_enum(datum);
+ free((void *)enump->name);
+ free((void *)enump->symbol);
+ free(enump);
+ }
+ break;
+ case AVRO_FIXED:{
+ struct avro_fixed_datum_t *fixed;
+ fixed = avro_datum_to_fixed(datum);
+ free((void *)fixed->name);
+ free((void *)fixed->bytes);
+ free(fixed);
+ }
+ break;
+ case AVRO_MAP:{
+ struct avro_map_datum_t *map;
+ map = avro_datum_to_map(datum);
+ st_foreach(map->map, char_datum_free_foreach,
+ 0);
+ st_free_table(map->map);
+ free(map);
+ }
+ break;
+ case AVRO_ARRAY:{
+ struct avro_array_datum_t *array;
+ array = avro_datum_to_array(datum);
+ while (!STAILQ_EMPTY(&array->els)) {
+ struct avro_array_element_t *el;
+ el = STAILQ_FIRST(&array->els);
+ STAILQ_REMOVE_HEAD(&array->els, els);
+ avro_datum_decref(el->datum);
+ free(el);
+ }
+ free(array);
+ }
+ break;
+ case AVRO_UNION:{
+ /* TODO */
+ }
+ break;
+ case AVRO_LINK:{
+ /* TODO */
+ }
+ break;
+ }
+ }
}
-void avro_datum_decref(avro_datum_t value)
+avro_datum_t avro_datum_incref(avro_datum_t datum)
{
+ if (datum && datum->refcount != (unsigned int)-1) {
+ ++datum->refcount;
+ }
+ return datum;
+}
+void avro_datum_decref(avro_datum_t datum)
+{
+ if (datum && datum->refcount != (unsigned int)-1
+ && --datum->refcount == 0) {
+ avro_datum_free(datum);
+ }
}
void avro_datum_print(avro_datum_t value, FILE * fp)
Modified: hadoop/avro/trunk/lang/c/src/datum.h
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/lang/c/src/datum.h?rev=902221&r1=902220&r2=902221&view=diff
==============================================================================
--- hadoop/avro/trunk/lang/c/src/datum.h (original)
+++ hadoop/avro/trunk/lang/c/src/datum.h Fri Jan 22 19:02:59 2010
@@ -25,12 +25,14 @@
struct avro_string_datum_t {
struct avro_obj_t obj;
char *s;
+ void (*free) (void *ptr);
};
struct avro_bytes_datum_t {
struct avro_obj_t obj;
char *bytes;
int64_t size;
+ void (*free) (void *ptr);
};
struct avro_int_datum_t {
Modified: hadoop/avro/trunk/lang/c/src/datum_equal.c
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/lang/c/src/datum_equal.c?rev=902221&r1=902220&r2=902221&view=diff
==============================================================================
--- hadoop/avro/trunk/lang/c/src/datum_equal.c (original)
+++ hadoop/avro/trunk/lang/c/src/datum_equal.c Fri Jan 22 19:02:59 2010
@@ -77,11 +77,8 @@
{
struct st_equal_args args = { 1, b->fields };
if (a->fields->num_entries != b->fields->num_entries) {
- fprintf(stderr, "num entries mismatch %d != %d\n",
- a->fields->num_entries, b->fields->num_entries);
return 0;
}
- fprintf(stderr, "Each record has %d values\n", a->fields->num_entries);
st_foreach(a->fields, st_equal_foreach, (st_data_t) & args);
return args.rval;
}
Modified: hadoop/avro/trunk/lang/c/src/datum_read.c
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/lang/c/src/datum_read.c?rev=902221&r1=902220&r2=902221&view=diff
==============================================================================
--- hadoop/avro/trunk/lang/c/src/datum_read.c (original)
+++ hadoop/avro/trunk/lang/c/src/datum_read.c Fri Jan 22 19:02:59 2010
@@ -194,12 +194,15 @@
avro_schema_to_map(readers_schema)->
values, &value);
if (rval) {
+ free(key);
return rval;
}
rval = avro_map_set(map, key, value);
if (rval) {
+ free(key);
return rval;
}
+ free(key);
}
rval = enc->read_long(reader, &block_count);
if (rval) {
@@ -314,7 +317,7 @@
{
char *s;
rval = enc->read_string(reader, &s);
- *datum = avro_string(s);
+ *datum = avro_givestring(s);
}
break;
@@ -355,7 +358,7 @@
char *bytes;
int64_t len;
rval = enc->read_bytes(reader, &bytes, &len);
- *datum = avro_bytes(bytes, len);
+ *datum = avro_givebytes(bytes, len);
}
break;
Modified: hadoop/avro/trunk/lang/c/src/schema.c
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/lang/c/src/schema.c?rev=902221&r1=902220&r2=902221&view=diff
==============================================================================
--- hadoop/avro/trunk/lang/c/src/schema.c (original)
+++ hadoop/avro/trunk/lang/c/src/schema.c Fri Jan 22 19:02:59 2010
@@ -58,12 +58,118 @@
return 0;
}
-/*
- * TODO
- */
-void avro_schema_free(avro_schema_t schema)
+static void avro_schema_free(avro_schema_t schema)
{
- return;
+ if (is_avro_schema(schema)) {
+ switch (avro_typeof(schema)) {
+ case AVRO_STRING:
+ case AVRO_BYTES:
+ case AVRO_INT:
+ case AVRO_LONG:
+ case AVRO_FLOAT:
+ case AVRO_DOUBLE:
+ case AVRO_BOOLEAN:
+ case AVRO_NULL:
+ /* no memory allocated for primitives */
+ return;
+
+ case AVRO_RECORD:{
+ struct avro_record_schema_t *record;
+ record = avro_schema_to_record(schema);
+ free(record->name);
+ while (!STAILQ_EMPTY(&record->fields)) {
+ struct avro_record_field_t *field;
+ field = STAILQ_FIRST(&record->fields);
+ STAILQ_REMOVE_HEAD(&record->fields,
+ fields);
+ avro_schema_decref(field->type);
+ free(field->name);
+ free(field);
+ }
+ free(record);
+ }
+ break;
+
+ case AVRO_ENUM:{
+ struct avro_enum_schema_t *enump;
+ enump = avro_schema_to_enum(schema);
+ free(enump->name);
+ while (!STAILQ_EMPTY(&enump->symbols)) {
+ struct avro_enum_symbol_t *symbol;
+ symbol = STAILQ_FIRST(&enump->symbols);
+ STAILQ_REMOVE_HEAD(&enump->symbols,
+ symbols);
+ free(symbol->symbol);
+ free(symbol);
+ }
+ free(enump);
+ }
+ break;
+
+ case AVRO_FIXED:{
+ struct avro_fixed_schema_t *fixed;
+ fixed = avro_schema_to_fixed(schema);
+ free((char *)fixed->name);
+ free(fixed);
+ }
+ break;
+
+ case AVRO_MAP:{
+ struct avro_map_schema_t *map;
+ map = avro_schema_to_map(schema);
+ avro_schema_decref(map->values);
+ free(map);
+ }
+ break;
+
+ case AVRO_ARRAY:{
+ struct avro_array_schema_t *array;
+ array = avro_schema_to_array(schema);
+ avro_schema_decref(array->items);
+ free(array);
+ }
+ break;
+ case AVRO_UNION:{
+ struct avro_union_schema_t *unionp;
+ unionp = avro_schema_to_union(schema);
+ while (!STAILQ_EMPTY(&unionp->branches)) {
+ struct avro_union_branch_t *branch;
+ branch =
+ STAILQ_FIRST(&unionp->branches);
+ STAILQ_REMOVE_HEAD(&unionp->branches,
+ branches);
+ avro_schema_decref(branch->schema);
+ free(branch);
+ }
+ free(unionp);
+ }
+ break;
+
+ case AVRO_LINK:{
+ struct avro_link_schema_t *link;
+ link = avro_schema_to_link(schema);
+ avro_schema_decref(link->to);
+ free(link);
+ }
+ break;
+ }
+ }
+}
+
+avro_schema_t avro_schema_incref(avro_schema_t schema)
+{
+ if (schema && schema->refcount != (unsigned int)-1) {
+ ++schema->refcount;
+ }
+ return schema;
+}
+
+void avro_schema_decref(avro_schema_t schema)
+{
+ if (schema && schema->refcount != (unsigned int)-1
+ && --schema->refcount == 0) {
+ avro_schema_free(schema);
+ }
}
avro_schema_t avro_schema_string(void)
@@ -189,7 +295,7 @@
if (!s) {
return ENOMEM;
}
- s->schema = schema;
+ s->schema = avro_schema_incref(schema);
STAILQ_INSERT_TAIL(&unionp->branches, s, branches);
return 0;
}
Modified: hadoop/avro/trunk/lang/c/src/schema.h
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/lang/c/src/schema.h?rev=902221&r1=902220&r2=902221&view=diff
==============================================================================
--- hadoop/avro/trunk/lang/c/src/schema.h (original)
+++ hadoop/avro/trunk/lang/c/src/schema.h Fri Jan 22 19:02:59 2010
@@ -87,22 +87,4 @@
#define avro_schema_to_fixed(schema_) (container_of(schema_, struct avro_fixed_schema_t, obj))
#define avro_schema_to_link(schema_) (container_of(schema_, struct avro_link_schema_t, obj))
-static inline avro_schema_t avro_schema_incref(avro_schema_t schema)
-{
- if (schema && schema->refcount != (unsigned int)-1) {
- ++schema->refcount;
- }
- return schema;
-}
-
-void avro_schema_free(avro_schema_t schema);
-
-static inline void avro_schema_decref(avro_schema_t schema)
-{
- if (schema && schema->refcount != (unsigned int)-1
- && --schema->refcount == 0) {
- avro_schema_free(schema);
- }
-}
-
#endif
Modified: hadoop/avro/trunk/lang/c/tests/Makefile.am
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/lang/c/tests/Makefile.am?rev=902221&r1=902220&r2=902221&view=diff
==============================================================================
--- hadoop/avro/trunk/lang/c/tests/Makefile.am (original)
+++ hadoop/avro/trunk/lang/c/tests/Makefile.am Fri Jan 22 19:02:59 2010
@@ -3,7 +3,7 @@
AM_CFLAGS=-Wall
ACLOCAL_AMFLAGS=-I m4
-EXTRA_DIST=schema_tests
+EXTRA_DIST=schema_tests test_valgrind
check_PROGRAMS=test_avro_schema test_avro_data
@@ -18,4 +18,4 @@
test_avro_interop_SOURCES=test_avro_interop.c
test_avro_interop_LDADD=$(test_LDADD)
-TESTS=$(check_PROGRAMS)
+TESTS=$(check_PROGRAMS) test_valgrind
Modified: hadoop/avro/trunk/lang/c/tests/test_avro_data.c
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/lang/c/tests/test_avro_data.c?rev=902221&r1=902220&r2=902221&view=diff
==============================================================================
--- hadoop/avro/trunk/lang/c/tests/test_avro_data.c (original)
+++ hadoop/avro/trunk/lang/c/tests/test_avro_data.c Fri Jan 22 19:02:59 2010
@@ -60,12 +60,13 @@
"a new nation", "conceived in Liberty",
"and dedicated to the proposition that all men are created equal."
};
+ avro_schema_t writer_schema = avro_schema_string();
for (i = 0; i < sizeof(strings) / sizeof(strings[0]); i++) {
- avro_schema_t writer_schema = avro_schema_string();
- avro_datum_t datum = avro_string(strings[i]);
+ avro_datum_t datum = avro_wrapstring(strings[i]);
write_read_check(writer_schema, NULL, datum, "string");
avro_datum_decref(datum);
}
+ avro_schema_decref(writer_schema);
return 0;
}
@@ -73,70 +74,76 @@
{
char bytes[] = { 0xDE, 0xAD, 0xBE, 0xEF };
avro_schema_t writer_schema = avro_schema_bytes();
- avro_datum_t datum = avro_bytes(bytes, sizeof(bytes));
+ avro_datum_t datum = avro_wrapbytes(bytes, sizeof(bytes));
write_read_check(writer_schema, NULL, datum, "bytes");
avro_datum_decref(datum);
+ avro_schema_decref(writer_schema);
return 0;
}
static int test_int(void)
{
int i;
+ avro_schema_t writer_schema = avro_schema_int();
for (i = 0; i < 100; i++) {
- avro_schema_t writer_schema = avro_schema_int();
avro_datum_t datum = avro_int(rand());
write_read_check(writer_schema, NULL, datum, "int");
avro_datum_decref(datum);
}
+ avro_schema_decref(writer_schema);
return 0;
}
static int test_long(void)
{
int i;
+ avro_schema_t writer_schema = avro_schema_long();
for (i = 0; i < 100; i++) {
- avro_schema_t writer_schema = avro_schema_long();
avro_datum_t datum = avro_long(rand());
write_read_check(writer_schema, NULL, datum, "long");
avro_datum_decref(datum);
}
+ avro_schema_decref(writer_schema);
return 0;
}
static int test_double(void)
{
int i;
+ avro_schema_t schema = avro_schema_double();
for (i = 0; i < 100; i++) {
- avro_schema_t schema = avro_schema_double();
avro_datum_t datum = avro_double((double)(rand()));
write_read_check(schema, NULL, datum, "double");
avro_datum_decref(datum);
}
+ avro_schema_decref(schema);
return 0;
}
static int test_float(void)
{
int i;
+ avro_schema_t schema = avro_schema_double();
for (i = 0; i < 100; i++) {
- avro_schema_t schema = avro_schema_double();
avro_datum_t datum = avro_double((double)(rand()));
write_read_check(schema, NULL, datum, "float");
avro_datum_decref(datum);
}
+ avro_schema_decref(schema);
return 0;
}
static int test_boolean(void)
{
int i;
+ avro_schema_t schema = avro_schema_boolean();
for (i = 0; i <= 1; i++) {
- avro_schema_t schema = avro_schema_boolean();
avro_datum_t datum = avro_boolean(i);
write_read_check(schema, NULL, datum, "boolean");
avro_datum_decref(datum);
}
+ avro_schema_decref(schema);
return 0;
}
@@ -157,10 +164,14 @@
avro_schema_record_field_append(schema, "name", avro_schema_string());
avro_schema_record_field_append(schema, "age", avro_schema_int());
- avro_record_field_set(datum, "name", avro_string("Joseph Campbell"));
+ avro_record_field_set(datum, "name",
+ avro_wrapstring("Joseph Campbell"));
avro_record_field_set(datum, "age", avro_int(83));
write_read_check(schema, NULL, datum, "record");
+
+ avro_datum_decref(datum);
+ avro_schema_decref(schema);
return 0;
}
@@ -186,6 +197,7 @@
}
write_read_check(schema, NULL, datum, "array");
avro_datum_decref(datum);
+ avro_schema_decref(schema);
return 0;
}
@@ -202,6 +214,7 @@
}
write_read_check(schema, NULL, datum, "map");
avro_datum_decref(datum);
+ avro_schema_decref(schema);
return 0;
}
Modified: hadoop/avro/trunk/lang/c/tests/test_avro_schema.c
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/lang/c/tests/test_avro_schema.c?rev=902221&r1=902220&r2=902221&view=diff
==============================================================================
--- hadoop/avro/trunk/lang/c/tests/test_avro_schema.c (original)
+++ hadoop/avro/trunk/lang/c/tests/test_avro_schema.c Fri Jan 22 19:02:59 2010
@@ -70,6 +70,8 @@
"failed to avro_schema_equal(schema,avro_schema_copy())\n");
exit(EXIT_FAILURE);
}
+ avro_schema_decref(schema_copy);
+ avro_schema_decref(schema);
} else {
/*
* Unexpected success
Added: hadoop/avro/trunk/lang/c/tests/test_valgrind
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/lang/c/tests/test_valgrind?rev=902221&view=auto
==============================================================================
--- hadoop/avro/trunk/lang/c/tests/test_valgrind (added)
+++ hadoop/avro/trunk/lang/c/tests/test_valgrind Fri Jan 22 19:02:59 2010
@@ -0,0 +1,34 @@
+#!/bin/sh
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to you under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+set +e
+set -x
+
+if ! which valgrind; then
+ echo "Unable to find valgrind installed. Test will not run."
+ # This special exit value will show that we skipped this test
+ exit 77
+fi
+
+LD_LIBRARY_PATH="../src/.libs/:${LD_LIBRARY_PATH}"
+valgrind --leak-check=full --show-reachable=yes -q .libs/test_avro_data 2>&1 |\
+grep -E '^==[0-9]+== '
+if [ $? -eq 0 ]; then
+ # Expression found. Test failed.
+ exit 1
+else
+ # We're all clean
+ exit 0
+fi
Propchange: hadoop/avro/trunk/lang/c/tests/test_valgrind
------------------------------------------------------------------------------
svn:executable = *
Modified: hadoop/avro/trunk/lang/c/version.sh
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/lang/c/version.sh?rev=902221&r1=902220&r2=902221&view=diff
==============================================================================
--- hadoop/avro/trunk/lang/c/version.sh (original)
+++ hadoop/avro/trunk/lang/c/version.sh Fri Jan 22 19:02:59 2010
@@ -18,9 +18,9 @@
# libavro_binary_age = 0
# libavro_interface_age = 0
#
-libavro_micro_version=7
+libavro_micro_version=8
libavro_interface_age=0
-libavro_binary_age=2
+libavro_binary_age=3
# IGNORE EVERYTHING ELSE FROM HERE DOWN.........
if test $# != 1; then