<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
You can always use a secondary channel to transmit the heavier data;
serialising libs like Protocol Buffers et. al. come to mind. As a
very unsafe alternative, you can also use enif_make_new_binary()
first and only then write your data over the allocated area. But, in
my limited experience, I wouldn't recomend it.<br>
<br>
<br>
<div class="moz-cite-prefix">On 08/09/14 11:35, Dror Mein wrote:<br>
</div>
<blockquote
cite="mid:1410172505.17155.YahooMailNeo@web126706.mail.ne1.yahoo.com"
type="cite">
<div style="color:#000; background-color:#fff;
font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial,
Lucida Grande, sans-serif;font-size:12pt">
<div>I'll try to clarify the problem.</div>
<div>I have a char * in my code, which I want to erl_send to the
erlang node. The erl_send function accepts as input an ETERM*
pointer. I need to turn char* to ETERM*. The current way is by
erl_mk_binary, which allocates memory.</div>
<div>Is there a way to pass the char * to erl_send without the
unnecessary memory allocation.</div>
<div><br>
</div>
<div style="color: rgb(0, 0, 0); font-size: 16px; font-family:
HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida
Grande', sans-serif; font-style: normal; background-color:
transparent;"><span style="background-color: transparent;">I
thought of pre-creating an ETERM struct, and only changing
the binary pointer to the char* (before running erl_send).
This way I can send multiple char* buffers without the need
to create multiple ETERM pointers.</span><br>
</div>
<div style="color: rgb(0, 0, 0); font-size: 16px; font-family:
HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida
Grande', sans-serif; font-style: normal; background-color:
transparent;"><span style="background-color: transparent;"><br>
</span></div>
<div style="color: rgb(0, 0, 0); font-size: 16px; font-family:
HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida
Grande', sans-serif; font-style: normal; background-color:
transparent;"><span style="background-color: transparent;">The
point of all this is to reduce run-time for the erl_send
process</span></div>
<div class="qtdSeparateBR"><br>
<br>
</div>
<div class="yahoo_quoted" style="display: block;">
<div style="font-family: HelveticaNeue, 'Helvetica Neue',
Helvetica, Arial, 'Lucida Grande', sans-serif; font-size:
12pt;">
<div style="font-family: HelveticaNeue, 'Helvetica Neue',
Helvetica, Arial, 'Lucida Grande', sans-serif; font-size:
12pt;">
<div dir="ltr"> <font face="Arial" size="2"> On Monday,
September 8, 2014 12:55 PM, Guilherme Andrade <a
class="moz-txt-link-rfc2396E"
href="mailto:g@gandrade.net"><g@gandrade.net></a>
wrote:<br>
</font> </div>
<br>
<br>
<div class="y_msg_container">
<div id="yiv8655810684">
<div> (Sorry, missed the subject -- you are indeed
talking about a C node. Please ignore some of my
previous phrasing.)<br clear="none">
<br clear="none">
<div class="yiv8655810684moz-cite-prefix">On
08/09/14 10:34, Guilherme Andrade wrote:<br
clear="none">
</div>
<blockquote type="cite"> </blockquote>
</div>
<div> Hi Drod,<br clear="none">
<br clear="none">
Assuming your application is a C node, and that the
library codebase is the same as for NIFs and
whatnot, I'd expect that allocating structures /
copying data is the appropriate behaviour when
creating Erlang terms -- it's the simple way to
transfer that data back to Erlang avoiding ownership
issues and mutable state (or at least making it much
harder to unintentionally do it.)<br clear="none">
<br clear="none">
I've only dealt with NIFs though, and am not an
expert on them, so probably someone else can
probably clarify this better.<br clear="none">
<br clear="none">
<br clear="none">
Cheers,<br clear="none">
<br clear="none">
<div class="yiv8655810684moz-cite-prefix">On
08/09/14 10:08, Dror Mein wrote:<br clear="none">
</div>
<blockquote type="cite">
<div style="color: rgb(0, 0, 0); font-family:
HelveticaNeue, 'Helvetica Neue', Helvetica,
Arial, 'Lucida Grande', sans-serif; font-size:
12pt; background-color: rgb(255, 255, 255);">
<div>Hi all,</div>
<div>I'm writing a c application that
communicates with an erlang node. In order to
send messages to the node I need to create
erlang terms (ETERM structure).</div>
<div>it appears that all functions in the C
library "erl_eterm" allocate memory when
creating erlang terms. </div>
<div>For example, erl_mk_binary copies the
binary provided to it, instead of only
creating the pointer.</div>
<div>I want to prevent this memory allocation to
optimize speed. </div>
<div>Has anyone done this before? </div>
<div>Is there a better way to create eterms?</div>
<div><br clear="none">
</div>
<div style="color: rgb(0, 0, 0); font-size:
16px; font-family: HelveticaNeue, 'Helvetica
Neue', Helvetica, Arial, 'Lucida Grande',
sans-serif; font-style: normal;
background-color: transparent;">Thanks</div>
</div>
<br clear="none">
<fieldset
class="yiv8655810684mimeAttachmentHeader"></fieldset>
<br clear="none">
<pre>_______________________________________________
erlang-questions mailing list
<a moz-do-not-send="true" rel="nofollow" shape="rect" class="yiv8655810684moz-txt-link-abbreviated" ymailto="mailto:erlang-questions@erlang.org" target="_blank" href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a>
<a moz-do-not-send="true" rel="nofollow" shape="rect" class="yiv8655810684moz-txt-link-freetext" target="_blank" href="http://erlang.org/mailman/listinfo/erlang-questions">http://erlang.org/mailman/listinfo/erlang-questions</a>
</pre>
</blockquote>
<br clear="none">
<pre class="yiv8655810684moz-signature">--
Guilherme
<a moz-do-not-send="true" rel="nofollow" shape="rect" class="yiv8655810684moz-txt-link-freetext" target="_blank" href="https://www.gandrade.net/">https://www.gandrade.net/</a>
PGP: 0x35CB8191 / 1968 5252 3901 B40F ED8A D67A 9330 79B1 35CB 8191
</pre>
<div class="yiv8655810684yqt9324709219"
id="yiv8655810684yqtfd48381"><br clear="none">
<fieldset
class="yiv8655810684mimeAttachmentHeader"></fieldset>
<br clear="none">
<pre>_______________________________________________
erlang-questions mailing list
<a moz-do-not-send="true" rel="nofollow" shape="rect" class="yiv8655810684moz-txt-link-abbreviated" ymailto="mailto:erlang-questions@erlang.org" target="_blank" href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a>
<a moz-do-not-send="true" rel="nofollow" shape="rect" class="yiv8655810684moz-txt-link-freetext" target="_blank" href="http://erlang.org/mailman/listinfo/erlang-questions">http://erlang.org/mailman/listinfo/erlang-questions</a>
</pre>
<br clear="none">
<pre class="yiv8655810684moz-signature">--
Guilherme
<a moz-do-not-send="true" rel="nofollow" shape="rect" class="yiv8655810684moz-txt-link-freetext" target="_blank" href="https://www.gandrade.net/">https://www.gandrade.net/</a>
PGP: 0x35CB8191 / 1968 5252 3901 B40F ED8A D67A 9330 79B1 35CB 8191
</pre>
</div>
</div>
</div>
<br>
<br>
</div>
</div>
</div>
</div>
</div>
</blockquote>
<br>
<pre class="moz-signature" cols="72">--
Guilherme
<a class="moz-txt-link-freetext" href="https://www.gandrade.net/">https://www.gandrade.net/</a>
PGP: 0x35CB8191 / 1968 5252 3901 B40F ED8A D67A 9330 79B1 35CB 8191
</pre>
</body>
</html>