[Mono-dev] Marshalling (Segmentation fault)

Robert Jordan robertj at gmx.net
Thu Oct 11 08:22:23 EDT 2007


Hi,

> struct fgrab {
> 	int bufferlength;
> 	unsigned char *buffer[1000];
> } typedef fgrab_struct;
> 
 >
> int bufferlength = 0;
> unsigned char *buffer[1000];
> 
> extern SDL_mutex *mutex;
> 
> 
> fgrab_struct gbuffergrab() {
> 	fgrab_struct fgbuffer;
> 
> 	int index;
> 
> 	SDL_mutexP(mutex);
> 
> 	fgbuffer.bufferlength = bufferlength;
> 	//fgbuffer.buffer = buffer;
> 	for (index = 0; index < bufferlength; index++) {
> 		fgbuffer.buffer[index] = buffer[index];
> 	}
> 
> 	bufferlength = 0;
> 
> 	SDL_mutexV(mutex);
> 
> 	return fgbuffer;
> }


I don't see where you're allocating the buffer, so
I think that function simply doesn't work.

Are you sure you want "unsigned char *buffer[1000]"?
I guess it should be "unsigned char buffer[1000]".

Fix this first and the p/invoke will work as well.

Robert


Abir Bhattacharya wrote:
> The 'C' prototype :
> 
> 
> 
> #ifndef PICTURE_H
> #define PICTURE_H
> 
> #include "def.h"
> 
> 
> struct fgrab {
> 	int bufferlength;
> 	unsigned char *buffer[1000];
> } typedef fgrab_struct;
> 
> 
> fgrab_struct fbuffergrab();
> void fbufferflush(fgrab_struct fgbuffer);
> 
> #endif
> 
> -----Original Message-----
> From: mono-devel-list-bounces at lists.ximian.com
> [mailto:mono-devel-list-bounces at lists.ximian.com] On Behalf Of Robert Jordan
> Sent: Thursday, October 11, 2007 4:32 PM
> To: mono-devel-list at lists.ximian.com
> Subject: Re: [Mono-dev] Marshalling (Segmentation fault)
> 
> Abir Bhattacharya wrote:
>> [DllImport ("lib.so")]
>>
>> Private static extern ImgStruct gbuffergrab(); // gbuffergrab is the 'C'
>> method which returns type struct
> 
> Please post the C prototype as well.
> 
> Robert
> 
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
> 
> 
> 
> 
> -- Visit us at http://www.2pirad.com/ --




More information about the Mono-devel-list mailing list