mkusner / wmd

Word Mover's Distance from Matthew J Kusner's paper "From Word Embeddings to Document Distances"
537 stars 132 forks source link

memory leak #5

Open gitforhf opened 7 years ago

gitforhf commented 7 years ago

in emd.i


%typemap(freearg) signature_t * {
    if ($1 != NULL) {
        PyObject **features_array = (PyObject **) $1->Features;
        int weights_count = (int)$1->n;
        int i = 0;
        for (i = 0; i < weights_count; ++i) {
            Py_XDECREF(features_array[i]);
        }
        free((PyObject **) $1->Features);
        free((float *) $1->Weights);
        free((signature_t *) $1);
    }
}