aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2007-07-10 01:45:07 +0000
committerMike Buland <eichlan@xagasoft.com>2007-07-10 01:45:07 +0000
commit32c48edc85e05bedc6324109e8a5429767dda42a (patch)
tree260535d410e450f419b81b539fb3e9c010fdca40
parent96a0e186d535d761d6b24ef3e929a6710e4b0cea (diff)
downloadlibbu++-32c48edc85e05bedc6324109e8a5429767dda42a.tar.gz
libbu++-32c48edc85e05bedc6324109e8a5429767dda42a.tar.bz2
libbu++-32c48edc85e05bedc6324109e8a5429767dda42a.tar.xz
libbu++-32c48edc85e05bedc6324109e8a5429767dda42a.zip
I Fixed the Hash bug!!!
-rw-r--r--src/client.cpp7
-rw-r--r--src/hash.h5
2 files changed, 8 insertions, 4 deletions
diff --git a/src/client.cpp b/src/client.cpp
index dc91e4b..7332abc 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -63,8 +63,11 @@ void Bu::Client::processOutput()
63{ 63{
64 if( sWriteBuf.getSize() > 0 ) 64 if( sWriteBuf.getSize() > 0 )
65 { 65 {
66 pSocket->write( sWriteBuf.getStr(), sWriteBuf.getSize() ); 66 int nAmnt = (sWriteBuf.getSize()<2048)?(sWriteBuf.getSize()):(2048);
67 sWriteBuf.clear(); 67 printf("Transmitting %d of %ld bytes.\n", nAmnt, sWriteBuf.getSize() );
68 pSocket->write( sWriteBuf.getStr(), nAmnt );
69 sWriteBuf.trimFront( nAmnt );
70 //sWriteBuf.clear();
68 } 71 }
69} 72}
70 73
diff --git a/src/hash.h b/src/hash.h
index f183823..36665a6 100644
--- a/src/hash.h
+++ b/src/hash.h
@@ -856,7 +856,8 @@ namespace Bu
856 856
857 // First we scan to see if the key is already there, abort if we 857 // First we scan to see if the key is already there, abort if we
858 // run out of probing room, or we find a non-filled entry 858 // run out of probing room, or we find a non-filled entry
859 for( int8_t j = 0; 859 int8_t j;
860 for( j = 0;
860 isFilled( nCur ) && j < 32; 861 isFilled( nCur ) && j < 32;
861 nCur = (nCur + (1<<j))%nCapacity, j++ 862 nCur = (nCur + (1<<j))%nCapacity, j++
862 ) 863 )
@@ -880,7 +881,7 @@ namespace Bu
880 881
881 // This is our insurance, if the table is full, then go ahead and 882 // This is our insurance, if the table is full, then go ahead and
882 // rehash, then try again. 883 // rehash, then try again.
883 if( isFilled( nCur ) && rehash == true ) 884 if( (isFilled( nCur ) || j == 32) && rehash == true )
884 { 885 {
885 reHash( szCalc(getCapacity(), getFill(), getDeleted()) ); 886 reHash( szCalc(getCapacity(), getFill(), getDeleted()) );
886 887