When I try to print an object in Python, python.exe crashes. Below are my files.
defs.h ------------------------------------------------------------------------------------------------------ typedef unsigned long MY_DIGIT; myapp.c ------------------------------------------------------------------------------------------------------ void MakeDigits(MY_DIGIT digits[]) { .... } char* GetString(char *inMessage, MY_DIGIT *digit) { char *results; ... ... return results; } MyApp.i ------------------------------------------------------------------------------------------------------ %module MyApp %{ #include "math.h" %} extern void MakeDigits(MY_DIGIT digits[]); extern char* GetString(char *inMessage, MY_DIGIT *digit); /* allows for the creation of a MY_DIGIT array */ %inline %{ MY_DIGIT *my_digit_array(int size) { return (MY_DIGIT *) malloc(size * sizeof(int)); } %} ...I have two questions. 1) One, I call MakeDigits which should populate the "digits" array with some values. It seems the first time I try it the digits array is populated. Then if I try to re-use the digits array i get some garbage output. But if I recall MakeDigits...I can then re-use the digits array over and over without anymore problems? Any idea? here is how I was trying it... digits = my_digit_array(10) MakeDigits(digits) 2) When I try to print the "my_digit_array" object, python.exe crashes...below is the code I use to cause this problem: (within python) digits = my_digit_array(10) print digits I am using Python 2.4.1, Swig 1.3.25 on Win XP Pro. I tried sending a message on the SWIG mailing list...but so far it hasn't shown up on the list...I've sent it three times now. I'll keep trying. -- http://mail.python.org/mailman/listinfo/python-list