Browse Source

Return TypedData_Wrap_Struct directly.

Change-Id: I6cf77f01370204ad4bc7b345a040a9a3de1706a0
Josh Haberman 10 years ago
parent
commit
d61e6adfcc
2 changed files with 2 additions and 4 deletions
  1. 1 2
      ruby/ext/google/protobuf_c/map.c
  2. 1 2
      ruby/ext/google/protobuf_c/repeated_field.c

+ 1 - 2
ruby/ext/google/protobuf_c/map.c

@@ -167,10 +167,9 @@ void Map_free(void* _self) {
 
 
 VALUE Map_alloc(VALUE klass) {
 VALUE Map_alloc(VALUE klass) {
   Map* self = ALLOC(Map);
   Map* self = ALLOC(Map);
-  VALUE ret = TypedData_Wrap_Struct(klass, &Map_type, self);
   memset(self, 0, sizeof(Map));
   memset(self, 0, sizeof(Map));
   self->value_type_class = Qnil;
   self->value_type_class = Qnil;
-  return ret;
+  return TypedData_Wrap_Struct(klass, &Map_type, self);
 }
 }
 
 
 static bool needs_typeclass(upb_fieldtype_t type) {
 static bool needs_typeclass(upb_fieldtype_t type) {

+ 1 - 2
ruby/ext/google/protobuf_c/repeated_field.c

@@ -606,13 +606,12 @@ void RepeatedField_free(void* _self) {
  */
  */
 VALUE RepeatedField_alloc(VALUE klass) {
 VALUE RepeatedField_alloc(VALUE klass) {
   RepeatedField* self = ALLOC(RepeatedField);
   RepeatedField* self = ALLOC(RepeatedField);
-  VALUE ret = TypedData_Wrap_Struct(klass, &RepeatedField_type, self);
   self->elements = NULL;
   self->elements = NULL;
   self->size = 0;
   self->size = 0;
   self->capacity = 0;
   self->capacity = 0;
   self->field_type = -1;
   self->field_type = -1;
   self->field_type_class = Qnil;
   self->field_type_class = Qnil;
-  return ret;
+  return TypedData_Wrap_Struct(klass, &RepeatedField_type, self);
 }
 }
 
 
 VALUE RepeatedField_init(int argc, VALUE* argv, VALUE self) {
 VALUE RepeatedField_init(int argc, VALUE* argv, VALUE self) {