Sun Java System Web Server 6.1 SP7 NSAPI Programmer's Guide

STRDUP

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.

Syntax

char *STRDUP(char *ptr);

Returns

A pointer to the new string.

Parameters

char *ptr is a pointer to a string.

Example

char *name1 = "MyName";char *name2 = STRDUP(name1);

See Also

MALLOC, FREE, CALLOC, REALLOC, PERM_MALLOC, PERM_FREE, PERM_CALLOC, PERM_REALLOC, PERM_STRDUP