projects
/
citadel.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
795754b
)
* adjust backward iterating
author
Wilfried Göesgens
<willi@citadel.org>
Wed, 24 Dec 2008 10:42:57 +0000
(10:42 +0000)
committer
Wilfried Göesgens
<willi@citadel.org>
Wed, 24 Dec 2008 10:42:57 +0000
(10:42 +0000)
libcitadel/lib/hash.c
patch
|
blob
|
history
diff --git
a/libcitadel/lib/hash.c
b/libcitadel/lib/hash.c
index b8ba8c346839ac267ebcad69e39a835e8bfea0f6..616429ca87904aabbe16f21abef5999a28585136 100644
(file)
--- a/
libcitadel/lib/hash.c
+++ b/
libcitadel/lib/hash.c
@@
-575,8
+575,7
@@
HashPos *GetNewHashPos(HashList *Hash, int StepWidth)
else
Ret->StepWidth = 1;
if (Ret->StepWidth < 0) {
else
Ret->StepWidth = 1;
if (Ret->StepWidth < 0) {
- Ret->Position = (Hash->nMembersUsed % (-Ret->StepWidth))
- * (-Ret->StepWidth);
+ Ret->Position = Hash->nMembersUsed - 1;
}
else {
Ret->Position = 0;
}
else {
Ret->Position = 0;
@@
-626,10
+625,18
@@
int GetNextHashPos(HashList *Hash, HashPos *At, long *HKLen, const char **HashKe
PayloadPos = Hash->LookupTable[At->Position]->Position;
*Data = Hash->Members[PayloadPos]->Data;
PayloadPos = Hash->LookupTable[At->Position]->Position;
*Data = Hash->Members[PayloadPos]->Data;
- At->Position += At->StepWidth;
+ if (At->Position % abs(At->StepWidth) == 0)
+ At->Position += At->StepWidth;
+ else
+ At->Position += (At->Position % abs(At->StepWidth)) *
+ (At->StepWidth / abs(At->StepWidth));
+
if (At->Position > Hash->nMembersUsed) {
At->Position = Hash->nMembersUsed;
return 0;
if (At->Position > Hash->nMembersUsed) {
At->Position = Hash->nMembersUsed;
return 0;
+ } else if (At->Position <= 0) {
+ At->Position = 0;
+ return 0;
}
return 1;
}
}
return 1;
}