Comments (6)
Like this: ?
public extern static ssize_t get_name(hid_t attr_id, size_t size, IntPtr name);
[TestMethod]
public unsafe void H5Aget_nameTest5()
{
size_t buf_size = IntPtr.Zero;
ssize_t size = IntPtr.Zero;
hid_t att = H5A.create(m_v2_test_file, "H5Aget_name", H5T.IEEE_F64LE, m_space_scalar);
Assert.IsTrue(att >= 0);
// pretend we don't know the size
size = H5A.get_name(att, buf_size, IntPtr.Zero);
Assert.IsTrue(size.ToInt32() == 11);
buf_size = new IntPtr(size.ToInt32() + 1);
char* namePtr = stackalloc char[(int)buf_size];
size = H5A.get_name(att, buf_size, (IntPtr)namePtr);
Assert.IsTrue(size.ToInt32() == 11);
string name = Marshal.PtrToStringAnsi((IntPtr)namePtr);
// names should match
Assert.AreEqual("H5Aget_name", name);
}
I'm not working with unsafe code so I never came around stackalloc until now. Do you use it for performance reasons ?
from hdf.pinvoke.
Exactly. In this particular example we probably could get away with StringBuilder or [MarshalAs] on a plain string (have not tried though). stackallow becomes even more useful if you just need a temporary int[] array for defining dimension lengths or hyperslab parameters a.t.l.
stackalloc also often allows to write code which is free of new
statements, which can be of advantage in multithreaded setups to prevent from contention by global locks.
We are currently integrating HDF.PInvoke into ILNumerics.IO.HDF and will add pointer overloads at all places we find useful. However, we do not cover all features of HDF5 yet.
from hdf.pinvoke.
Basically, those pointer overloads must simply reflect the HDF5 C API in a 1:1 manner.
from hdf.pinvoke.
I'd be fine with that. Let's discuss this at the next pow wow!
from hdf.pinvoke.
See issue #72 as a first step. More to come as needed/requested.
from hdf.pinvoke.
tested and working fine. (nuget 1.8.17.2, 1.10)
from hdf.pinvoke.
Related Issues (20)
- Can't read compound dataset with struct fields Sbyte and Float HOT 10
- Support HDF5 1.12 HOT 12
- Question: Iterate of each attribute of object and print its information #17
- Question: Call to list all open objects and how to close all of them? #18 HOT 2
- H5D(O) [read/write]_chunk incorrect function arguments? HOT 1
- [Question] How to use H5Z to set compressions and checksum HOT 2
- [Broken links] Some links are broken on the main page
- Memory leak issue when trying to open using H5O.open HOT 3
- NuGet binaries are all missing copyright/version information
- Alpine support HOT 1
- Doc comments HOT 2
- Typo?
- Thread safety? HOT 3
- Just SWIG it! (?)
- HDF.PInvoke for latest HDF version HOT 2
- Dependency on vcruntime140.dll HOT 3
- GetDllPathFromAppConfig Not Considering Existing Keys HOT 7
- CFD Error HOT 2
- [HELP] Wiki and demo code about read ultra large dataset
- closed
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hdf.pinvoke.