int *result, float *distances){ vector<int> resultV; vector<float> distancesV; ptr->get_nns_by_item(item, n, search_k, &resultV, &distancesV); std::copy(resultV.begin(), resultV.end(), result); std::copy(distancesV.begin(), distancesV.end(), distances); } val result = Array.fill(10)(-1) val distances = Array.fill(10)(-1.0f) lib.getNnsByItem(annoy, item, 10, -1, result, distances) under GC's control free automatically