<div dir="ltr"><div><div><div><div><div>Dear all,<br><br>I have trouble using foreign-free on win7 64bit.<br><br>My code:<br><br></div>C++:<br><br>int* gen(int n) {<br> int* x = new int[n];<br> for(int i = 0; i < n; i++) x[i] = i;<br>
return x;<br>}<br><br></div>LISP:<br><br>(defun gen-values (n)<br> (let* ((ret (cffi:foreign-funcall "gen" :int n :pointer)))<br> (dotimes (i n)<br> (format t "~A~%" (mem-ref (mem-aptr ret :int i) :int)))<br>
(foreign-free ret)))<br><br></div>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.<br>
<br></div>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.<br>
<br>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?<br><br>Thanks in advance.<br><br></div>- Rujia<br><br></div>