+/*
+ * Copyright (c) 1987-2011 by the citadel.org team
+ *
+ * This program is open source software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
}
+int TestValidateHash(HashList *TestHash)
+{
+ long i;
+
+ if (TestHash->nMembersUsed != TestHash->nLookupTableItems)
+ return 1;
+
+ if (TestHash->nMembersUsed > TestHash->MemberSize)
+ return 2;
+
+ for (i=0; i < TestHash->nMembersUsed; i++)
+ {
+
+ if (TestHash->LookupTable[i]->Position > TestHash->nMembersUsed)
+ return 3;
+
+ if (TestHash->Members[TestHash->LookupTable[i]->Position] == NULL)
+ return 4;
+ if (TestHash->Members[TestHash->LookupTable[i]->Position]->Data == NULL)
+ return 5;
+ }
+ return 0;
+}
+
/**
* @ingroup HashListAccess
* @brief instanciate a new hashlist
/** oh, we're brand new... */
if (Hash->LookupTable[HashAt] == NULL) {
InsertHashItem(Hash, HashAt, HashBinKey, HKey, HKLen, Data, DeleteIt);
- }/** Insert After? */
+ }/** Insert Before? */
else if (Hash->LookupTable[HashAt]->Key > HashBinKey) {
InsertHashItem(Hash, HashAt, HashBinKey, HKey, HKLen, Data, DeleteIt);
- }/** Insert before? */
+ }/** Insert After? */
else if (Hash->LookupTable[HashAt]->Key < HashBinKey) {
InsertHashItem(Hash, HashAt + 1, HashBinKey, HKey, HKLen, Data, DeleteIt);
}
return 0;
}
/** GOTCHA! */
- At->Position = Hash->LookupTable[HashAt]->Position;
+ At->Position = HashAt;
return 1;
}