Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | The hash tables deallocate when empty in order to avoid nuisanse complaints from valgrind. Added tests to verify no hash table memory leaks in os_unix.c. (CVS 2738) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
080eadca582a49a069a76ed113ec15e9 |
User & Date: | drh 2005-10-03 15:11:09.000 |
Context
2005-10-04
| ||
18:38 | Automatically check for the fdatasync() function and replace it with fsync() if not found. (CVS 2739) (check-in: 385a08afef user: drh tags: trunk) | |
2005-10-03
| ||
15:11 | The hash tables deallocate when empty in order to avoid nuisanse complaints from valgrind. Added tests to verify no hash table memory leaks in os_unix.c. (CVS 2738) (check-in: 080eadca58 user: drh tags: trunk) | |
2005-09-25
| ||
01:13 | Make sure the default storage for virtual tables is the disk not memory while running conflict.test. Ticket #1453. (CVS 2737) (check-in: 6d780ca6cf user: drh 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.17 2005/10/03 15:11:09 drh Exp $ */ #include "sqliteInt.h" #include <assert.h> /* Turn bulk memory into a hash table object by initializing the ** fields of the Hash structure. ** |
︙ | ︙ | |||
290 291 292 293 294 295 296 297 298 299 300 301 302 303 | pEntry->chain = 0; } if( pH->copyKey && elem->pKey ){ sqliteFree(elem->pKey); } sqliteFree( elem ); pH->count--; } /* Attempt to locate an element of the hash table pH with a key ** that matches pKey,nKey. Return the data for this element if it is ** found, or NULL if there is no match. */ void *sqlite3HashFind(const Hash *pH, const void *pKey, int nKey){ | > > > > > | 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 | pEntry->chain = 0; } if( pH->copyKey && elem->pKey ){ sqliteFree(elem->pKey); } sqliteFree( elem ); pH->count--; if( pH->count<=0 ){ assert( pH->first==0 ); assert( pH->count==0 ); sqlite3HashClear(pH); } } /* Attempt to locate an element of the hash table pH with a key ** that matches pKey,nKey. Return the data for this element if it is ** found, or NULL if there is no match. */ void *sqlite3HashFind(const Hash *pH, const void *pKey, int nKey){ |
︙ | ︙ |
Added test/manydb.test.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | # 2005 October 3 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. # # This file implements tests the ability of the library to open # many different databases at the same time without leaking memory. # # $Id: manydb.test,v 1.1 2005/10/03 15:11:09 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl set N 300 # Create a bunch of random database names # unset -nocomplain dbname unset -nocomplain used for {set i 0} {$i<$N} {incr i} { while 1 { set name test-[format %08x [expr {int(rand()*0x7fffffff)}]].db if {[info exists used($name)]} continue set dbname($i) $name set used($name) $i break } } # Create a bunch of databases # for {set i 0} {$i<$N} {incr i} { do_test manydb-1.$i { sqlite3 db$i $dbname($i) execsql { CREATE TABLE t1(a,b); BEGIN; INSERT INTO t1 VALUES(1,2); } db$i } {} } # Finish the transactions # for {set i 0} {$i<$N} {incr i} { do_test manydb-2.$i { execsql { COMMIT; SELECT * FROM t1; } db$i } {1 2} } # Close the databases and erase the files. # for {set i 0} {$i<$N} {incr i} { do_test manydb-3.$i { db$i close file delete -force $dbname($i) } {} } finish_test |