[erlang-questions] Replace ERL_BIN_ATOM with binary/list in a C node.

Robert Raschke rtrlists@REDACTED
Tue Jul 15 18:21:45 CEST 2014

Hi Pablo,

I'm not 100% certain, but I think binaries are not NULL terminated. So, you
need to take the length of the binary into account. That obviously makes
the code change a bit harder :-(

Looking at the erl_interface code for the atom conversion, I see quite a
bit of shuffling to do with character encodings and explicit setting of \0

I think you'll need to take a copy of the binary data and slap the \0 onto
the end yourself. And you need to be aware of the character encoding you
are expecting to exchange and, if required, convert accordingly.


On 15 July 2014 16:53, pablo platt <pablo.platt@REDACTED> wrote:

> Hi,
> I'm using erlycairo to draw on a 2D canvas.
> There are several functions that leak atoms:
> erlycairo_server:write_to_png/2
> erlycairo_server:show_text/2
> erlycairo_server:text_extents/2
> erlycairo_server:surface_create_from_png/2
> I tried to pass a binary to the C node and use (char *)ERL_BIN_PTR(file)
> but I'm getting another char at the end of the binary.
> https://code.google.com/p/erlycairo/source/browse/trunk/src/erlycairo/erlycairo_server.erl#143
> https://code.google.com/p/erlycairo/source/browse/trunk/c_src/erlycairo.c#337
> What is the correct way to use binaries or lists instead of atoms for the
> write_to_png function?
> Thanks
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20140715/ce226069/attachment.htm>

More information about the erlang-questions mailing list