#include #include int main (int argc, char *argv[]) { const char *uri_string = "mongodb://localhost:27017"; const char *db_name = "db_name"; const char *collection_name = "coll_name"; mongoc_uri_t *uri; mongoc_client_t *client; bson_t *command, reply; bson_error_t error; mongoc_cursor_t *cursor; mongoc_init (); uri = mongoc_uri_new_with_error (uri_string, &error); client = mongoc_client_new_from_uri (uri); command = BCON_NEW ("find", collection_name); mongoc_client_command_with_opts(client, db_name, command, NULL, NULL, &reply, &error); cursor = mongoc_cursor_new_from_command_reply_with_opts(client, &reply, NULL); printf("Trying to destroy the cursor\n"); mongoc_cursor_destroy(cursor); printf("The cursor was destroyed\n"); bson_destroy(command); mongoc_uri_destroy (uri); mongoc_client_destroy (client); mongoc_cleanup (); return EXIT_SUCCESS; }