Frederik,

As I told you, you should think about an 'unsafe solution': unsafe is
the code you can write in a C# language, managing the memory pointers
by yourself, rather than letting the VM to do it.
For doing this you have to sign the assembly as unsafe, then you can
place blocks of 'unsafe' code (even entire classes) inside the  Mono
(or .NET) application, handling the memset by yourself.

Maybe this reply was unneeded, but from your answer I think you don't
know what 'unsafe' code is...

Cheers



On 2/20/07, Frederik Carlier <[EMAIL PROTECTED]> wrote:
> Antonello,
>
> Thanks for the reply. Maybe my terminology is a bit off -- it should
> have been "C# equivalent of memset". The struct is going to be passed to
> unmanaged code, but I was wondering how to "prepare" it before passing
> it. That is, I need a C# equivalent of the line
> memset(m_errbuf,0,sizeof(TidyBuffer)). I tried googling, I tried looking
> what the Marshal class has to offer, but yet didn't find any answer.
> That's why I tried this list.
>
> So, can anybody offer any insight into how to convert the C++ code below
> to C#/Interop?
>
> Frederik.
>
> Antonello Provenzano schreef:
> > Frederik,
> >
> > Managed code is by definition "managed", that means the memory is
> > handled by the VirtualMachine: so you can't operate on the memory
> > directly.
> > You should try to look for an "unsafe" (if you don't know what
> > 'unsafe' means in such context, read the manual...) solution, that
> > could be found around somewhere by googling a bit.
> >
> > Cheers
> >
> >
> > On 2/20/07, Frederik Carlier <[EMAIL PROTECTED]> wrote:
> >> Hi,
> >>
> >> As a quick introduction, I'm trying to convert a C++.NET wrapper around
> >> HTML Tidy to C#, because of the lack of a C++.NET compiler for Linux.
> >> I'm by no means an expert in unmanaged code, but things are going well.
> >>
> >> I am, however, hitting a problem with a struct. The C++ code that
> >> initializes the struct reads as follows:
> >>
> >> [C++]
> >> m_errbuf = new TidyBuffer;
> >> memset(m_errbuf,0,sizeof(TidyBuffer));
> >> tidySetErrorBuffer(m_tdoc,m_errbuf);
> >>
> >> Re-creating the struct and calling tidySetErrorBuffer is easy enough,
> >> but what is the managed equivalent of memset? If I just 'omit' the
> >> memset line, I get the following failed assertion:
> >>
> >> mono: src/buffio.c:184: tidyBufPutByte: Assertion `buf != ((void *)0)'
> >> failed.
> >>
> >> Thanks,
> >>
> >> Frederik.
> >> _______________________________________________
> >> Mono-list maillist  -  [email protected]
> >> http://lists.ximian.com/mailman/listinfo/mono-list
> >>
>
>
_______________________________________________
Mono-list maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-list

Reply via email to