[lldb][NFC] Remove unused custom reimplementation of realpath for Windows

No one is calling this function it seems and according to
https://bugs.llvm.org/show_bug.cgi?id=47088 this can leak memory, so let's just
remove it:

Quote from the bug report:
> Before return on line 146, the memory allocated on line 130 is not freed.

Reviewed By: amccarth

Differential Revision: https://reviews.llvm.org/D85633
This commit is contained in:
Raphael Isemann committed 2020-08-11 10:04:42 +02:00
1 parent 8f92f3c2ea
commit 51117e3c51
2 files changed
-84

No files matched your search

@@ -98,7 +98,6 @@ typedef uint32_t pid_t;
// custom implementations.
int vasprintf(char **ret, const char *fmt, va_list ap);
char *strcasestr(const char *s, const char *find);
char *realpath(const char *name, char *resolved);
#ifdef _MSC_VER
-83
View File
@@ -82,89 +82,6 @@ char *strcasestr(const char *s, const char *find) {
return const_cast<char *>(s);
}
char *realpath(const char *name, char *resolved) {
char *retname = NULL;
/* SUSv3 says we must set `errno = EINVAL', and return NULL,
* if `name' is passed as a NULL pointer.
*/
if (name == NULL) {
errno = EINVAL;
return NULL;
}
/* Otherwise, `name' must refer to a readable filesystem object,
* if we are going to resolve its absolute path name.
*/
wchar_t wideNameBuffer[PATH_MAX];
wchar_t *wideName = wideNameBuffer;
if (!utf8ToWide(name, wideName, PATH_MAX)) {
errno = EINVAL;
return NULL;
}
if (_waccess(wideName, 4) != 0)
return NULL;
/* If `name' didn't point to an existing entity,
* then we don't get to here; we simply fall past this block,
* returning NULL, with `errno' appropriately set by `access'.
*
* When we _do_ get to here, then we can use `_fullpath' to
* resolve the full path for `name' into `resolved', but first,
* check that we have a suitable buffer, in which to return it.
*/
if ((retname = resolved) == NULL) {
/* Caller didn't give us a buffer, so we'll exercise the
* option granted by SUSv3, and allocate one.
*
* `_fullpath' would do this for us, but it uses `malloc', and
* Microsoft's implementation doesn't set `errno' on failure.
* If we don't do this explicitly ourselves, then we will not
* know if `_fullpath' fails on `malloc' failure, or for some
* other reason, and we want to set `errno = ENOMEM' for the
* `malloc' failure case.
*/
retname = (char *)malloc(PATH_MAX);
if (retname == NULL) {
errno = ENOMEM;
return NULL;
}
}
/* Otherwise, when we do have a valid buffer,
* `_fullpath' should only fail if the path name is too long.
*/
wchar_t wideFullPathBuffer[PATH_MAX];
wchar_t *wideFullPath;
if ((wideFullPath = _wfullpath(wideFullPathBuffer, wideName, PATH_MAX)) ==
NULL) {
errno = ENAMETOOLONG;
return NULL;
}
// Do a LongPath<->ShortPath roundtrip so that case is resolved by OS
// FIXME: Check for failure
size_t initialLength = wcslen(wideFullPath);
GetShortPathNameW(wideFullPath, wideNameBuffer, PATH_MAX);
GetLongPathNameW(wideNameBuffer, wideFullPathBuffer, initialLength + 1);
// Convert back to UTF-8
if (!wideToUtf8(wideFullPathBuffer, retname, PATH_MAX)) {
errno = EINVAL;
return NULL;
}
// Force drive to be upper case
if (retname[1] == ':')
retname[0] = toupper(retname[0]);
return retname;
}
#ifdef _MSC_VER
char *basename(char *path) {