Use the Type() ctor and avoid:
- clang warning about memset overwrite of vtable - memory leak - Undefined behavior in Type copy/move operations and dtor.
This commit is contained in:
parent
74345c92e4
commit
6c0885ff67
1 changed files with 2 additions and 3 deletions
|
|
@ -134,13 +134,12 @@ namespace swig {
|
||||||
return *v;
|
return *v;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Uninitialized return value, no Type() constructor required.
|
static Type v_def;
|
||||||
static Type *v_def = (Type*) calloc(1, sizeof(Type)); // memory leak?
|
|
||||||
if (!PyErr_Occurred()) {
|
if (!PyErr_Occurred()) {
|
||||||
%type_error(swig::type_name<Type>());
|
%type_error(swig::type_name<Type>());
|
||||||
}
|
}
|
||||||
if (throw_error) throw std::invalid_argument("bad type");
|
if (throw_error) throw std::invalid_argument("bad type");
|
||||||
return *v_def;
|
return v_def;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue