diff --git a/native_client/ctcdecode/swigwrapper.i b/native_client/ctcdecode/swigwrapper.i index 64ed5f5a..ab5675be 100644 --- a/native_client/ctcdecode/swigwrapper.i +++ b/native_client/ctcdecode/swigwrapper.i @@ -43,7 +43,13 @@ namespace std { %template(OutputVectorVector) std::vector>; // Import only the error code enum definitions from deepspeech.h -%ignore ""; -%rename("%s", regexmatch$name="DS_ERR_") ""; -%rename("%s", regexmatch$name="DeepSpeech_Error_Codes") ""; +// We can't just do |%ignore "";| here because it affects this file globally (even +// files %include'd above). That causes SWIG to lose destructor information and +// leads to leaks of the wrapper objects. +// Instead we ignore functions and classes (structs), which are the only other +// things in deepspeech.h. If we add some new construct to deepspeech.h we need +// to update the ignore rules here to avoid exposing unwanted APIs in the decoder +// package. +%rename("$ignore", %$isfunction) ""; +%rename("$ignore", %$isclass) ""; %include "../deepspeech.h"