The STRDUP macro is a platform-independent substitute for the C library routine strdup. It creates a new copy of a string in the request’s memory pool.
The STRDUP routine is functionally equivalent to:
newstr = (char *) MALLOC(strlen(str) + 1); strcpy(newstr, str); |
A string created with STRDUP should be disposed with FREE.
char *STRDUP(char *ptr);
A pointer to the new string.
char *ptr is a pointer to a string.
char *name1 = "MyName";char *name2 = STRDUP(name1);
MALLOC, FREE, CALLOC, REALLOC, PERM_MALLOC, PERM_FREE, PERM_CALLOC, PERM_REALLOC, PERM_STRDUP