SQLite4
Check-in [108d62cab9]
Not logged in

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

Overview
Comment:Fix a memory leak in the test harness.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 108d62cab90096262c0c53bd1edbb08d6cea72ee
User & Date: drh 2013-02-11 15:51:17
Context
2013-02-11
16:04
Fix a memory leak in DETACH. check-in: 9b03a19a30 user: drh tags: trunk
15:51
Fix a memory leak in the test harness. check-in: 108d62cab9 user: drh tags: trunk
15:17
Remove two MySQL-isms: Strings in double-quotes and identifiers quoted by grave accents. check-in: eec75c074c user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to test/test_kv2.c.

   287    287   static int kvwrap_install_cmd(Tcl_Interp *interp, int objc, Tcl_Obj **objv){
   288    288     if( objc!=2 ){
   289    289       Tcl_WrongNumArgs(interp, 2, objv, "");
   290    290       return TCL_ERROR;
   291    291     }
   292    292   
   293    293     if( kvwg.xFactory==0 ){
   294         -    sqlite4_env_config(0, SQLITE4_ENVCONFIG_KVSTORE_GET, "main", &kvwg.xFactory);
   295         -    sqlite4_env_config(0, SQLITE4_ENVCONFIG_KVSTORE_PUSH, "main",newFileStorage);
          294  +    sqlite4_env_config(0, SQLITE4_ENVCONFIG_KVSTORE_GET,"main", &kvwg.xFactory);
          295  +    sqlite4_env_config(0, SQLITE4_ENVCONFIG_KVSTORE_PUSH,"main",newFileStorage);
          296  +  }
          297  +  return TCL_OK;
          298  +}
          299  +
          300  +static int kvwrap_uninstall_cmd(Tcl_Interp *interp, int objc, Tcl_Obj **objv){
          301  +  if( objc!=2 ){
          302  +    Tcl_WrongNumArgs(interp, 2, objv, "");
          303  +    return TCL_ERROR;
          304  +  }
          305  +
          306  +  if( kvwg.xFactory ){
          307  +    sqlite4_env_config(0, SQLITE4_ENVCONFIG_KVSTORE_POP,"main", &kvwg.xFactory);
          308  +    kvwg.xFactory = 0;
   296    309     }
   297    310     return TCL_OK;
   298    311   }
   299    312   
   300    313   static int kvwrap_seek_cmd(Tcl_Interp *interp, int objc, Tcl_Obj **objv){
   301    314     if( objc!=2 ){
   302    315       Tcl_WrongNumArgs(interp, 2, objv, "");
................................................................................
   340    353     int objc,
   341    354     Tcl_Obj *CONST objv[]
   342    355   ){
   343    356     struct Subcmd {
   344    357       const char *zCmd;
   345    358       int (*xCmd)(Tcl_Interp *, int, Tcl_Obj **);
   346    359     } aSub[] = {
   347         -    { "install", kvwrap_install_cmd },
   348         -    { "step",    kvwrap_step_cmd },
   349         -    { "seek",    kvwrap_seek_cmd },
   350         -    { "reset",   kvwrap_reset_cmd },
          360  +    { "install",   kvwrap_install_cmd },
          361  +    { "step",      kvwrap_step_cmd },
          362  +    { "seek",      kvwrap_seek_cmd },
          363  +    { "reset",     kvwrap_reset_cmd },
          364  +    { "uninstall", kvwrap_uninstall_cmd },
   351    365     };
   352    366     int iSub;
   353    367     int rc;
   354    368   
   355    369     rc = Tcl_GetIndexFromObjStruct(
   356    370         interp, objv[1], aSub, sizeof(aSub[0]), "sub-command", 0, &iSub
   357    371     );

Changes to test/tester.tcl.

   758    758       puts "all of the test failures above might be a result from this defect"
   759    759       puts "in your TCL build."
   760    760       puts "******************************************************************"
   761    761     }
   762    762     if {$::cmdlinearg(binarylog)} {
   763    763       vfslog finalize binarylog
   764    764     }
          765  +  kvwrap uninstall
   765    766     if {[lindex [sqlite4_env_status SQLITE4_ENVSTATUS_MALLOC_COUNT 0] 1]>0 ||
   766    767                 [sqlite4_memory_used]>0} {
   767    768       puts "Unfreed memory: [sqlite4_memory_used] bytes in\
   768    769            [lindex [sqlite4_env_status SQLITE4_ENVSTATUS_MALLOC_COUNT 0] 1] allocations"
   769    770       incr nErr
   770    771       ifcapable memdebug||mem5||(mem3&&debug) {
   771    772         puts "Writing unfreed memory log to \"./memleak.txt\""