R_mongo_collection_find leaks memory as mongoc_read_prefs_new(MONGOC_READ_PRIMARY) is not cleaned up.
Anyway, MONGOC_READ_PRIMARY is the default (http://mongoc.org/libmongoc/current/mongoc_read_prefs_t.html).
This patch avoids the leakage by not allocating the memory in the first place but instead using NULL for mongoc_collection_find_with_opts to use the default values.
R_mongo_collection_find
leaks memory asmongoc_read_prefs_new(MONGOC_READ_PRIMARY)
is not cleaned up. Anyway,MONGOC_READ_PRIMARY
is the default (http://mongoc.org/libmongoc/current/mongoc_read_prefs_t.html). This patch avoids the leakage by not allocating the memory in the first place but instead usingNULL
formongoc_collection_find_with_opts
to use the default values.