Hi,

I don't understand why my loop crashes,

Here is my grovel definition for ifaddrs struct:

(cstruct ifaddrs "struct ifaddrs"
         (next "ifa_next" :type :pointer)
         (name "ifa_name" :type :string)
         (flags "ifa_flags" :type :unsigned-int)
         (address "ifa_addr" :type :pointer)
         (netmask "ifa_netmask" :type :pointer)
         (broadcast "ifa_broadaddr" :type :pointer)
         (point-to-point-destination "ifa_dstaddr" :type :pointer)
         (data "ifa_data" :type :pointer))

Here is my loop, i was expecting next to be a null pointer after the first
vmnet8

CL-USER>  (cffi:with-foreign-object (p
:pointer)

           (getifaddrs
p)

           (do
()

               ((cffi:null-pointer-p
p))

             (format t "Interface: ~a~%" (cffi:foreign-slot-value
(cffi:mem-ref p :pointer) 'ifaddrs
'name))
             (setf p (cffi:foreign-slot-value p 'ifaddrs 'next))))
Interface:
lo

Interface:
sit0

Interface:
eth0

Interface:
wlan0

Interface:
vmnet1

Interface:
vmnet8

Interface:
lo

Interface:
wlan0

Interface:
vmnet1

Interface:
vmnet8

Interface:
lo

Interface:
wlan0

Interface:
vmnet1

Interface:
vmnet8

; Evaluation aborted on #<SB-SYS:MEMORY-FAULT-ERROR {BF604E1}>.

Regards,
Jose
_______________________________________________
cffi-devel mailing list
cffi-devel@common-lisp.net
http://common-lisp.net/cgi-bin/mailman/listinfo/cffi-devel

Reply via email to