Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^3: FFI::Platypus: Replace malloc with GC_MALLOC?

by ikegami (Patriarch)
on Dec 13, 2022 at 13:57 UTC ( [id://11148822]=note: print w/replies, xml ) Need Help??


in reply to Re^2: FFI::Platypus: Replace malloc with GC_MALLOC?
in thread FFI::Platypus: Replace malloc with GC_MALLOC?

I'm just trying to improve my poor C knowledge.

You picked something that's probably a bit too advanced for that. It involves not just C, but knowledge of FFI and of Perl internals as well, both of which are complex systems.

Is [replacing malloc with GC_MALLOC] recommended or will it cause problems in the future not yet imaginable now?

The answer to the question depends on whether FFI or Perl can free the returned buffer.

I think the const in the return type tells FFI to copy the string and avoid freeing it. If so, then yes, you could use a different allocator.

I'm guessing that because the example would have problem as-is if FFI or Perl could free the buffer.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11148822]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (2)
As of 2024-04-24 23:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found