Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
strdup Functions
◄Summary► ◄Example► ◄Up► ◄Contents► ◄Index► ◄Back►
────────────────────────────────────────────────────────────────────────────
The strdup family of functions operates on null-terminated
strings. The <string> arguments to these functions are expected to
contain a null character (\0) marking the end of the string.
The strdup function allocates storage space (with a call to
malloc) for a copy of <string>, and returns a pointer to the
storage space containing the copied string. The function returns
NULL if storage cannot be allocated.
The _fstrdup and _nstrdup functions provide complete control over
the heap used for string duplication. The regular strdup function
returns a pointer to a copy of the <string> argument. The space
for the string is allocated from the heap specified by the memory
model in use. In large data models (that is, compact-, large-, and
huge-model programs), strdup allocates space from the far heap. In
small data models (tiny-, small-, and medium-model programs),
strdup allocates space from the near heap.
The _fstrdup function returns a pointer to a copy of the string
allocated in far memory (the far heap), and _nstrdup allocates
space for the copy from the near heap.
The _f... forms of these functions are model-independent (large-
model) forms that use far pointer forms of the string arguments
and return values. These model-independent functions can be called
from any point in the program.
Return Value
The return values for these functions are described above.
-♦-