add utils::strdup() convenience function

This commit is contained in:
Axel Kohlmeyer
2021-02-04 15:35:43 -05:00
parent f5bf10e00f
commit 0f07215a2b
4 changed files with 41 additions and 0 deletions

View File

@ -195,6 +195,17 @@ namespace LAMMPS_NS {
int expand_args(const char *file, int line, int narg, char **arg,
int mode, char **&earg, LAMMPS *lmp);
/** Make C-style copy of string in new storage
*
* This allocates a storage buffer and copies the C-style or
* C++ style string into it. The buffer is allocated with "new"
* and thus needs to be deallocated with "delete[]".
*
* \param text string that should be copied
* \return new buffer with copy of string */
char *strdup(const std::string &text);
/** Trim leading and trailing whitespace. Like TRIM() in Fortran.
*
* \param line string that should be trimmed