From 7ce581d7eb0618c10f6986abc3ddb32abd807db2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Thu, 26 Nov 2009 14:28:55 +0000 Subject: [PATCH] * Eliminated the extra buffer in dir_vnode_to_path(); we write directly to the specified buffer now. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34282 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/kernel/fs/vfs.cpp | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/src/system/kernel/fs/vfs.cpp b/src/system/kernel/fs/vfs.cpp index dadd1f17b6..1f1144da32 100644 --- a/src/system/kernel/fs/vfs.cpp +++ b/src/system/kernel/fs/vfs.cpp @@ -2634,12 +2634,8 @@ dir_vnode_to_path(struct vnode* vnode, char* buffer, size_t bufferSize, if (!S_ISDIR(vnode->type)) return B_NOT_A_DIRECTORY; - KPath pathBuffer(bufferSize); - if (pathBuffer.InitCheck() != B_OK) - return B_NO_MEMORY; - - char* path = pathBuffer.LockBuffer(); - int32 insert = pathBuffer.BufferSize(); + char* path = buffer; + int32 insert = bufferSize; int32 maxLevel = 256; int32 length; status_t status; @@ -2738,12 +2734,9 @@ dir_vnode_to_path(struct vnode* vnode, char* buffer, size_t bufferSize, TRACE((" path is: %s\n", path + insert)); - // copy the path to the output buffer - length = pathBuffer.BufferSize() - insert; - if (length <= (int)bufferSize) - memcpy(buffer, path + insert, length); - else - status = B_RESULT_NOT_REPRESENTABLE; + // move the path to the start of the buffer + length = bufferSize - insert; + memmove(buffer, path + insert, length); out: put_vnode(vnode);