Programming Guide |
Allocate memory and copy a string to that memory
char *sm_strdup(char *string);
- string
- The string to be duplicated.
- . · The value returned by sm_
fmalloc
.
- · the null pointer if string is the null pointer or if the call to
sm_fmalloc
failed.
.If string is not the null pointer, its length is found, sm_fmalloc is called and if it did not return the null pointer, string is copied to the allocated memory. Memory allocated by calling sm_strdup should be freed by calling sm_ffree.