diff --git a/headers/private/kernel/fs/KPath.h b/headers/private/kernel/fs/KPath.h index 5b4bbe4918..6474868126 100644 --- a/headers/private/kernel/fs/KPath.h +++ b/headers/private/kernel/fs/KPath.h @@ -22,6 +22,7 @@ class KPath { status_t SetTo(const char *path, bool normalize = false, size_t bufferSize = B_PATH_NAME_LENGTH); + void Adopt(KPath& other); status_t InitCheck() const; diff --git a/src/system/kernel/fs/KPath.cpp b/src/system/kernel/fs/KPath.cpp index 7d06db50e5..2ad3cb5c53 100644 --- a/src/system/kernel/fs/KPath.cpp +++ b/src/system/kernel/fs/KPath.cpp @@ -86,6 +86,18 @@ KPath::SetTo(const char* path, bool normalize, size_t bufferSize) } +void +KPath::Adopt(KPath& other) +{ + free(fBuffer); + + fBuffer = other.fBuffer; + fBufferSize = other.fBufferSize; + + other.fBuffer = NULL; +} + + status_t KPath::InitCheck() const { @@ -257,7 +269,7 @@ KPath::Append(const char *component, bool isComponent) KPath& KPath::operator=(const KPath& other) { - SetTo(other.fBuffer, other.fBufferSize); + SetTo(other.fBuffer, false, other.fBufferSize); return *this; }