For the record, strdup() is *not* standard, it is a GNU extension and not part of ANSI/ISO C.
When it comes to bigger picture, I'd say scrapping pure char arrays in favour of std::string is long overdue. The dynamic allocation argument against string is shadowed by all kinds of bugs related to C arrays. Moreover, there are other ways to cut CPU cycles besides shunning string (memoization comes to mind). Artem В Вт, 03/01/2017 в 22:13 +0200, Juha Sointusalo пишет: > On 3 January 2017 at 17:13, Christian Beer <[email protected] > > > wrote: > > > 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. > > > > Putting aside the bigger issues for a moment. The next time you need > a copy > of a C string just use strdup(). It's standard and everybody knows it > allocates memory that needs to be free()d. > > -Juha > _______________________________________________ > 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.
