[CDRIVER-1449] Refactor mongoc-metadata get_os_* functions to not use strndup Created: 04/Aug/16 Updated: 03/May/17 Resolved: 05/Jan/17 |
|
| Status: | Closed |
| Project: | C Driver |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | TBD |
| Type: | Improvement | Priority: | Minor - P4 |
| Reporter: | Ian Boros | Assignee: | Backlog - C Driver Team |
| Resolution: | Won't Fix | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Epic Link: | mongodb-handshake |
| Description |
|
We follow a sort of ugly pattern in mongoc-metadata.c all of the get_os* functions (like _get_os_name or _get_os_arch) return a malloc'd string. A better pattern would be to have the caller pass in a buffer (and max size) and the function can just copy the string into that buffer. |
| Comments |
| Comment by A. Jesse Jiryu Davis [ 05/Jan/17 ] |
|
This is in one of the least performance-intensive code paths of the driver; it's executed once per mongoc_topology_scanner_t. |