"News Wombat" <newswom...@gmail.com> wrote in message
news:2abdd9b3-66ec-4125-a5f8-41315008c...@l17g2000yqe.googlegroups.com...
Hi everyone,
I've been experimenting with the ctypes module and think it's great.
I'm hitting a few snags though with seg faults. I attached two links
that holds the code. The line i'm having problems with is this,
sn=clibsmi.smiGetNextNode(pointer(sno),SMI_NODEKIND_ANY)
It will work one time, and if I call it again with the result of the
previous, even though the result (a c struct) looks ok, it will
segfault. I think it's a problem with pointers or maybe the function
in the c library trying to change a string that python won't let it
change. I'm stuck, any tips would be appreciated. Thanks, and Merry
Christmas!
constants.py: http://pastebin.com/HvngjzZN
libsmi.py: http://pastebin.com/19C9kYEa
Well, I can't run your code, but I think you should pass the original "sn"
pointer from smiGetNode() and not a pointer(sno). The values are not the
same and the library probably relies on passing the original pointer back
into smiGetNextNode. sn.contents returns a new SmiNode object so its
pointer will be different.
-Mark
--
http://mail.python.org/mailman/listinfo/python-list