diff --git a/headers/private/kernel/fs/KPath.h b/headers/private/kernel/fs/KPath.h index 372b02fc2d..726ed810f8 100644 --- a/headers/private/kernel/fs/KPath.h +++ b/headers/private/kernel/fs/KPath.h @@ -22,15 +22,16 @@ public: TRAVERSE_LEAF_LINK = 0x02, LAZY_ALLOC = 0x04 }; + public: - KPath(size_t bufferSize = B_PATH_NAME_LENGTH + 1); + KPath(size_t bufferSize = B_PATH_NAME_LENGTH); KPath(const char* path, int32 flags = DEFAULT, - size_t bufferSize = B_PATH_NAME_LENGTH + 1); + size_t bufferSize = B_PATH_NAME_LENGTH); KPath(const KPath& other); ~KPath(); status_t SetTo(const char* path, int32 flags = DEFAULT, - size_t bufferSize = B_PATH_NAME_LENGTH + 1); + 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 cfca5be237..32ded8b69d 100644 --- a/src/system/kernel/fs/KPath.cpp +++ b/src/system/kernel/fs/KPath.cpp @@ -80,7 +80,7 @@ status_t KPath::SetTo(const char* path, int32 flags, size_t bufferSize) { if (bufferSize == 0) - bufferSize = B_PATH_NAME_LENGTH + 1; + bufferSize = B_PATH_NAME_LENGTH; // free the previous buffer, if the buffer size differs if (fBuffer != NULL && fBufferSize != bufferSize) { @@ -249,11 +249,13 @@ KPath::DetachBuffer() { char* buffer = fBuffer; - if (fBufferSize == (B_PATH_NAME_LENGTH + 1)) { +#ifdef _KERNEL_MODE + if (fBufferSize == B_PATH_NAME_LENGTH) { buffer = (char*)malloc(fBufferSize); memcpy(buffer, fBuffer, fBufferSize); _FreeBuffer(); } +#endif if (fBuffer != NULL) { fBuffer = NULL; @@ -427,7 +429,7 @@ KPath::_AllocateBuffer() { if (fBuffer == NULL && fBufferSize != 0) { #ifdef _KERNEL_MODE - if (fBufferSize == (B_PATH_NAME_LENGTH + 1)) + if (fBufferSize == B_PATH_NAME_LENGTH) fBuffer = (char*)object_cache_alloc(sPathNameCache, 0); else #endif @@ -448,7 +450,7 @@ void KPath::_FreeBuffer() { #ifdef _KERNEL_MODE - if (fBufferSize == (B_PATH_NAME_LENGTH + 1)) + if (fBufferSize == B_PATH_NAME_LENGTH) object_cache_free(sPathNameCache, fBuffer, 0); else #endif diff --git a/src/system/kernel/fs/vfs.cpp b/src/system/kernel/fs/vfs.cpp index 85e2098512..2a5dbbbccb 100644 --- a/src/system/kernel/fs/vfs.cpp +++ b/src/system/kernel/fs/vfs.cpp @@ -5284,7 +5284,7 @@ vfs_init(kernel_args* args) panic("vfs_init: error creating mounts hash table\n"); sPathNameCache = create_object_cache("vfs path names", - B_PATH_NAME_LENGTH + 1, 8, NULL, NULL, NULL); + B_PATH_NAME_LENGTH, 8, NULL, NULL, NULL); if (sPathNameCache == NULL) panic("vfs_init: error creating path name object_cache\n");