Re: Problems with FFI
Chris Double <[email protected]> Tue, 8 Apr 2003 00:06:36 +1200
| Newsgroups | gmane.lisp.corman |
|---|---|
| Organization | none |
| Message-ID | <[email protected]> |
I don't have Corman Lisp handy to run so the following comments are untested, but I'm pretty sure their right. > } OPENFILENAME, *LPOPENFILENAME; There are two types defined here. One is OPENFILENAME which will have the size of the structure. The other is LPOPENFILENAME which is a pointer type and is only of the size of the pointer. > (let ((lpOFN (malloc (sizeof 'LPOPENFILENAME)))) Here you are mallocing a size of the pointer type. I think this should be (sizeof 'OPENFILENAME). What do (sizeof 'OPENFILENAME) and (sizeof 'LPOPENFILENAME) return? > (with-c-struct (strct lpOFN OPENFILENAME) You are offsetting into the memory allocated as if it was a fully allocated OPENFILENAME, but it is only a few bytes big. You will be overwriting memory here. Fix the malloc above it and this should be fine. > lpstrFile (malloc (* (sizeof 'LPTSTR) 260)) Here you probably mean to allocate a string of 260 characteres. (malloc 260) would be sufficient. I believe what you are actually saying here is malloc something 260 * the sizeof a pointer (again that LP indicates a pointer type). So you are allocating more than needed, not really a problem. > nMaxFile 260 This indicates you really did want (malloc 260) before. Try those fixes and see how things go. Chris. ------------------------ Yahoo! Groups Sponsor ---------------------~--> Get 128 Bit SSL Encryption! http://us.click.yahoo.com/xaxhjB/hdqFAA/VygGAA/SyjtlB/TM ---------------------------------------------------------------------~-> To unsubscribe from this group, send an email to: [email protected] Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/