forked from OSchip/llvm-project
Use standard realloc so FreeBSD Host.cpp can use glibc
To fix building on Debian GNU/kFreeBSD, which uses the FreeBSD kernel with a GNU userland. llvm-svn: 215134
This commit is contained in:
parent
a02d625513
commit
42461e9f13
|
@ -86,7 +86,7 @@ Host::ThreadCreated (const char *thread_name)
|
||||||
std::string
|
std::string
|
||||||
Host::GetThreadName (lldb::pid_t pid, lldb::tid_t tid)
|
Host::GetThreadName (lldb::pid_t pid, lldb::tid_t tid)
|
||||||
{
|
{
|
||||||
struct kinfo_proc *kp = nullptr;
|
struct kinfo_proc *kp = nullptr, *nkp;
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
int error;
|
int error;
|
||||||
int name[4] = {
|
int name[4] = {
|
||||||
|
@ -98,9 +98,13 @@ Host::GetThreadName (lldb::pid_t pid, lldb::tid_t tid)
|
||||||
if (kp == nullptr || (error != 0 && errno == ENOMEM)) {
|
if (kp == nullptr || (error != 0 && errno == ENOMEM)) {
|
||||||
// Add extra space in case threads are added before next call.
|
// Add extra space in case threads are added before next call.
|
||||||
len += sizeof(*kp) + len / 10;
|
len += sizeof(*kp) + len / 10;
|
||||||
kp = (struct kinfo_proc *)reallocf(kp, len);
|
nkp = (struct kinfo_proc *)realloc(kp, len);
|
||||||
if (kp == nullptr)
|
if (nkp == nullptr)
|
||||||
|
{
|
||||||
|
free(kp);
|
||||||
return std::string();
|
return std::string();
|
||||||
|
}
|
||||||
|
kp = nkp;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (error != 0)
|
if (error != 0)
|
||||||
|
|
Loading…
Reference in New Issue