NSPR Reference Previous Contents Next |
Chapter 16 String Operations
PL_strlen
PL_strcpy
PL_strdup
PL_strfree
PL_strlen
Returns the length of a specified string (not including the trailing'\0'
)
Syntax
PRUint32 PL_strlen(const char *str);
Parameter
This function has the following parameter:
str |
Size in bytes of item to be allocated.
|
Returns
If successful, the function returns length of the specified string.PL_strcpy
Copies a string, up to and including the trailing'\0'
, into a destination buffer.
Syntax
char * PL_strcpy(char *dest, const char *src);
Parameters
This function has the following parameters:
dest |
Pointer to a buffer. On output, the buffer contains a copy of the string
passed in src .
|
src |
Pointer to the string to be copied.
|
Returns
The function returns a pointer to the buffer specified by thedest
parameter.
Description
If the string specified bysrc
is longer than the buffer specified by dest
, the buffer
will not be null-terminated.
PL_strdup
Returns a pointer to a new memory node in the NSPR heap containing a copy of a specified string.Syntax
char *PL_strdup(const char *s);
Parameter
This function has the following parameter:
s |
Size in bytes of item to be allocated.
|
Returns
The function returns one of these values:
Description
To accommodate the terminator, the size of the allocated memory is one greater than the length of the string being copied. ANULL
argument, like a zero-length
argument, results in a pointer to a one-byte block of memory containing the null
value.
PL_strfree
Frees memory allocated byPL_strdup
.
Syntax
void PL_strfree(char *s);
Parameter
This function has the following parameter:
s |
Pointer to the string to be freed.
|
Last Updated May 18, 2001