SWIG - python.exe crash

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Java and Swing

    #1

    SWIG - python.exe crash

    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_D IGIT digits[]) {
    ....
    }

    char* GetString(char *inMessage, MY_DIGIT *digit) {
    char *results;
    ...
    ...
    return results;
    }


    MyApp.i
    ------------------------------------------------------------------------------------------------------
    %module MyApp
    %{
    #include "math.h"
    %}

    extern void MakeDigits(MY_D IGIT 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(digi ts)

    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.

Working...