On Fri, Mar 14, 2008 at 08:34:48 +0000, Jules Bean wrote: > But it doesn't segfault :(
:-/ Well, at least this means it might be something we can fix. > void createAndGetPixels() { > wxImage *im = new wxImage(256,256); > unsigned char* pixels = im->GetData(); > std::cout << "pixels : " << ((void*)pixels) << std::endl; > void *bytes = malloc(256*256*3); > memcpy(bytes,pixels,256*256*3); > //free(bytes); > //delete im; I modified the wxc wrapper so that it copies the contents of the array into a whole new one... and that stops the segfaulting. It doesn't explain very much (to me), though, and the whole introducing a memory leak thing may not be so much fun. EWXWEXPORT(void*, wxImage_GetData)(void* _obj) { int w = ((wxImage*)_obj)->GetWidth(); int h = ((wxImage*)_obj)->GetHeight(); void *bytes = malloc(h*w*3); void *pixels = ((wxImage*)_obj)->GetData(); memcpy(bytes,pixels,h*w*3); return (void*)bytes; } I have honestly no idea what's going on here. -- Eric Kow <http://www.nltg.brighton.ac.uk/home/Eric.Kow> PGP Key ID: 08AC04F9
pgptLUz3ZXZIH.pgp
Description: PGP signature
------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________ wxhaskell-users mailing list wxhaskell-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wxhaskell-users