Memory leak in the example file "foo_client.c"
lifeng68 opened this issue · comments
foo__HelloReply *r;
char str[BUFSIZ];
snprintf(str, BUFSIZ, "world");
h.name = str;
/*
* This will invoke a blocking RPC
*/
int status = foo__greeter__say_hello__sync(client, &h, &r, NULL, 0);
printf("Got back: %s\n", r->message);
printf("Finished with %d\n", status
In the example file foo_client.c ,the memory pointed by the "foo__HelloReply *r" hadn't free. I added "create_response_free(NULL,r);" to free the memory.Please tell me, Is it OK?
_free function will be generated by protobuf_c for each structure. That can be used here to free data. I will update this.
@ajhai Are you talking about _reply_free()
stub that you added? If so, that doesn't really work here, because the prototype of the xxx_reply_free (grpc_c_context_t *context, void *buf)
requires a context to pass in. But in https://github.com/Juniper/grpc-c/blob/master/lib/client.c#L1177 you end up freeing the context yourself, so it's impossible to pass in anything..
this project has a lot of memory allocation missing a free. had better pray if want to use this for long-term running application.