[cffi-devel] possible foreign-free bug
    Martin Simmons 
    martin at lispworks.com
       
    Tue Nov 12 16:55:17 UTC 2013
    
    
  
>>>>> On Mon, 11 Nov 2013 11:29:23 -0800 (PST), Joeish W said:
> 
> (defun get-cols-example ()
>   (let* ((matrix (create-mat 5 7 +8uc1+))
>      (submat (foreign-alloc `(:struct cv-mat)
>                 :initial-contents '())))
>    (get-cols matrix submat 0 3)
>     (foreign-free submat)))
> 
> when i run the above code with the (get-cols matrix submat 0 3) line 
> commented or without foreign-free  it runs fine but as it is above i get below error 
What are you trying to achieve by using :initial-contents '() in
foreign-alloc?  It is wrong because it causes foreign-alloc to make an array
of 0 elements.
Also, assuming you don't return submat, then it looks like you should be using
with-foreign-object here, rather than foreign-alloc and foreign-free.
__Martin
    
    
More information about the cffi-devel
mailing list