- strdup uses malloc and standard C++ allocation uses 'new' - you should use std::string instead of C string functions string s1 = pszAnyString; // get a copy of char array string s2 = s1; // get a second copy using reference counting char buf[1024]; int l = dllFunction(s2.c_str(), buf, sizeof(buf)); // pass a string as a const char pointer

C string handling - Wikipedia The C programming language has a set of functions implementing operations on strings (character strings and byte strings) in its standard library.Various operations, such as copying, concatenation, tokenization and searching are supported. For character strings, the standard library uses the convention that strings are null-terminated: a string of n characters is represented as an array of n memory leak at strdup! what do I free? | Yahoo Answers Feb 19, 2010 Difference between strdup() and strcpy()

The strdup() function allocates sufficient memory for a copy of the string s1, does the copy, and returns a pointer to it. The pointer may subsequently be used as an …

g_strdup_vprintf () gchar * g_strdup_vprintf (const gchar *format, va_list args); Similar to the standard C vsprintf() function but safer, since it calculates the maximum space required and allocates memory to hold the result. The returned string should be freed with g_free() when no longer needed.

The strdup() function appears at Line 10. It’s format uses the original string as the only argument. The duplicate is returned, or the NULL pointer in case of failure. The output for the above code is the same as for the first example. Both strcpy() and strdup() have sisters that …

strdup(), strndup(), strdupa(), strndupa() The strdup() function returns a pointer to a new string that is a duplicate of the string pointed to by s. The returned pointer can be passed to free(). The space for the new string is obtained using malloc(3C). z_fatal_error missing log_strdup · Issue #18052 This needs further design work due to problems with logging C strings. Just send always to printk() for now until this is resolved. Fixes: zephyrproject-rtos#18052 Signed-off-by: Andrew Boie