/ Check-in [9cca9593]
Login

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

Overview
Comment:Fix a bad memory leak in the in-memory database module. (CVS 1039)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 9cca95937837333c91f5dee8c48178cf7e06d59f
User & Date: drh 2003-06-29 18:29:48
Context
2003-06-29
20:25
The prior fix of ticket #360 was incorrect and caused a memory leak. This check-in plugs the memory leak and correctly fixes ticket #360. (CVS 1040) check-in: fc490f67 user: drh tags: trunk
18:29
Fix a bad memory leak in the in-memory database module. (CVS 1039) check-in: 9cca9593 user: drh tags: trunk
16:16
Bump the version number in preparation for the next release. (CVS 1038) check-in: 0532e1a8 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/btree_rb.c.

     5      5   ** a legal notice, here is a blessing:
     6      6   **
     7      7   **    May you do good and not evil.
     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         -** $Id: btree_rb.c,v 1.13 2003/06/10 02:46:15 drh Exp $
           12  +** $Id: btree_rb.c,v 1.14 2003/06/29 18:29:48 drh Exp $
    13     13   **
    14     14   ** This file implements an in-core database using Red-Black balanced
    15     15   ** binary trees.
    16     16   **
    17     17   ** It was contributed to SQLite by anonymous on 2003-Feb-04 23:24:49 UTC.
    18     18   */
    19     19   #include "btree.h"
................................................................................
  1176   1176       BtRbTree *pTree = sqliteHashData(p);
  1177   1177       check_redblack_tree(pTree, &msg);
  1178   1178     }
  1179   1179   
  1180   1180     return msg;
  1181   1181   }
  1182   1182   
  1183         -/*
  1184         - * Close the supplied Rbtree. Delete everything associated with it.
  1185         - */
  1186         -static int memRbtreeClose(Rbtree* tree)
  1187         -{
  1188         -  HashElem *p;
  1189         -  while( (p=sqliteHashFirst(&tree->tblHash))!=0 ){
  1190         -    tree->eTransState = TRANS_ROLLBACK;
  1191         -    memRbtreeDropTable(tree, sqliteHashKeysize(p));
  1192         -  }
  1193         -  sqliteHashClear(&tree->tblHash);
  1194         -  sqliteFree(tree);
  1195         -  return SQLITE_OK;
  1196         -}
  1197         -
  1198   1183   static int memRbtreeSetCacheSize(Rbtree* tree, int sz)
  1199   1184   {
  1200   1185     return SQLITE_OK;
  1201   1186   }
  1202   1187   
  1203   1188   static int memRbtreeSetSafetyLevel(Rbtree *pBt, int level){
  1204   1189     return SQLITE_OK;
................................................................................
  1233   1218     deleteRollbackList(tree->pTransRollback);
  1234   1219     tree->pTransRollback = 0;
  1235   1220     tree->pCheckRollback = 0;
  1236   1221     tree->pCheckRollbackTail = 0;
  1237   1222     tree->eTransState = TRANS_NONE;
  1238   1223     return SQLITE_OK;
  1239   1224   }
         1225  +
         1226  +/*
         1227  + * Close the supplied Rbtree. Delete everything associated with it.
         1228  + */
         1229  +static int memRbtreeClose(Rbtree* tree)
         1230  +{
         1231  +  HashElem *p;
         1232  +  memRbtreeCommit(tree);
         1233  +  while( (p=sqliteHashFirst(&tree->tblHash))!=0 ){
         1234  +    tree->eTransState = TRANS_ROLLBACK;
         1235  +    memRbtreeDropTable(tree, sqliteHashKeysize(p));
         1236  +  }
         1237  +  sqliteHashClear(&tree->tblHash);
         1238  +  sqliteFree(tree);
         1239  +  return SQLITE_OK;
         1240  +}
  1240   1241   
  1241   1242   /*
  1242   1243    * Execute and delete the supplied rollback-list on pRbtree.
  1243   1244    */
  1244   1245   static void execute_rollback_list(Rbtree *pRbtree, BtRollbackOp *pList)
  1245   1246   {
  1246   1247     BtRollbackOp *pTmp;