Skip to content

Commit 42ecaed

Browse files
author
Christian Hergert
committed
examples: simplify cursor iteration in example-client.
1 parent d0e54c2 commit 42ecaed

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

examples/example-client.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,10 @@ main (int argc,
5353
NULL, /* Fields, NULL for all. */
5454
NULL); /* Read Prefs, NULL for default */
5555

56-
while (!mongoc_cursor_error (cursor, &error) &&
57-
mongoc_cursor_more (cursor)) {
58-
if (mongoc_cursor_next (cursor, &doc)) {
59-
str = bson_as_json (doc, NULL);
60-
fprintf (stdout, "%s\n", str);
61-
bson_free (str);
62-
}
56+
while (mongoc_cursor_next (cursor, &doc)) {
57+
str = bson_as_json (doc, NULL);
58+
fprintf (stdout, "%s\n", str);
59+
bson_free (str);
6360
}
6461

6562
if (mongoc_cursor_error (cursor, &error)) {

0 commit comments

Comments
 (0)