From b20e56b451e942803f6e53842dfcf66d44b49648 Mon Sep 17 00:00:00 2001 From: danielk1977 Date: Tue, 15 Jun 2004 13:36:30 +0000 Subject: [PATCH] Memory leak fixes for tests in file select1.test. (CVS 1599) FossilOrigin-Name: 59db58ebd30cd7c79c32f5a725620e740eff661d --- manifest | 20 ++++++++++---------- manifest.uuid | 2 +- src/func.c | 3 ++- src/main.c | 3 ++- src/vdbe.c | 23 +---------------------- src/vdbeInt.h | 2 -- src/vdbeaux.c | 24 ++++++++---------------- 7 files changed, 24 insertions(+), 53 deletions(-) diff --git a/manifest b/manifest index 92124f59b5..401c63a12f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Minor\sbugfixes\sand\stest\scase\sadjustments\sfor\sversion\s2\stest\scases\sto\swork\nwith\sversion\s3.\s(CVS\s1598) -D 2004-06-15T11:40:04 +C Memory\sleak\sfixes\sfor\stests\sin\sfile\sselect1.test.\s(CVS\s1599) +D 2004-06-15T13:36:30 F Makefile.in ab7b0d5118e2da97bac66be8684a1034e3500f5a F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457 F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd @@ -33,12 +33,12 @@ F src/date.c 65b483caeb0e4dd663667d2f927caa058168ebff F src/delete.c 911221aadb35d610c84fadb32e71c52990827e58 F src/encode.c a876af473d1d636faa3dca51c7571f2e007eea37 F src/expr.c f9eafe34828ebc9040b4f0f4de2c1e6a0aee296b -F src/func.c 3b86bf207b21c1eff766c06c67a0712e756873e5 +F src/func.c 60bf9412807f95d4694863114ae7009d817de45f F src/hash.c 440c2f8cb373ee1b4e13a0988489c7cd95d55b6f F src/hash.h 762d95f1e567664d1eafc1687de755626be962fb F src/insert.c 68c7f3ddd6a7f1e5596d6996da1a2861b3789a3a F src/legacy.c ad23746f15f67e34577621b1875f639c94839e1f -F src/main.c a62c08c9d315c3ebc58bfb6b52ab5953ee8a3089 +F src/main.c afb1200c096a90836676da2b3e873a2e0192c718 F src/md5.c d77a389955759c8329bb357e3d71bac3d6eb710b F src/os.h 1cb5f0293a30288451fe3c0c73815cf208212ed1 F src/os_common.h ba1b7306e16e2091718f2c48db0fe6c1d7a31bb8 @@ -71,11 +71,11 @@ F src/update.c 6133c876aa126e1771cda165fd992bb0d2f8eb38 F src/utf.c e16737b3fc4201bf7ce9bd8ced5250596aa31b76 F src/util.c 90375fa253137562d536ccdd40b297f0fd7413fc F src/vacuum.c f9561c8095407a970af4e6a304b77c4083433d3e -F src/vdbe.c adf618cd90b41ad473aadc165554896968988b02 +F src/vdbe.c 6f022fdf6f4e7273d6f6c39907e5ebd36b300e76 F src/vdbe.h 46f74444a213129bc4b5ce40124dd8ed613b0cde -F src/vdbeInt.h 0aabcc77523f0885c3e710fae58c8ec6e3ef0753 +F src/vdbeInt.h 4e636b1b6c18d1d85b085fe0e5a19d45ad85f382 F src/vdbeapi.c ee350b552fc4c1c695b760f914f69e9c5556e829 -F src/vdbeaux.c 765ffa64365c61c0d5b91dba33b35cadddadf52a +F src/vdbeaux.c 475fb88c1dc2dd170c0d218b0c9da3544f82db74 F src/vdbemem.c 1e7df5ed53bc05433c7d3fb28899cf2c82bd16ac F src/where.c 7fee7aeb9278f27324f228c55ab453b5f183b486 F test/all.test 569a92a8ee88f5300c057cc4a8f50fbbc69a3242 @@ -222,7 +222,7 @@ F www/support.tcl 1801397edd271cc39a2aadd54e701184b5181248 F www/tclsqlite.tcl 19191cf2a1010eaeff74c51d83fd5f5a4d899075 F www/vdbe.tcl 59288db1ac5c0616296b26dce071c36cb611dfe9 F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4 -P 4f5e2530829ef91753b083b5f2a1d7332e311cb6 -R e12d307f558ec5df80a17da54f5ce817 +P e21a181376d4115c7dbe614f3f8a1fbf82d77c75 +R e061ee699c8f945d020155b0ecea44f4 U danielk1977 -Z f98acef0e3dddb395ad5120c2ae73489 +Z 708f1b0423b9ce4121dae16049794fd8 diff --git a/manifest.uuid b/manifest.uuid index fcbe55ad24..ccd7554505 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e21a181376d4115c7dbe614f3f8a1fbf82d77c75 \ No newline at end of file +59db58ebd30cd7c79c32f5a725620e740eff661d \ No newline at end of file diff --git a/src/func.c b/src/func.c index 534486e493..4f639540ec 100644 --- a/src/func.c +++ b/src/func.c @@ -16,7 +16,7 @@ ** sqliteRegisterBuildinFunctions() found at the bottom of the file. ** All other code has file scope. ** -** $Id: func.c,v 1.68 2004/06/12 09:25:14 danielk1977 Exp $ +** $Id: func.c,v 1.69 2004/06/15 13:36:30 danielk1977 Exp $ */ #include #include @@ -931,6 +931,7 @@ static void minMaxFinalize(sqlite3_context *context){ if( pRes->flags ){ sqlite3_result_value(context, pRes); } + sqlite3VdbeMemRelease(pRes); } /* diff --git a/src/main.c b/src/main.c index 500dcd822d..d5b11aca09 100644 --- a/src/main.c +++ b/src/main.c @@ -14,7 +14,7 @@ ** other files are for internal use by SQLite and should not be ** accessed by users of the library. ** -** $Id: main.c,v 1.220 2004/06/14 09:35:17 danielk1977 Exp $ +** $Id: main.c,v 1.221 2004/06/15 13:36:31 danielk1977 Exp $ */ #include "sqliteInt.h" #include "os.h" @@ -1007,6 +1007,7 @@ prepare_out: } if( zErrMsg ){ sqlite3Error(db, rc, "%s", zErrMsg); + sqliteFree(zErrMsg); }else{ sqlite3Error(db, rc, 0); } diff --git a/src/vdbe.c b/src/vdbe.c index 94cfdbaff7..320ee74799 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -43,7 +43,7 @@ ** in this file for details. If in doubt, do not deviate from existing ** commenting and indentation practices when changing or adding code. ** -** $Id: vdbe.c,v 1.373 2004/06/15 11:40:09 danielk1977 Exp $ +** $Id: vdbe.c,v 1.374 2004/06/15 13:36:37 danielk1977 Exp $ */ #include "sqliteInt.h" #include "os.h" @@ -993,27 +993,6 @@ case OP_Push: { break; } - -/* Opcode: ColumnName P1 P2 P3 -** -** P3 becomes the P1-th column name (first is 0). An array of pointers -** to all column names is passed as the 4th parameter to the callback. -** If P2==1 then this is the last column in the result set and thus the -** number of columns in the result set will be P1. There must be at least -** one OP_ColumnName with a P2==1 before invoking OP_Callback and the -** number of columns specified in OP_Callback must one more than the P1 -** value of the OP_ColumnName that has P2==1. -*/ -case OP_ColumnName: { - assert(0); - assert( pOp->p1>=0 && pOp->p1nOp ); - p->azColName[pOp->p1] = pOp->p3; - p->nCallback = 0; - assert( !pOp->p2 || p->nResColumn==(pOp->p1+1) ); - /* if( pOp->p2 ) p->nResColumn = pOp->p1+1; */ - break; -} - /* Opcode: Callback P1 * * ** ** Pop P1 values off the stack and form them into an array. Then diff --git a/src/vdbeInt.h b/src/vdbeInt.h index 0121fc1b86..ce5244fda0 100644 --- a/src/vdbeInt.h +++ b/src/vdbeInt.h @@ -303,8 +303,6 @@ struct Vdbe { Mem *pTos; /* Top entry in the operand stack */ Mem **apArg; /* Arguments to currently executing user function */ Mem *aColName; /* Column names to return */ - char **azColName; /* Becomes the 4th parameter to callbacks */ - void **azColName16; /* UTF-16 encoded equivalent of azColName */ int nCursor; /* Number of slots in apCsr[] */ Cursor **apCsr; /* One element of this array for each open cursor */ Sorter *pSort; /* A linked list of objects to be sorted */ diff --git a/src/vdbeaux.c b/src/vdbeaux.c index 7f5c421790..3713b00243 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -530,11 +530,6 @@ int sqlite3VdbeList( sqlite *db = p->db; int i; int rc = SQLITE_OK; - static char *azColumnNames[] = { - "addr", "opcode", "p1", "p2", "p3", - "int", "text", "int", "int", "text", - 0 - }; assert( p->explain ); @@ -548,8 +543,6 @@ int sqlite3VdbeList( p->aStack[i].flags = 0; } } - - p->azColName = azColumnNames; p->resOnStack = 0; i = p->pc++; @@ -638,12 +631,11 @@ void sqlite3VdbeMakeReady( assert( nVar>=0 ); n = isExplain ? 10 : p->nOp; p->aStack = sqliteMalloc( - n*(sizeof(p->aStack[0])+sizeof(Mem*)+sizeof(char*)) /* aStack, apArg */ + n*(sizeof(p->aStack[0])+sizeof(Mem*)) /* aStack, apArg */ + p->nVar*sizeof(Mem) /* apVar */ ); p->apArg = (Mem **)&p->aStack[n]; - p->azColName = (char**)&p->apArg[n]; - p->apVar = (Mem *)&p->azColName[n]; + p->apVar = (Mem *)&p->apArg[n]; for(n=0; nnVar; n++){ p->apVar[n].flags = MEM_Null; } @@ -1382,15 +1374,15 @@ void sqlite3VdbeDelete(Vdbe *p){ for(i=0; inVar; i++){ sqlite3VdbeMemRelease(&p->apVar[i]); } - if( p->azColName16 ){ - for(i=0; inResColumn; i++){ - if( p->azColName16[i] ) sqliteFree(p->azColName16[i]); - } - sqliteFree(p->azColName16); - } sqliteFree(p->aOp); sqliteFree(p->aLabel); sqliteFree(p->aStack); + if( p->aColName ){ + for(i=0; i<(p->nResColumn)*2; i++){ + sqlite3VdbeMemRelease(&(p->aColName[i])); + } + sqliteFree(p->aColName); + } p->magic = VDBE_MAGIC_DEAD; sqliteFree(p); }