Giter Club home page Giter Club logo

Comments (4)

gheber avatar gheber commented on August 10, 2024

Very interesting. I'm on x64 and all tests pass. Let me take a closer look.

from hdf.pinvoke.

gheber avatar gheber commented on August 10, 2024

Please pull the latest version. Everything passes for me on x86 and x64. Please confirm.

from hdf.pinvoke.

DSanchen avatar DSanchen commented on August 10, 2024

Now all tests pass for me, too.
Redeclaring the operator_t type to take an IntPtr is surely correct.
What I consider still dangerous, is that GCHandle.Alloc() without the Pinned flag allows the GC still to move the allocated object around (which could happen any time).
From my point of view, something like this would be bulletproof:

GCHandle hnd = GCHandle.Alloc(aObj, GCHandleType.Pinned);
IntPtr aAdr = hnd.AddrOfPinnedObject();
H5A.iterate(...,cb, aAdr);
hnd.Free();

The downside of this is, that you cannot "pin" interesting .NET objects (like collections). But with the current declaration of the callback-function, it's completely up to the user, what she is passing in to the callback, so it's fine...

from hdf.pinvoke.

gheber avatar gheber commented on August 10, 2024

I would like to believe that I read somewhere that when passing a PInvoke boundary, the runtime automatically pins those handles. Maybe just wishful thinking... I'll close it for now and re-open as needed. There's another batch of callback APIs coming...

from hdf.pinvoke.

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.