From 55b5474b8b3755e14a99260e03c07d642d78b16c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Sun, 25 Jan 2004 14:38:51 +0000 Subject: [PATCH] Added _PACKED to the on-disk structures. Switched to kernel_cpp.h/cpp. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6287 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../kernel/file_systems/bfs/BPlusTree.cpp | 26 +++++++++++++------ .../kernel/file_systems/bfs/BPlusTree.h | 6 ++--- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/src/add-ons/kernel/file_systems/bfs/BPlusTree.cpp b/src/add-ons/kernel/file_systems/bfs/BPlusTree.cpp index eb73a6463c..b8c261ed8d 100644 --- a/src/add-ons/kernel/file_systems/bfs/BPlusTree.cpp +++ b/src/add-ons/kernel/file_systems/bfs/BPlusTree.cpp @@ -3,18 +3,18 @@ ** Initial version by Axel Dörfler, axeld@pinc-software.de ** Roughly based on 'btlib' written by Marcus J. Ranum ** -** Copyright (c) 2001-2002 pinc Software. All Rights Reserved. +** Copyright (c) 2001-2004 pinc Software. All Rights Reserved. ** This file may be used under the terms of the OpenBeOS License. */ #include "Debug.h" -#include "cpp.h" #include "BPlusTree.h" #include "Inode.h" #include "Utility.h" #include "Stack.h" +#include #include #include @@ -2052,14 +2052,25 @@ bplustree_node::CheckIntegrity(uint32 nodeSize) int32 -compareKeys(type_code type,const void *key1, int keyLength1, const void *key2, int keyLength2) +compareKeys(type_code type, const void *key1, int keyLength1, const void *key2, int keyLength2) { // if one of the keys is NULL, bail out gracefully - if (key1 == NULL || key2 == NULL) - return -1; + if (key1 == NULL || key2 == NULL) { +//#if USER +// // that's here to see if it's reasonable to handle this case nicely at all +// DEBUGGER(("compareKeys() got NULL key!")); +//#endif + // even if it's most probably a bug in the calling code, we try to + // give a meaningful result + if (key1 == NULL && key2 != NULL) + return 1; + else if (key2 == NULL && key1 != NULL) + return -1; - switch (type) - { + return 0; + } + + switch (type) { case B_STRING_TYPE: { int len = min_c(keyLength1, keyLength2); @@ -2125,4 +2136,3 @@ compareKeys(type_code type,const void *key1, int keyLength1, const void *key2, i return -1; } - diff --git a/src/add-ons/kernel/file_systems/bfs/BPlusTree.h b/src/add-ons/kernel/file_systems/bfs/BPlusTree.h index b93f3da3ea..6a9b4d554f 100644 --- a/src/add-ons/kernel/file_systems/bfs/BPlusTree.h +++ b/src/add-ons/kernel/file_systems/bfs/BPlusTree.h @@ -5,7 +5,7 @@ ** Initial version by Axel Dörfler, axeld@pinc-software.de ** Roughly based on 'btlib' written by Marcus J. Ranum ** -** Copyright (c) 2001-2002 pinc Software. All Rights Reserved. +** Copyright (c) 2001-2004 pinc Software. All Rights Reserved. ** This file may be used under the terms of the OpenBeOS License. */ @@ -40,7 +40,7 @@ struct bplustree_header { uint32 MaxNumberOfLevels() const { return BFS_ENDIAN_TO_HOST_INT32(max_number_of_levels); } inline bool IsValidLink(off_t link); -}; +} _PACKED; #define BPLUSTREE_MAGIC 0x69f6c2e8 #define BPLUSTREE_NODE_SIZE 1024 @@ -97,7 +97,7 @@ struct bplustree_node { #ifdef DEBUG void CheckIntegrity(uint32 nodeSize); #endif -}; +} _PACKED; //#define BPLUSTREE_NODE 0 #define BPLUSTREE_DUPLICATE_NODE 2