Copies a string from src to dest, where these strings may be NULL or allocated, and (*dest) will result in a NULL or will be allocated to fit the src string.
- If (*dest) is NULL, it will malloc'd to an appropriate size to contain the string in src.
- If (*dest) is non-NULL, it will be realloc'd to an appropriate size to contain the string in src.
- If src is NULL, then (*dest) will be freed and made NULL (or dest will remain NULL if it is already NULL.
- Parameters
-
[in] | src | The source string. May be NULL, or it may be a previously-allocated string, or a string literal. If it is a string, it must be null-terminated. |
[in,out] | dest | Pointer to the destination char*. The char* may be NULL, or it may be a previously-allocated string. If it is a string, it must be null-terminated upon entry. Upon exit, the char* pointed to by dest is guaranteed to be either NULL or null-terminated. If the char* pointed to by dest is not NULL on exit, then the caller is responsible for freeing it. |
- Returns
- MPA_SUCCESS on success MPA_NULL_POINTER_ERR if the dest double-pointer is NULL. MPA_OUT_OF_MEMORY_ERR if memory could not be allocated for dest