[Mono-dev] Allocating unmanaged memory

Leszek Ciesielski skolima at gmail.com
Thu Jan 4 10:42:33 EST 2007


On 1/4/07, Jonathan Pryor <jonpryor at vt.edu> wrote:
> On Thu, 2007-01-04 at 12:19 +0100, Leszek Ciesielski wrote:
> > I need to allocate unmanaged memory AND make sure it is filled with
> > 0's. Is there some clever/fast way to do this?  So far, I found only
> > Marshal.WriteByte, which sets one byte at a time.
>
> Mono.Unix.Native.Stdlib.calloc() in Mono.Posix.dll will do this.
>
>  - Jon
>
>
>

Uhm. Quite a lot solutions for a simple task :P I asked the question,
because I found a bug in OracleClient, where memory was allocated but
not zeroed (and OCI expected it to be padded with 0's). So a simple
AllocHGlobal was not enough. I am working with the current repository
version - is there a _preferred_ way? For now I am going to run a
benchmark and choose the fastest method :-)



More information about the Mono-devel-list mailing list