Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#886 double cast in generated code for Java constructor

closed-fixed
5
2008-03-12
2008-01-23
Hendrik Maryns
No

When wrapping a C struct, a default constructor without arguments is made. The corresponding C function looks like this:

SWIGEXPORT jlong JNICALL Java_package_ModuleJNI_new_1structName(JNIEnv *jenv, jclass jcls) {
jlong jresult = 0 ;
struct structName *result = 0 ;

(void)jenv;
(void)jcls;
result = (struct structName *)(struct structName *) calloc(1, sizeof(struct structName));
*(struct structName **)&jresult = result;
return jresult;
}

Note the double cast to (struct structName *). This is unnecessary.

Generated by e.g.

struct structName { int i; };

Discussion

  • William Fulton
    William Fulton
    2008-03-12

    Logged In: YES
    user_id=242951
    Originator: NO

    Applies to all languages. Fixed for swig-1.3.35.

     
  • William Fulton
    William Fulton
    2008-03-12

    • labels: 102868 --> code generation (general)
    • status: open --> closed-fixed