Giter Club home page Giter Club logo

Comments (7)

chfast avatar chfast commented on August 13, 2024

Agreed. That was mistake.

from evmjit.

chfast avatar chfast commented on August 13, 2024

I'm not sure C++ cares how the struct was allocated. C++ only cares if the pointer is valid.

from evmjit.

chfast avatar chfast commented on August 13, 2024

This shows how you can create a struct matching C struct in Rust and pass a pointer to it to a C function.
https://doc.rust-lang.org/book/ffi.html#creating-a-safe-interface

from evmjit.

chfast avatar chfast commented on August 13, 2024

@debris Any comments?

from evmjit.

debris avatar debris commented on August 13, 2024

I'm not sure C++ cares how the struct was allocated. C++ only cares if the pointer is valid.

You are right. I've created a playground with a few examples and everything is working fine.*

*There is one failing test, but it is related with rust not casting ffi call argument to a reference automatically, rather than memory allocation.

from evmjit.

bobsummerwill avatar bobsummerwill commented on August 13, 2024

Yes, memory-is-memory. It doesn't matter where it came from when you are just using it.

Where allocations happened obviously do matter when you get to the deallocations. That is a common source of issues:

  • trying to deallocate on different threads
  • trying to deallocate with C++ pointers with free()
  • or worse!

from evmjit.

chfast avatar chfast commented on August 13, 2024

Let know if you need any changes in the area.

from evmjit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.