using foreign-free on Win7 64-bit
Rujia Liu
rujia.liu at gmail.com
Wed Sep 25 12:32:14 UTC 2013
Dear all,
I have trouble using foreign-free on win7 64bit.
My code:
C++:
int* gen(int n) {
int* x = new int[n];
for(int i = 0; i < n; i++) x[i] = i;
return x;
}
LISP:
(defun gen-values (n)
(let* ((ret (cffi:foreign-funcall "gen" :int n :pointer)))
(dotimes (i n)
(format t "~A~%" (mem-ref (mem-aptr ret :int i) :int)))
(foreign-free ret)))
It works well on windows XP (32bit), but crashes on (foreign-free ret).
SBCL win32 just crashes the process, while CCL win32 dropped me into kernel
debugger. The topmost frame is a call to FREE.
Our customers use both 32-bit and 64-bit systems, so I'd like to provide a
single exe that runs on both 32-bit and 64-bits. Our dev machine is running
a 32-bit Windows XP, uses VS2008 to compile to C++ library to DLL.
After I commented out (foreign-free), the exe runs perfectly on both 32-bit
and 64-bit, but there are memory leaks. Am I doing anything wrong?
Thanks in advance.
- Rujia
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/cffi-devel/attachments/20130925/3ae2c396/attachment.html>
More information about the cffi-devel
mailing list