_getcwd_dbg, _wgetcwd_dbg
The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.
The latest version of this topic can be found at _getcwd_dbg, _wgetcwd_dbg.
Debug versions of the _getcwd, _wgetcwd functions (only available during debug).
Syntax
char *_getcwd_dbg(
char *buffer,
int maxlen,
int blockType,
const char *filename,
int linenumber
);
wchar_t *_wgetcwd_dbg(
wchar_t *buffer,
int maxlen,
int blockType,
const char *filename,
int linenumber
);
Parameters
buffer
Storage location for the path.
maxlen
Maximum length of the path in characters: char
for _getcwd_dbg
and wchar_t
for _wgetcwd_dbg
.
blockType
Requested type of the memory block: _CLIENT_BLOCK
or _NORMAL_BLOCK
.
filename
Pointer to the name of the source file that requested the allocation operation or NULL
.
linenumber
Line number in the source file where the allocation operation was requested or NULL
.
Return Value
Returns a pointer to buffer
. A NULL
return value indicates an error, and errno
is set either to ENOMEM
, indicating that there is insufficient memory to allocate maxlen
bytes (when a NULL
argument is given as buffer
), or to ERANGE
, indicating that the path is longer than maxlen
characters.
For more information, see errno, _doserrno, _sys_errlist, and _sys_nerr.
Remarks
The _getcwd_dbg
and _wgetcwd_dbg
functions are identical to _getcwd
and _wgetcwd
except that, when _DEBUG
is defined, these functions use the debug version of malloc
and _malloc_dbg
to allocate memory if NULL
is passed as the first parameter. For more information, see _malloc_dbg.
You do not need to call these functions explicitly in most cases. Instead, you can define the _CRTDBG_MAP_ALLOC
flag. When _CRTDBG_MAP_ALLOC
is defined, calls to _getcwd
and _wgetcwd
are remapped to _getcwd_dbg
and _wgetcwd_dbg
, respectively, with the blockType
set to _NORMAL_BLOCK
. Thus, you do not need to call these functions explicitly unless you want to mark the heap blocks as _CLIENT_BLOCK
. For more information, see Types of blocks on the debug heap.
Generic-Text Routine Mappings
Tchar.h routine | _UNICODE and _MBCS not defined | _MBCS defined | _UNICODE defined |
---|---|---|---|
_tgetcwd_dbg |
_getcwd_dbg |
_getcwd_dbg |
_wgetcwd_dbg |
Requirements
Routine | Required header |
---|---|
_getcwd_dbg |
<crtdbg.h> |
_wgetcwd_dbg |
<crtdbg.h> |
For more compatibility information, see Compatibility in the Introduction.
.NET Framework Equivalent
See Also
_getcwd, _wgetcwd
Directory Control
Debug Versions of Heap Allocation Functions