1
0
Fork 0

fix memleak

This commit is contained in:
jsteemann 2016-12-19 21:41:29 +01:00
parent 27e4b170cf
commit bd6d48760c
2 changed files with 14 additions and 2 deletions

View File

@ -106,13 +106,13 @@ void GeoIndexIterator::nextBabies(std::vector<IndexLookupResult>& result, size_t
result.clear(); result.clear();
if (batchSize > 0) { if (batchSize > 0) {
auto coords = std::unique_ptr<GeoCoordinates>(::GeoIndex_ReadCursor(_cursor,batchSize)); auto coords = std::unique_ptr<GeoCoordinates>(::GeoIndex_ReadCursor(_cursor,batchSize));
size_t length = coords ? coords->length : 0; size_t length = coords ? coords->length : 0;
//LOG_TOPIC(DEBUG, Logger::DEVEL) << "length " << length; //LOG_TOPIC(DEBUG, Logger::DEVEL) << "length " << length;
if (!length){ if (!length) {
return; return;
} }
for(std::size_t index = 0; index < length; ++index){ for(std::size_t index = 0; index < length; ++index){
//LOG_TOPIC(DEBUG, Logger::DEVEL) << "near " << _near << " max allowed range: " << _withinRange //LOG_TOPIC(DEBUG, Logger::DEVEL) << "near " << _near << " max allowed range: " << _withinRange
// << " actual range: " << GeoIndex_distance(&_coor, &coords->coordinates[index]) ; // << " actual range: " << GeoIndex_distance(&_coor, &coords->coordinates[index]) ;

View File

@ -180,4 +180,16 @@ friend class GeoIndexIterator;
}; };
} }
namespace std {
template <>
class default_delete<GeoCoordinates> {
public:
void operator()(GeoCoordinates* result) {
if (result != nullptr) {
GeoIndex_CoordinatesFree(result);
}
}
};
}
#endif #endif