The policy in BOINC is to minimize dynamic allocation and thus avoid
the complexity of pointer ownership.
We avoid functions that return pointers to allocated memory.
Exceptions to this should be clearly indicated in the function name,
e.g. read_file_malloc().
On 1/3/2017 7:13 AM, Christian Beer wrote:
On 03.01.2017 15:29, McLeod, John wrote:
What about the std::string function c_str? It returns a non-modifiable pointer
to the null terminated data in the string?
This function (std::string::c_str) provides a non-modifiable pointer and
the pointer is only valid as long as the string exists. So you can't use
the pointer outside of the context of the string. So the safe_copy()
function serves two purposes. It copies a string into a new char array
to make it modifiable and usable outside of the string context.
Another solution would be to only use strings and use c_str() locally
when it is needed and not pass around pointers to char arrays.
Regards
Christian
_______________________________________________
boinc_dev mailing list
[email protected]
http://lists.ssl.berkeley.edu/mailman/listinfo/boinc_dev
To unsubscribe, visit the above URL and
(near bottom of page) enter your email address.
_______________________________________________
boinc_dev mailing list
[email protected]
http://lists.ssl.berkeley.edu/mailman/listinfo/boinc_dev
To unsubscribe, visit the above URL and
(near bottom of page) enter your email address.