Skip to content

Commit 846c115

Browse files
authored
CDRIVER-1541 add const to return of mongoc_server_description_host (#1915)
1 parent a5fbace commit 846c115

File tree

5 files changed

+11
-9
lines changed

5 files changed

+11
-9
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Unreleased (2.0.0)
77
now applies `batchSize:0` to the `aggregate` command. Useful to request an immediate cursor. Previously the value
88
was ignored.
99
* `bson_oid_init_sequence` is removed. Use `bson_oid_init` instead.
10+
* `mongoc_server_description_host` changes the return type from `mongoc_host_list_t *` to `const mongoc_host_list_t *`.
1011

1112
## Removals
1213

src/libmongoc/doc/mongoc_server_description_host.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Synopsis
88

99
.. code-block:: c
1010
11-
mongoc_host_list_t *
11+
const mongoc_host_list_t *
1212
mongoc_server_description_host (const mongoc_server_description_t *description);
1313
1414
Parameters
@@ -24,5 +24,7 @@ Return the server's host and port. This object is owned by the server descriptio
2424
Returns
2525
-------
2626

27-
A reference to the server description's :symbol:`mongoc_host_list_t`, which you must not modify or free.
27+
.. versionchanged:: 2.0.0 The return type changed from ``mongoc_host_list_t *`` to ``const mongoc_host_list_t *``.
28+
29+
A reference to the server description's :symbol:`mongoc_host_list_t`.
2830

src/libmongoc/src/mongoc/mongoc-server-description.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,13 +287,12 @@ mongoc_server_description_id (const mongoc_server_description_t *description)
287287
* Return a reference to the host associated with this server description.
288288
*
289289
* Returns:
290-
* This server description's host, a mongoc_host_list_t * you must
291-
* not modify or free.
290+
* This server description's host, a const mongoc_host_list_t *.
292291
*
293292
*--------------------------------------------------------------------------
294293
*/
295294

296-
mongoc_host_list_t *
295+
const mongoc_host_list_t *
297296
mongoc_server_description_host (const mongoc_server_description_t *description)
298297
{
299298
return &((mongoc_server_description_t *) description)->host;

src/libmongoc/src/mongoc/mongoc-server-description.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ mongoc_server_description_new_copy (const mongoc_server_description_t *descripti
3838
MONGOC_EXPORT (uint32_t)
3939
mongoc_server_description_id (const mongoc_server_description_t *description);
4040

41-
MONGOC_EXPORT (mongoc_host_list_t *)
41+
MONGOC_EXPORT (const mongoc_host_list_t *)
4242
mongoc_server_description_host (const mongoc_server_description_t *description);
4343

4444
MONGOC_EXPORT (int64_t)

src/libmongoc/tests/test-mongoc-sdam.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ test_topology_discovery (void *ctx)
533533
mongoc_client_t *client;
534534
mongoc_read_prefs_t *prefs;
535535
mongoc_server_description_t *sd_secondary;
536-
mongoc_host_list_t *hl_secondary;
536+
const mongoc_host_list_t *hl_secondary;
537537
mongoc_collection_t *collection;
538538
bson_t doc = BSON_INITIALIZER;
539539
bson_t reply;
@@ -597,7 +597,7 @@ test_direct_connection (void *ctx)
597597
mongoc_client_t *client;
598598
mongoc_read_prefs_t *prefs;
599599
mongoc_server_description_t *sd_secondary;
600-
mongoc_host_list_t *hl_secondary;
600+
const mongoc_host_list_t *hl_secondary;
601601
mongoc_collection_t *collection;
602602
bson_t doc = BSON_INITIALIZER;
603603
bson_t reply;
@@ -662,7 +662,7 @@ test_existing_behavior (void *ctx)
662662
mongoc_client_t *client;
663663
mongoc_read_prefs_t *prefs;
664664
mongoc_server_description_t *sd_secondary;
665-
mongoc_host_list_t *hl_secondary;
665+
const mongoc_host_list_t *hl_secondary;
666666
mongoc_collection_t *collection;
667667
bson_t doc = BSON_INITIALIZER;
668668
bson_t reply;

0 commit comments

Comments
 (0)