Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Fix asserts in hash.c so that zero-length symbols can be used. (CVS 6563) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
fe9f00aa369051beee09ab3d1a2e046a |
User & Date: | drh 2009-04-28 17:33:16.000 |
Context
2009-04-28
| ||
18:00 | Fix an out-of-order test number in blob.test. Cosmetic change. No changes to code. Ticket #3830. (CVS 6564) (check-in: e855654283 user: drh tags: trunk) | |
17:33 | Fix asserts in hash.c so that zero-length symbols can be used. (CVS 6563) (check-in: fe9f00aa36 user: drh tags: trunk) | |
16:37 | When testing with TEMP_STORE=3 and the test pcache, only run 20 iterations in trans.test. Otherwise the test pcache runs out of memory. (CVS 6562) (check-in: 0799b729a7 user: danielk1977 tags: trunk) | |
Changes
Changes to src/hash.c.
︙ | ︙ | |||
8 9 10 11 12 13 14 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This is the implementation of generic hash-tables ** used in SQLite. ** | | | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This is the implementation of generic hash-tables ** used in SQLite. ** ** $Id: hash.c,v 1.36 2009/04/28 17:33:16 drh Exp $ */ #include "sqliteInt.h" #include <assert.h> /* Turn bulk memory into a hash table object by initializing the ** fields of the Hash structure. ** |
︙ | ︙ | |||
59 60 61 62 63 64 65 | /* ** Hash and comparison functions when the mode is SQLITE_HASH_STRING */ static unsigned int strHash(const void *pKey, int nKey){ const char *z = (const char *)pKey; int h = 0; | | | 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | /* ** Hash and comparison functions when the mode is SQLITE_HASH_STRING */ static unsigned int strHash(const void *pKey, int nKey){ const char *z = (const char *)pKey; int h = 0; assert( nKey>=0 ); while( nKey > 0 ){ h = (h<<3) ^ h ^ sqlite3UpperToLower[(unsigned char)*z++]; nKey--; } return h; } static int strCompare(const void *pKey1, int n1, const void *pKey2, int n2){ |
︙ | ︙ | |||
218 219 220 221 222 223 224 | */ void *sqlite3HashFind(const Hash *pH, const void *pKey, int nKey){ HashElem *elem; /* The element that matches key */ unsigned int h; /* A hash on key */ assert( pH!=0 ); assert( pKey!=0 ); | | | 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 | */ void *sqlite3HashFind(const Hash *pH, const void *pKey, int nKey){ HashElem *elem; /* The element that matches key */ unsigned int h; /* A hash on key */ assert( pH!=0 ); assert( pKey!=0 ); assert( nKey>=0 ); if( pH->ht ){ h = strHash(pKey, nKey) % pH->htsize; }else{ h = 0; } elem = findElementGivenHash(pH, pKey, nKey, h); return elem ? elem->data : 0; |
︙ | ︙ | |||
250 251 252 253 254 255 256 | void *sqlite3HashInsert(Hash *pH, const void *pKey, int nKey, void *data){ unsigned int h; /* the hash of the key modulo hash table size */ HashElem *elem; /* Used to loop thru the element list */ HashElem *new_elem; /* New element added to the pH */ assert( pH!=0 ); assert( pKey!=0 ); | | | 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 | void *sqlite3HashInsert(Hash *pH, const void *pKey, int nKey, void *data){ unsigned int h; /* the hash of the key modulo hash table size */ HashElem *elem; /* Used to loop thru the element list */ HashElem *new_elem; /* New element added to the pH */ assert( pH!=0 ); assert( pKey!=0 ); assert( nKey>=0 ); if( pH->htsize ){ h = strHash(pKey, nKey) % pH->htsize; }else{ h = 0; } elem = findElementGivenHash(pH,pKey,nKey,h); if( elem ){ |
︙ | ︙ |