unmanaged-memory

How to zero out memory allocated by Marshal.AllocHGlobal?

I am allocating some unmanaged memory in my application via Marshal.AllocHGlobal. I'm then copying a set of bytes to this location and converting the resulting segment of memory to a struct before freeing the memory again via Marshal.FreeHGlobal. Here's the method: public static T Deserialize<T>(byte[] messageBytes, int start, int len...

How to read a managed stream into a uint array directly in C#?

I have some data in a stream which is actually in the format of uint. System.IO.Stream only allows me to read the content out to a byte array, but I don't want to read the bytes and then convert them into a uint array with 1/4 the length of the byte array. I want to read it directly into the memory of the uint array so that it saves time...

System-specific bug hunting?

Hey all, I have recently been messing around with SFML, a multimedia library. I use C# so naturally I went for the .Net binding, which you can fetch from the SVN in the latest 2.0 version. After a while of messing around I noticed that my application would sometimes hang up when using the Text object, an object used to draw texture font...

C#/.NET: UnmanagedMemoryStream for networking?

I was considering using UnmanagedMemoryStream rather than MemoryStream for dealing with incoming (and perhaps outgoing?) packets in a network server. What I hope to achieve is less copying of values, and if possible, avoid copying to the heap (too much). For example, for an incoming packet, one could do: fixed (byte* p = &data) // wher...