/ Check-in [42372999]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Convert an always-true condition in hash.c into an assert(). (CVS 6624)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 4237299935b8bf8c346aacba021113224813bcb9
User & Date: drh 2009-05-09 23:29:12
Context
2009-05-11
18:22
Enhance the parser to allow nested parentheses in the module argument of a CREATE VIRTUAL TABLE statement. (CVS 6625) check-in: 93772bd7 user: drh tags: trunk
2009-05-09
23:29
Convert an always-true condition in hash.c into an assert(). (CVS 6624) check-in: 42372999 user: drh tags: trunk
18:59
Add the SQLITE_TESTCTRL_ASSERT and SQLITE_TESTCTRL_ALWAYS codes for the sqlite3_test_control() interface. (CVS 6623) check-in: 38df91c2 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/hash.c.

     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** This is the implementation of generic hash-tables
    13     13   ** used in SQLite.
    14     14   **
    15         -** $Id: hash.c,v 1.37 2009/05/02 13:29:38 drh Exp $
           15  +** $Id: hash.c,v 1.38 2009/05/09 23:29:12 drh Exp $
    16     16   */
    17     17   #include "sqliteInt.h"
    18     18   #include <assert.h>
    19     19   
    20     20   /* Turn bulk memory into a hash table object by initializing the
    21     21   ** fields of the Hash structure.
    22     22   **
................................................................................
   261    261     new_elem = (HashElem*)sqlite3Malloc( sizeof(HashElem) );
   262    262     if( new_elem==0 ) return data;
   263    263     new_elem->pKey = pKey;
   264    264     new_elem->nKey = nKey;
   265    265     new_elem->data = data;
   266    266     pH->count++;
   267    267     if( pH->count>=10 && pH->count > 2*pH->htsize ){
   268         -    if( rehash(pH, pH->count*2) && pH->htsize ){
          268  +    if( rehash(pH, pH->count*2) ){
          269  +      assert( pH->htsize>0 );
   269    270         h = strHash(pKey, nKey) % pH->htsize;
   270    271       }
   271    272     }
   272    273     if( pH->ht ){
   273    274       insertElement(pH, &pH->ht[h], new_elem);
   274    275     }else{
   275    276       insertElement(pH, 0, new_elem);
   276    277     }
   277    278     return 0;
   278    279   }