## [Swig-user] Re: double pointer problem

 [Swig-user] Re: double pointer problem From: Marcelo Matus - 2005-10-28 08:18:43 ```Given that int build(objid **pid) { pid[0]->val = 10; pid[0]->wt =20; return 1; } is expecting an array ob aobjid, you need to provide an array of pointer. look at the carray.i and cpointer.i if you can get any solution or ideas from them, and/or write a method that create the array for you, ie, something like objid **new_objid_parray(int n) { objid **res = (objid **)malloc(sizeof(objid*)*(n+1)); for (int i =0; i < n; ++i) { res[i] = malloc(sizeof(objid)); } res[i] = 0; return res; } void delete_objid_parray(objid **parray) { for (...) ... free(parray); } in in python use it as t1 = mymod.new_obid_parray(1) mymod.build(t1) ... delete_obid_parray(t1) but again, take a look first at carray.i and cpointer.i for ready to use solutions. Marcelo ```

 [Swig-user] Re: double pointer problem From: Marcelo Matus - 2005-10-28 08:18:43 ```Given that int build(objid **pid) { pid[0]->val = 10; pid[0]->wt =20; return 1; } is expecting an array ob aobjid, you need to provide an array of pointer. look at the carray.i and cpointer.i if you can get any solution or ideas from them, and/or write a method that create the array for you, ie, something like objid **new_objid_parray(int n) { objid **res = (objid **)malloc(sizeof(objid*)*(n+1)); for (int i =0; i < n; ++i) { res[i] = malloc(sizeof(objid)); } res[i] = 0; return res; } void delete_objid_parray(objid **parray) { for (...) ... free(parray); } in in python use it as t1 = mymod.new_obid_parray(1) mymod.build(t1) ... delete_obid_parray(t1) but again, take a look first at carray.i and cpointer.i for ready to use solutions. Marcelo ```