From 56bbbbc9ca07e097c948cd59d3f70d4bb363f19c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Thu, 8 May 2008 16:45:29 +0000 Subject: [PATCH] * Added Adopt() method that steals the other path's buffer. * Fixed operator=(): the second argument of SetTo() is a boolean (normalize), not the length of the buffer. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25382 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/private/kernel/fs/KPath.h | 1 + src/system/kernel/fs/KPath.cpp | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) 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; }