[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: |
|
||||||||||||||||
| 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: |
| 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? |