avro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bru...@apache.org
Subject svn commit: r1062747 - in /avro/trunk/lang/c/src: datum.c schema.c
Date Mon, 24 Jan 2011 12:05:09 GMT
Author: brucem
Date: Mon Jan 24 12:05:09 2011
New Revision: 1062747

URL: http://svn.apache.org/viewvc?rev=1062747&view=rev
Log:
AVRO-742. Maintain reference count for singleton objects.

We use a singleton struct for instances of the null value type, and for
each of the primitive schema types.  This means that we need to increase
the reference count of each singleton each time the appropriate
constructor is called; otherwise, the reference count will get wonky
when we call avro_whatever_decref().  That won't cause any memory
corruption, since we never free any singleton objects, regardless of
what their reference counts do, but still.

Modified:
    avro/trunk/lang/c/src/datum.c
    avro/trunk/lang/c/src/schema.c

Modified: avro/trunk/lang/c/src/datum.c
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/src/datum.c?rev=1062747&r1=1062746&r2=1062747&view=diff
==============================================================================
--- avro/trunk/lang/c/src/datum.c (original)
+++ avro/trunk/lang/c/src/datum.c Mon Jan 24 12:05:09 2011
@@ -406,7 +406,7 @@ avro_datum_t avro_null(void)
 		.class_type = AVRO_DATUM,
 		.refcount = 1
 	};
-	return &obj;
+	return avro_datum_incref(&obj);
 }
 
 avro_datum_t avro_union(int64_t discriminant, avro_datum_t value)

Modified: avro/trunk/lang/c/src/schema.c
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/src/schema.c?rev=1062747&r1=1062746&r2=1062747&view=diff
==============================================================================
--- avro/trunk/lang/c/src/schema.c (original)
+++ avro/trunk/lang/c/src/schema.c Mon Jan 24 12:05:09 2011
@@ -203,7 +203,7 @@ avro_schema_t avro_schema_string(void)
 		.class_type = AVRO_SCHEMA,
 		.refcount = 1
 	};
-	return &obj;
+	return avro_schema_incref(&obj);
 }
 
 avro_schema_t avro_schema_bytes(void)
@@ -213,7 +213,7 @@ avro_schema_t avro_schema_bytes(void)
 		.class_type = AVRO_SCHEMA,
 		.refcount = 1
 	};
-	return &obj;
+	return avro_schema_incref(&obj);
 }
 
 avro_schema_t avro_schema_int(void)
@@ -223,7 +223,7 @@ avro_schema_t avro_schema_int(void)
 		.class_type = AVRO_SCHEMA,
 		.refcount = 1
 	};
-	return &obj;
+	return avro_schema_incref(&obj);
 }
 
 avro_schema_t avro_schema_long(void)
@@ -233,7 +233,7 @@ avro_schema_t avro_schema_long(void)
 		.class_type = AVRO_SCHEMA,
 		.refcount = 1
 	};
-	return &obj;
+	return avro_schema_incref(&obj);
 }
 
 avro_schema_t avro_schema_float(void)
@@ -243,7 +243,7 @@ avro_schema_t avro_schema_float(void)
 		.class_type = AVRO_SCHEMA,
 		.refcount = 1
 	};
-	return &obj;
+	return avro_schema_incref(&obj);
 }
 
 avro_schema_t avro_schema_double(void)
@@ -253,7 +253,7 @@ avro_schema_t avro_schema_double(void)
 		.class_type = AVRO_SCHEMA,
 		.refcount = 1
 	};
-	return &obj;
+	return avro_schema_incref(&obj);
 }
 
 avro_schema_t avro_schema_boolean(void)
@@ -263,7 +263,7 @@ avro_schema_t avro_schema_boolean(void)
 		.class_type = AVRO_SCHEMA,
 		.refcount = 1
 	};
-	return &obj;
+	return avro_schema_incref(&obj);
 }
 
 avro_schema_t avro_schema_null(void)
@@ -273,7 +273,7 @@ avro_schema_t avro_schema_null(void)
 		.class_type = AVRO_SCHEMA,
 		.refcount = 1
 	};
-	return &obj;
+	return avro_schema_incref(&obj);
 }
 
 avro_schema_t avro_schema_fixed(const char *name, const int64_t size)



Mime
View raw message