[erlang-questions] [Clarification] erl_interface: to erl_free_term() or not to erl_free_term() ?
Antoine Koener
antoine.koener@REDACTED
Mon Nov 5 15:47:05 CET 2012
>From the documentation located at:
http://erlang.org/doc/apps/erl_interface/ei_users_guide.html#id59377
Part: Example of Receiving Messages
Sample code is:
ETERM *arr[2], *answer;
int sockfd,rc;
char buf[BUFSIZE];
ErlMessage emsg;
if ((rc = erl_receive_msg(sockfd , buf, BUFSIZE, &emsg)) == ERL_MSG) {
arr[0] = erl_mk_atom("goodbye");
arr[1] = erl_element(1, emsg.msg);
answer = erl_mk_tuple(arr, 2);
erl_send(sockfd, arr[1], answer);* erl_free_term(answer);*
erl_free_term(emsg.msg);
erl_free_term(emsg.to);
}
why erl_free_term() instead of erl_free_compound ?
>From my own tests erl_free_term() is not enough...
I then think that this code leaks memory.
Maybe I'm completely wrong ?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20121105/4b415cac/attachment.htm>
More information about the erlang-questions
mailing list