[CDRIVER-2360] decimal128 and regex functions that accept string lengths Created: 10/Nov/17  Updated: 28/Oct/23  Resolved: 26/Dec/17

Status: Closed
Project: C Driver
Component/s: libbson
Affects Version/s: None
Fix Version/s: 1.10.0

Type: Improvement Priority: Minor - P4
Reporter: Andrew Morrow (Inactive) Assignee: Xiangyu Yao (Inactive)
Resolution: Fixed Votes: 0
Labels: ext
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by CXX-1501 Use bson_append...w_len functions whe... Closed
Related
related to CDRIVER-2414 bson_iter{_init}_find should have len... Closed
Backwards Compatibility: Fully Compatible

 Description   

There are still a few functions that only take raw char* pointers to null terminated buffers. This makes it hard for the C++ driver, since it often deals in string_views that aren't ensured to be null terminated. In those instances, we must construct a temporary std::string (with the associated heap allocation) from our string_view, and then pass those into the C driver, which then calls strlen on it.

A few functions known to have this issue, notably the bson_append family functions for dbpointer, code, codewscope, and regex. It also appears that the decimal128_[to,from]_string functions have this issue.

While it may not make sense to address this for the deprecated types, fixing it for at least regex and decimals seems worthwhile.



 Comments   
Comment by Githook User [ 14/Dec/17 ]

Author:

{'name': 'Xiangyu Yao', 'email': 'xiangyu.yao24@gmail.com', 'username': 'xy24'}

Message: CDRIVER-2360 add bson_[append_regex/decimal128_from_string]_w_len
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/28f5a2fb109a405ac068f16337b40f1073ad2d2d

Comment by A. Jesse Jiryu Davis [ 13/Dec/17 ]

You're right, that was my mistake. We need bson_decimal128_from_string_w_len() but we don't need bson_decimal128_to_string_w_len().

Comment by Xiangyu Yao (Inactive) [ 13/Dec/17 ]

jesse Why do we want to make bson_decimal128_to_string_w_len() since the string here is an output rather than an input?

Generated at Wed Feb 07 21:14:59 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.