Skip to content

Commit

Permalink
PS-941 Free the allocated memory (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
codingrhythm committed May 4, 2020
1 parent 0fdb5bb commit ba7ecf9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions protobuf/protoc-gen-cruxclient/api_generator.cc
Expand Up @@ -510,6 +510,7 @@ void APIGenerator::PrintDjinniObjcSupport(
printer->Print("void *bytes = malloc(byte_size);\n");
printer->Print("message.SerializeToArray(bytes, static_cast<int>(byte_size));\n");
printer->Print("NSData *data = [NSData dataWithBytes: bytes length: (int)byte_size];\n");
printer->Print("free(bytes);\n");
printer->Print("NSError *error;\n");
printer->Print(vars, "return [$objc_class_prefix$$message_name$ parseFromData:data error:&error];\n");
printer->Outdent();
Expand Down
Expand Up @@ -24,6 +24,7 @@ struct Translator {
void *bytes = malloc(byte_size);
message.SerializeToArray(bytes, static_cast<int>(byte_size));
NSData *data = [NSData dataWithBytes: bytes length: (int)byte_size];
free(bytes);
NSError *error;
return [RTGPoint parseFromData:data error:&error];
}
Expand Down Expand Up @@ -54,6 +55,7 @@ struct Translator {
void *bytes = malloc(byte_size);
message.SerializeToArray(bytes, static_cast<int>(byte_size));
NSData *data = [NSData dataWithBytes: bytes length: (int)byte_size];
free(bytes);
NSError *error;
return [RTGRectangle parseFromData:data error:&error];
}
Expand Down Expand Up @@ -84,6 +86,7 @@ struct Translator {
void *bytes = malloc(byte_size);
message.SerializeToArray(bytes, static_cast<int>(byte_size));
NSData *data = [NSData dataWithBytes: bytes length: (int)byte_size];
free(bytes);
NSError *error;
return [RTGFeature parseFromData:data error:&error];
}
Expand Down Expand Up @@ -114,6 +117,7 @@ struct Translator {
void *bytes = malloc(byte_size);
message.SerializeToArray(bytes, static_cast<int>(byte_size));
NSData *data = [NSData dataWithBytes: bytes length: (int)byte_size];
free(bytes);
NSError *error;
return [RTGRouteNote parseFromData:data error:&error];
}
Expand Down Expand Up @@ -144,6 +148,7 @@ struct Translator {
void *bytes = malloc(byte_size);
message.SerializeToArray(bytes, static_cast<int>(byte_size));
NSData *data = [NSData dataWithBytes: bytes length: (int)byte_size];
free(bytes);
NSError *error;
return [RTGRouteSummary parseFromData:data error:&error];
}
Expand Down Expand Up @@ -174,6 +179,7 @@ struct Translator {
void *bytes = malloc(byte_size);
message.SerializeToArray(bytes, static_cast<int>(byte_size));
NSData *data = [NSData dataWithBytes: bytes length: (int)byte_size];
free(bytes);
NSError *error;
return [RTGRouteSummary_Details parseFromData:data error:&error];
}
Expand Down Expand Up @@ -204,6 +210,7 @@ struct Translator {
void *bytes = malloc(byte_size);
message.SerializeToArray(bytes, static_cast<int>(byte_size));
NSData *data = [NSData dataWithBytes: bytes length: (int)byte_size];
free(bytes);
NSError *error;
return [RTGRouteSummary_Details_MoreDetails parseFromData:data error:&error];
}
Expand Down

0 comments on commit ba7ecf9

Please sign in to comment.