Menu

mgl_data_create causes SEGFAULT

Anonymous
2013-12-16
2013-12-17
  • Anonymous

    Anonymous - 2013-12-16

    The following example code:

    include<mgl2 mgl_cf.h="">

    int main(int argc,char **argv)
    {
    HMDT y;
    mgl_data_create(y,50,1,1); //segmentation fault occurs
    return EXIT_SUCCESS;
    }


    causes segmentation fault (mathgl 1.11 and mathgl 2.2). Using data creation in c++ gives
    no error. Linux Mint 15, gcc 4.7, 64-bit. Am I doing something wrong in data initialization in c ? Does anyone uses mathgl from c ?

     
  • Alexey Balakin

    Alexey Balakin - 2013-12-17

    Yes, it should. You try to change the variable ("y") which is not yet allocated. The correct calls should be

    HMDT y;
    y = mgl_create_data_size(50,1,1);
    ...
    mgl_delete_data(y);
    

    or

    HMDT y;
    y = mgl_create_data();
    mgl_data_create(y,50,1,1);
    ...
    mgl_delete_data(y);
    
     

Anonymous
Anonymous

Add attachments
Cancel