mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-05 15:55:57 +03:00
Use the DbMalloc() and DbRealloc() functions more consistently. (CVS 4323)
FossilOrigin-Name: c790c234c369c6b7610e67dcaaa9eee347df729c
This commit is contained in:
32
manifest
32
manifest
@@ -1,5 +1,5 @@
|
|||||||
C Be\scareful\sto\sverify\sthe\sschema\scookie\swhen\srunning\sthe\sxfer\soptimization\non\sINSERT\sstatements.\s(CVS\s4322)
|
C Use\sthe\sDbMalloc()\sand\sDbRealloc()\sfunctions\smore\sconsistently.\s(CVS\s4323)
|
||||||
D 2007-08-29T13:45:59
|
D 2007-08-29T14:06:23
|
||||||
F Makefile.in bfcc303429a5d9dcd552d807ee016c77427418c3
|
F Makefile.in bfcc303429a5d9dcd552d807ee016c77427418c3
|
||||||
F Makefile.linux-gcc 65241babba6faf1152bf86574477baab19190499
|
F Makefile.linux-gcc 65241babba6faf1152bf86574477baab19190499
|
||||||
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
|
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
|
||||||
@@ -76,7 +76,7 @@ F sqlite.pc.in 30552343140c53304c2a658c080fbe810cd09ca2
|
|||||||
F sqlite3.1 6be1ad09113570e1fc8dcaff84c9b0b337db5ffc
|
F sqlite3.1 6be1ad09113570e1fc8dcaff84c9b0b337db5ffc
|
||||||
F sqlite3.def a96c1d0d39362b763d2ddba220a32da41a15c4b4
|
F sqlite3.def a96c1d0d39362b763d2ddba220a32da41a15c4b4
|
||||||
F sqlite3.pc.in 985b9bf34192a549d7d370e0f0b6b34a4f61369a
|
F sqlite3.pc.in 985b9bf34192a549d7d370e0f0b6b34a4f61369a
|
||||||
F src/alter.c 977eeee31adc5c2b7b41c256ccbb84342e7e2ed4
|
F src/alter.c c9f30b4d6fbf7eff7c5518b002a217d4ecd13bcf
|
||||||
F src/analyze.c a28b43a5f79bfa7616ab506bb917077242098469
|
F src/analyze.c a28b43a5f79bfa7616ab506bb917077242098469
|
||||||
F src/attach.c a52225c75b107be8c5bc144a2b6d20201be3f8f8
|
F src/attach.c a52225c75b107be8c5bc144a2b6d20201be3f8f8
|
||||||
F src/auth.c 083c1205b45e3f52291ec539d396b4fc557856b3
|
F src/auth.c 083c1205b45e3f52291ec539d396b4fc557856b3
|
||||||
@@ -84,14 +84,14 @@ F src/btmutex.c c04e67d99d949a12beb17209f307950f21313980
|
|||||||
F src/btree.c 7079a423e0da7eec5147d102202e2b51038002cd
|
F src/btree.c 7079a423e0da7eec5147d102202e2b51038002cd
|
||||||
F src/btree.h 7391b9e78ae441fe0fb3a6d3ae772770d35a4375
|
F src/btree.h 7391b9e78ae441fe0fb3a6d3ae772770d35a4375
|
||||||
F src/btreeInt.h 1fa6510aa8601dc0358a5240d191335236d3cf76
|
F src/btreeInt.h 1fa6510aa8601dc0358a5240d191335236d3cf76
|
||||||
F src/build.c 915c4591ca7258b3144d53cd980bc3b4cc4a81e2
|
F src/build.c 830d1a6b2de157fc4d4dd08d4433066ad83f8b72
|
||||||
F src/callback.c 77b302b0d41468dcda78c70e706e5b84577f0fa0
|
F src/callback.c 77b302b0d41468dcda78c70e706e5b84577f0fa0
|
||||||
F src/complete.c 4cf68fd75d60257524cbe74f87351b9848399131
|
F src/complete.c 4cf68fd75d60257524cbe74f87351b9848399131
|
||||||
F src/date.c af235f38f50809abd0a96da3bb3e0cc32be6226e
|
F src/date.c af235f38f50809abd0a96da3bb3e0cc32be6226e
|
||||||
F src/delete.c 849846d06d29851dde0d9f424a5de5817eb140d1
|
F src/delete.c 849846d06d29851dde0d9f424a5de5817eb140d1
|
||||||
F src/experimental.c 1b2d1a6cd62ecc39610e97670332ca073c50792b
|
F src/experimental.c 1b2d1a6cd62ecc39610e97670332ca073c50792b
|
||||||
F src/expr.c 70660e0c5fc6375a03b3a7fc4eb6e66d96e5f6b1
|
F src/expr.c e0e393df864531720b5281c528c6a8d59d530b80
|
||||||
F src/func.c 4db632f1a81ed42a5a315136d3e90b7d8c76834c
|
F src/func.c 30f9562b0e71efcf0d9752079b95480d2cba6a34
|
||||||
F src/hash.c 8fe2fa52bd17869c87748e42cff5b1e7fbf90822
|
F src/hash.c 8fe2fa52bd17869c87748e42cff5b1e7fbf90822
|
||||||
F src/hash.h 3ad3da76bfb954978d227bf495568b0e6da2c19e
|
F src/hash.h 3ad3da76bfb954978d227bf495568b0e6da2c19e
|
||||||
F src/insert.c b11e5ca0d68bf2a7a56f47a052a0ee67dd4e2f89
|
F src/insert.c b11e5ca0d68bf2a7a56f47a052a0ee67dd4e2f89
|
||||||
@@ -100,7 +100,7 @@ F src/legacy.c 4ac53191fad2e3c4d59bde1228879b2dc5a96d66
|
|||||||
F src/limits.h 71ab25f17e35e0a9f3f6f234b8ed49cc56731d35
|
F src/limits.h 71ab25f17e35e0a9f3f6f234b8ed49cc56731d35
|
||||||
F src/loadext.c 8b31e2e0e961918fa045515459aee1c122d8c266
|
F src/loadext.c 8b31e2e0e961918fa045515459aee1c122d8c266
|
||||||
F src/main.c 58f71f9b0c583fbe74d13b6d3fdb509cac5871f3
|
F src/main.c 58f71f9b0c583fbe74d13b6d3fdb509cac5871f3
|
||||||
F src/malloc.c baed31e12b774080a2ee4cb88fbc6a41e601f64a
|
F src/malloc.c de4e77fe70a9a0ac47a1c3a874422b107231bf31
|
||||||
F src/md5.c c5fdfa5c2593eaee2e32a5ce6c6927c986eaf217
|
F src/md5.c c5fdfa5c2593eaee2e32a5ce6c6927c986eaf217
|
||||||
F src/mem1.c afe2fbf6d7e8247c6c9f69c1481358b1cad60c08
|
F src/mem1.c afe2fbf6d7e8247c6c9f69c1481358b1cad60c08
|
||||||
F src/mem2.c 2ba377e2f7d57ec36238456eb44371ac40aa0e94
|
F src/mem2.c 2ba377e2f7d57ec36238456eb44371ac40aa0e94
|
||||||
@@ -134,7 +134,7 @@ F src/sqlite.h.in 1ef41c05bf64d580e77e6c57f8705cdf36f37be0
|
|||||||
F src/sqlite3ext.h 9a26028378c288af500d8b94ed079666fed5806b
|
F src/sqlite3ext.h 9a26028378c288af500d8b94ed079666fed5806b
|
||||||
F src/sqliteInt.h 1dd9226a6f2f048222d5a5df38ab8cd26d8ece5d
|
F src/sqliteInt.h 1dd9226a6f2f048222d5a5df38ab8cd26d8ece5d
|
||||||
F src/sqliteLimit.h 1bcbbdfa856f8b71b561abb31edb864b0eca1d12
|
F src/sqliteLimit.h 1bcbbdfa856f8b71b561abb31edb864b0eca1d12
|
||||||
F src/table.c c725e47f6f3092b9a7b569fc58e408e2173ee008
|
F src/table.c 1aeb9eab57b4235db86fe15a35dec76fb445a9c4
|
||||||
F src/tclsqlite.c d76af53f45c9e9f7f7d39531fa4c7bee7d0adad6
|
F src/tclsqlite.c d76af53f45c9e9f7f7d39531fa4c7bee7d0adad6
|
||||||
F src/test1.c 8b20d1f05777ac480d3caf8d5f79ab7a543513fc
|
F src/test1.c 8b20d1f05777ac480d3caf8d5f79ab7a543513fc
|
||||||
F src/test2.c 4ab230fbdc0decfa7422f6a052b609ba54f4dfac
|
F src/test2.c 4ab230fbdc0decfa7422f6a052b609ba54f4dfac
|
||||||
@@ -165,13 +165,13 @@ F src/vacuum.c 38745037c63246d1b0669038257890cf89fc4578
|
|||||||
F src/vdbe.c 9f2ef520614425016881234965b8146ac771d7dc
|
F src/vdbe.c 9f2ef520614425016881234965b8146ac771d7dc
|
||||||
F src/vdbe.h 498e9ddade4baf70f2fc39e585670131dde07caa
|
F src/vdbe.h 498e9ddade4baf70f2fc39e585670131dde07caa
|
||||||
F src/vdbeInt.h 630145b9bfaa19190ab491f52658a7db550f2247
|
F src/vdbeInt.h 630145b9bfaa19190ab491f52658a7db550f2247
|
||||||
F src/vdbeapi.c 7737b6e07ea6547c6a83b2432832fe36309e2ce7
|
F src/vdbeapi.c 9c2d681b75e4b90c28b9dd01a3f2e5905267f884
|
||||||
F src/vdbeaux.c 7cc1e0b33e4d5b8259fd12b7bd28c2180903146c
|
F src/vdbeaux.c 7cc1e0b33e4d5b8259fd12b7bd28c2180903146c
|
||||||
F src/vdbeblob.c d12ed95dac0992e1e372d079d76af047cc42f7c7
|
F src/vdbeblob.c d12ed95dac0992e1e372d079d76af047cc42f7c7
|
||||||
F src/vdbefifo.c 334c838c8f42d61a94813d136019ee566b5dc2f6
|
F src/vdbefifo.c 334c838c8f42d61a94813d136019ee566b5dc2f6
|
||||||
F src/vdbemem.c de0f4df15900f274e8fe43753f59ab115255b788
|
F src/vdbemem.c 246d434fa60bde6553490eb686adfd86adcd6712
|
||||||
F src/vtab.c 5b8d7ec77b9babba1b48072576bf30b43d543163
|
F src/vtab.c ace9b41a088f6ad55d2e39084d92180a2bee3276
|
||||||
F src/where.c beade77e34619553fa425d52891b1b102f35c933
|
F src/where.c 4687a2a56bc0fe66ad457958ea9f72b6cae17426
|
||||||
F tclinstaller.tcl 4356d9d94d2b5ed5e68f9f0c80c4df3048dd7617
|
F tclinstaller.tcl 4356d9d94d2b5ed5e68f9f0c80c4df3048dd7617
|
||||||
F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
|
F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
|
||||||
F test/all.test 0b2117b4ccbb3dc88a5259d1735a04d20584b92b
|
F test/all.test 0b2117b4ccbb3dc88a5259d1735a04d20584b92b
|
||||||
@@ -567,7 +567,7 @@ F www/tclsqlite.tcl 8be95ee6dba05eabcd27a9d91331c803f2ce2130
|
|||||||
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
|
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
|
||||||
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
|
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
|
||||||
F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
|
F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
|
||||||
P e38ef81b85feb5bff2ad8448f3438ff0ab36571e
|
P d8ef7024172fffee049cfda6707220af2577e9a1
|
||||||
R 4005574fa538fb54a130f6155d3c58ce
|
R 02e243d6b7b8198a44d4e659876a4584
|
||||||
U drh
|
U danielk1977
|
||||||
Z 0efa78184b21c87b5dc9bb414aa7047b
|
Z e737eb1ddcb93155a8d9637fcf24015b
|
||||||
|
@@ -1 +1 @@
|
|||||||
d8ef7024172fffee049cfda6707220af2577e9a1
|
c790c234c369c6b7610e67dcaaa9eee347df729c
|
@@ -12,7 +12,7 @@
|
|||||||
** This file contains C code routines that used to generate VDBE code
|
** This file contains C code routines that used to generate VDBE code
|
||||||
** that implements the ALTER TABLE command.
|
** that implements the ALTER TABLE command.
|
||||||
**
|
**
|
||||||
** $Id: alter.c,v 1.31 2007/08/29 04:00:58 drh Exp $
|
** $Id: alter.c,v 1.32 2007/08/29 14:06:23 danielk1977 Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
@@ -591,7 +591,7 @@ void sqlite3AlterBeginAddColumn(Parse *pParse, SrcList *pSrc){
|
|||||||
assert( pNew->nCol>0 );
|
assert( pNew->nCol>0 );
|
||||||
nAlloc = (((pNew->nCol-1)/8)*8)+8;
|
nAlloc = (((pNew->nCol-1)/8)*8)+8;
|
||||||
assert( nAlloc>=pNew->nCol && nAlloc%8==0 && nAlloc-pNew->nCol<8 );
|
assert( nAlloc>=pNew->nCol && nAlloc%8==0 && nAlloc-pNew->nCol<8 );
|
||||||
pNew->aCol = (Column*)sqlite3MallocZero(sizeof(Column)*nAlloc);
|
pNew->aCol = (Column*)sqlite3DbMallocZero(db, sizeof(Column)*nAlloc);
|
||||||
pNew->zName = sqlite3DbStrDup(db, pTab->zName);
|
pNew->zName = sqlite3DbStrDup(db, pTab->zName);
|
||||||
if( !pNew->aCol || !pNew->zName ){
|
if( !pNew->aCol || !pNew->zName ){
|
||||||
db->mallocFailed = 1;
|
db->mallocFailed = 1;
|
||||||
|
13
src/build.c
13
src/build.c
@@ -22,7 +22,7 @@
|
|||||||
** COMMIT
|
** COMMIT
|
||||||
** ROLLBACK
|
** ROLLBACK
|
||||||
**
|
**
|
||||||
** $Id: build.c,v 1.441 2007/08/29 12:31:26 danielk1977 Exp $
|
** $Id: build.c,v 1.442 2007/08/29 14:06:23 danielk1977 Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
@@ -800,7 +800,7 @@ void sqlite3StartTable(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pTable = sqlite3MallocZero( sizeof(Table) );
|
pTable = sqlite3DbMallocZero(db, sizeof(Table));
|
||||||
if( pTable==0 ){
|
if( pTable==0 ){
|
||||||
db->mallocFailed = 1;
|
db->mallocFailed = 1;
|
||||||
pParse->rc = SQLITE_NOMEM;
|
pParse->rc = SQLITE_NOMEM;
|
||||||
@@ -933,9 +933,8 @@ void sqlite3AddColumn(Parse *pParse, Token *pName){
|
|||||||
}
|
}
|
||||||
if( (p->nCol & 0x7)==0 ){
|
if( (p->nCol & 0x7)==0 ){
|
||||||
Column *aNew;
|
Column *aNew;
|
||||||
aNew = sqlite3_realloc( p->aCol, (p->nCol+8)*sizeof(p->aCol[0]));
|
aNew = sqlite3DbRealloc(pParse->db,p->aCol,(p->nCol+8)*sizeof(p->aCol[0]));
|
||||||
if( aNew==0 ){
|
if( aNew==0 ){
|
||||||
pParse->db->mallocFailed = 1;
|
|
||||||
sqlite3_free(z);
|
sqlite3_free(z);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -2829,9 +2828,8 @@ void *sqlite3ArrayAllocate(
|
|||||||
void *pNew;
|
void *pNew;
|
||||||
int newSize;
|
int newSize;
|
||||||
newSize = (*pnAlloc)*2 + initSize;
|
newSize = (*pnAlloc)*2 + initSize;
|
||||||
pNew = sqlite3_realloc(pArray, newSize*szEntry);
|
pNew = sqlite3DbRealloc(db, pArray, newSize*szEntry);
|
||||||
if( pNew==0 ){
|
if( pNew==0 ){
|
||||||
db->mallocFailed = 1;
|
|
||||||
*pIdx = -1;
|
*pIdx = -1;
|
||||||
return pArray;
|
return pArray;
|
||||||
}
|
}
|
||||||
@@ -2941,10 +2939,9 @@ SrcList *sqlite3SrcListAppend(
|
|||||||
if( pList->nSrc>=pList->nAlloc ){
|
if( pList->nSrc>=pList->nAlloc ){
|
||||||
SrcList *pNew;
|
SrcList *pNew;
|
||||||
pList->nAlloc *= 2;
|
pList->nAlloc *= 2;
|
||||||
pNew = sqlite3_realloc(pList,
|
pNew = sqlite3DbRealloc(db, pList,
|
||||||
sizeof(*pList) + (pList->nAlloc-1)*sizeof(pList->a[0]) );
|
sizeof(*pList) + (pList->nAlloc-1)*sizeof(pList->a[0]) );
|
||||||
if( pNew==0 ){
|
if( pNew==0 ){
|
||||||
db->mallocFailed = 1;
|
|
||||||
sqlite3SrcListDelete(pList);
|
sqlite3SrcListDelete(pList);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@@ -12,7 +12,7 @@
|
|||||||
** This file contains routines used for analyzing expressions and
|
** This file contains routines used for analyzing expressions and
|
||||||
** for generating VDBE code that evaluates expressions in SQLite.
|
** for generating VDBE code that evaluates expressions in SQLite.
|
||||||
**
|
**
|
||||||
** $Id: expr.c,v 1.309 2007/08/29 12:31:26 danielk1977 Exp $
|
** $Id: expr.c,v 1.310 2007/08/29 14:06:23 danielk1977 Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
@@ -665,7 +665,7 @@ ExprList *sqlite3ExprListAppend(
|
|||||||
if( pList->nAlloc<=pList->nExpr ){
|
if( pList->nAlloc<=pList->nExpr ){
|
||||||
struct ExprList_item *a;
|
struct ExprList_item *a;
|
||||||
int n = pList->nAlloc*2 + 4;
|
int n = pList->nAlloc*2 + 4;
|
||||||
a = sqlite3_realloc(pList->a, n*sizeof(pList->a[0]));
|
a = sqlite3DbRealloc(db, pList->a, n*sizeof(pList->a[0]));
|
||||||
if( a==0 ){
|
if( a==0 ){
|
||||||
goto no_mem;
|
goto no_mem;
|
||||||
}
|
}
|
||||||
@@ -683,7 +683,6 @@ ExprList *sqlite3ExprListAppend(
|
|||||||
|
|
||||||
no_mem:
|
no_mem:
|
||||||
/* Avoid leaking memory if malloc has failed. */
|
/* Avoid leaking memory if malloc has failed. */
|
||||||
db->mallocFailed = 1;
|
|
||||||
sqlite3ExprDelete(pExpr);
|
sqlite3ExprDelete(pExpr);
|
||||||
sqlite3ExprListDelete(pList);
|
sqlite3ExprListDelete(pList);
|
||||||
return 0;
|
return 0;
|
||||||
|
16
src/func.c
16
src/func.c
@@ -16,7 +16,7 @@
|
|||||||
** sqliteRegisterBuildinFunctions() found at the bottom of the file.
|
** sqliteRegisterBuildinFunctions() found at the bottom of the file.
|
||||||
** All other code has file scope.
|
** All other code has file scope.
|
||||||
**
|
**
|
||||||
** $Id: func.c,v 1.170 2007/08/29 12:31:26 danielk1977 Exp $
|
** $Id: func.c,v 1.171 2007/08/29 14:06:23 danielk1977 Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
@@ -234,6 +234,11 @@ static void roundFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
|
|||||||
sqlite3_result_double(context, r);
|
sqlite3_result_double(context, r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Allocate nByte bytes of space using sqlite3_malloc(). If the
|
||||||
|
** allocation fails, call sqlite3_result_error_nomem() to notify
|
||||||
|
** the database handle that malloc() has failed.
|
||||||
|
*/
|
||||||
static void *contextMalloc(sqlite3_context *context, int nByte){
|
static void *contextMalloc(sqlite3_context *context, int nByte){
|
||||||
char *z = sqlite3_malloc(nByte);
|
char *z = sqlite3_malloc(nByte);
|
||||||
if( !z && nByte>0 ){
|
if( !z && nByte>0 ){
|
||||||
@@ -1074,10 +1079,11 @@ static void test_destructor(
|
|||||||
assert( nArg==1 );
|
assert( nArg==1 );
|
||||||
if( sqlite3_value_type(argv[0])==SQLITE_NULL ) return;
|
if( sqlite3_value_type(argv[0])==SQLITE_NULL ) return;
|
||||||
len = sqlite3ValueBytes(argv[0], ENC(db));
|
len = sqlite3ValueBytes(argv[0], ENC(db));
|
||||||
zVal = sqlite3MallocZero(len+3);
|
zVal = contextMalloc(pCtx, len+3);
|
||||||
zVal[len] = 0;
|
if( !zVal ){
|
||||||
zVal[len-1] = 0;
|
return;
|
||||||
assert( zVal );
|
}
|
||||||
|
zVal[len+1] = 0;
|
||||||
zVal++;
|
zVal++;
|
||||||
memcpy(zVal, sqlite3ValueText(argv[0], ENC(db)), len);
|
memcpy(zVal, sqlite3ValueText(argv[0], ENC(db)), len);
|
||||||
if( ENC(db)==SQLITE_UTF8 ){
|
if( ENC(db)==SQLITE_UTF8 ){
|
||||||
|
@@ -12,7 +12,7 @@
|
|||||||
** Memory allocation functions used throughout sqlite.
|
** Memory allocation functions used throughout sqlite.
|
||||||
**
|
**
|
||||||
**
|
**
|
||||||
** $Id: malloc.c,v 1.12 2007/08/29 12:31:26 danielk1977 Exp $
|
** $Id: malloc.c,v 1.13 2007/08/29 14:06:23 danielk1977 Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
@@ -104,6 +104,10 @@ void *sqlite3DbMallocRaw(sqlite3 *db, unsigned n){
|
|||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Resize the block of memory pointed to by p to n bytes. If the
|
||||||
|
** resize fails, set the mallocFailed flag inthe connection object.
|
||||||
|
*/
|
||||||
void *sqlite3DbRealloc(sqlite3 *db, void *p, int n){
|
void *sqlite3DbRealloc(sqlite3 *db, void *p, int n){
|
||||||
void *pNew = 0;
|
void *pNew = 0;
|
||||||
if( db->mallocFailed==0 ){
|
if( db->mallocFailed==0 ){
|
||||||
|
13
src/table.c
13
src/table.c
@@ -143,6 +143,11 @@ int sqlite3_get_table(
|
|||||||
if( res.azResult==0 ) return SQLITE_NOMEM;
|
if( res.azResult==0 ) return SQLITE_NOMEM;
|
||||||
res.azResult[0] = 0;
|
res.azResult[0] = 0;
|
||||||
rc = sqlite3_exec(db, zSql, sqlite3_get_table_cb, &res, pzErrMsg);
|
rc = sqlite3_exec(db, zSql, sqlite3_get_table_cb, &res, pzErrMsg);
|
||||||
|
#ifndef NDEBUG
|
||||||
|
sqlite3_mutex_enter(db->mutex);
|
||||||
|
assert((rc&db->errMask)==rc && (res.rc&db->errMask)==res.rc);
|
||||||
|
sqlite3_mutex_leave(db->mutex);
|
||||||
|
#endif
|
||||||
if( res.azResult ){
|
if( res.azResult ){
|
||||||
assert( sizeof(res.azResult[0])>= sizeof(res.nData) );
|
assert( sizeof(res.azResult[0])>= sizeof(res.nData) );
|
||||||
res.azResult[0] = (char*)res.nData;
|
res.azResult[0] = (char*)res.nData;
|
||||||
@@ -156,13 +161,15 @@ int sqlite3_get_table(
|
|||||||
}
|
}
|
||||||
sqlite3_free(res.zErrMsg);
|
sqlite3_free(res.zErrMsg);
|
||||||
}
|
}
|
||||||
|
sqlite3_mutex_enter(db->mutex);
|
||||||
db->errCode = res.rc;
|
db->errCode = res.rc;
|
||||||
return res.rc & db->errMask;
|
sqlite3_mutex_leave(db->mutex);
|
||||||
|
return res.rc;
|
||||||
}
|
}
|
||||||
sqlite3_free(res.zErrMsg);
|
sqlite3_free(res.zErrMsg);
|
||||||
if( rc!=SQLITE_OK ){
|
if( rc!=SQLITE_OK ){
|
||||||
sqlite3_free_table(&res.azResult[1]);
|
sqlite3_free_table(&res.azResult[1]);
|
||||||
return rc & db->errMask;
|
return rc;
|
||||||
}
|
}
|
||||||
if( res.nAlloc>res.nData ){
|
if( res.nAlloc>res.nData ){
|
||||||
char **azNew;
|
char **azNew;
|
||||||
@@ -177,7 +184,7 @@ int sqlite3_get_table(
|
|||||||
*pazResult = &res.azResult[1];
|
*pazResult = &res.azResult[1];
|
||||||
if( pnColumn ) *pnColumn = res.nColumn;
|
if( pnColumn ) *pnColumn = res.nColumn;
|
||||||
if( pnRow ) *pnRow = res.nRow;
|
if( pnRow ) *pnRow = res.nRow;
|
||||||
return rc & db->errMask;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -491,9 +491,8 @@ void sqlite3_set_auxdata(
|
|||||||
if( !pVdbeFunc || pVdbeFunc->nAux<=iArg ){
|
if( !pVdbeFunc || pVdbeFunc->nAux<=iArg ){
|
||||||
int nAux = (pVdbeFunc ? pVdbeFunc->nAux : 0);
|
int nAux = (pVdbeFunc ? pVdbeFunc->nAux : 0);
|
||||||
int nMalloc = sizeof(VdbeFunc) + sizeof(struct AuxData)*iArg;
|
int nMalloc = sizeof(VdbeFunc) + sizeof(struct AuxData)*iArg;
|
||||||
pVdbeFunc = sqlite3_realloc(pVdbeFunc, nMalloc);
|
pVdbeFunc = sqlite3DbRealloc(pCtx->s.db, pVdbeFunc, nMalloc);
|
||||||
if( !pVdbeFunc ){
|
if( !pVdbeFunc ){
|
||||||
pCtx->s.db->mallocFailed = 1;
|
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
pCtx->pVdbeFunc = pVdbeFunc;
|
pCtx->pVdbeFunc = pVdbeFunc;
|
||||||
|
@@ -901,13 +901,11 @@ const void *sqlite3ValueText(sqlite3_value* pVal, u8 enc){
|
|||||||
** Create a new sqlite3_value object.
|
** Create a new sqlite3_value object.
|
||||||
*/
|
*/
|
||||||
sqlite3_value *sqlite3ValueNew(sqlite3 *db){
|
sqlite3_value *sqlite3ValueNew(sqlite3 *db){
|
||||||
Mem *p = sqlite3MallocZero(sizeof(*p));
|
Mem *p = sqlite3DbMallocZero(db, sizeof(*p));
|
||||||
if( p ){
|
if( p ){
|
||||||
p->flags = MEM_Null;
|
p->flags = MEM_Null;
|
||||||
p->type = SQLITE_NULL;
|
p->type = SQLITE_NULL;
|
||||||
p->db = db;
|
p->db = db;
|
||||||
}else if( db ){
|
|
||||||
db->mallocFailed = 1;
|
|
||||||
}
|
}
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
@@ -11,7 +11,7 @@
|
|||||||
*************************************************************************
|
*************************************************************************
|
||||||
** This file contains code used to help implement virtual tables.
|
** This file contains code used to help implement virtual tables.
|
||||||
**
|
**
|
||||||
** $Id: vtab.c,v 1.55 2007/08/29 12:31:29 danielk1977 Exp $
|
** $Id: vtab.c,v 1.56 2007/08/29 14:06:23 danielk1977 Exp $
|
||||||
*/
|
*/
|
||||||
#ifndef SQLITE_OMIT_VIRTUALTABLE
|
#ifndef SQLITE_OMIT_VIRTUALTABLE
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
@@ -136,7 +136,7 @@ static void addModuleArgument(sqlite3 *db, Table *pTable, char *zArg){
|
|||||||
int i = pTable->nModuleArg++;
|
int i = pTable->nModuleArg++;
|
||||||
int nBytes = sizeof(char *)*(1+pTable->nModuleArg);
|
int nBytes = sizeof(char *)*(1+pTable->nModuleArg);
|
||||||
char **azModuleArg;
|
char **azModuleArg;
|
||||||
azModuleArg = sqlite3_realloc(pTable->azModuleArg, nBytes);
|
azModuleArg = sqlite3DbRealloc(db, pTable->azModuleArg, nBytes);
|
||||||
if( azModuleArg==0 ){
|
if( azModuleArg==0 ){
|
||||||
int j;
|
int j;
|
||||||
for(j=0; j<i; j++){
|
for(j=0; j<i; j++){
|
||||||
@@ -145,7 +145,6 @@ static void addModuleArgument(sqlite3 *db, Table *pTable, char *zArg){
|
|||||||
sqlite3_free(zArg);
|
sqlite3_free(zArg);
|
||||||
sqlite3_free(pTable->azModuleArg);
|
sqlite3_free(pTable->azModuleArg);
|
||||||
pTable->nModuleArg = 0;
|
pTable->nModuleArg = 0;
|
||||||
db->mallocFailed = 1;
|
|
||||||
}else{
|
}else{
|
||||||
azModuleArg[i] = zArg;
|
azModuleArg[i] = zArg;
|
||||||
azModuleArg[i+1] = 0;
|
azModuleArg[i+1] = 0;
|
||||||
@@ -469,9 +468,8 @@ static int addToVTrans(sqlite3 *db, sqlite3_vtab *pVtab){
|
|||||||
if( (db->nVTrans%ARRAY_INCR)==0 ){
|
if( (db->nVTrans%ARRAY_INCR)==0 ){
|
||||||
sqlite3_vtab **aVTrans;
|
sqlite3_vtab **aVTrans;
|
||||||
int nBytes = sizeof(sqlite3_vtab *) * (db->nVTrans + ARRAY_INCR);
|
int nBytes = sizeof(sqlite3_vtab *) * (db->nVTrans + ARRAY_INCR);
|
||||||
aVTrans = sqlite3_realloc((void *)db->aVTrans, nBytes);
|
aVTrans = sqlite3DbRealloc(db, (void *)db->aVTrans, nBytes);
|
||||||
if( !aVTrans ){
|
if( !aVTrans ){
|
||||||
db->mallocFailed = 1;
|
|
||||||
return SQLITE_NOMEM;
|
return SQLITE_NOMEM;
|
||||||
}
|
}
|
||||||
memset(&aVTrans[db->nVTrans], 0, sizeof(sqlite3_vtab *)*ARRAY_INCR);
|
memset(&aVTrans[db->nVTrans], 0, sizeof(sqlite3_vtab *)*ARRAY_INCR);
|
||||||
|
@@ -16,7 +16,7 @@
|
|||||||
** so is applicable. Because this module is responsible for selecting
|
** so is applicable. Because this module is responsible for selecting
|
||||||
** indices, you might also think of this module as the "query optimizer".
|
** indices, you might also think of this module as the "query optimizer".
|
||||||
**
|
**
|
||||||
** $Id: where.c,v 1.258 2007/08/29 12:31:29 danielk1977 Exp $
|
** $Id: where.c,v 1.259 2007/08/29 14:06:23 danielk1977 Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
|
|
||||||
@@ -1260,11 +1260,10 @@ static double bestVirtualIndex(
|
|||||||
|
|
||||||
/* Allocate the sqlite3_index_info structure
|
/* Allocate the sqlite3_index_info structure
|
||||||
*/
|
*/
|
||||||
pIdxInfo = sqlite3MallocZero( sizeof(*pIdxInfo)
|
pIdxInfo = sqlite3DbMallocZero(pParse->db, sizeof(*pIdxInfo)
|
||||||
+ (sizeof(*pIdxCons) + sizeof(*pUsage))*nTerm
|
+ (sizeof(*pIdxCons) + sizeof(*pUsage))*nTerm
|
||||||
+ sizeof(*pIdxOrderBy)*nOrderBy );
|
+ sizeof(*pIdxOrderBy)*nOrderBy );
|
||||||
if( pIdxInfo==0 ){
|
if( pIdxInfo==0 ){
|
||||||
pParse->db->mallocFailed = 1;
|
|
||||||
sqlite3ErrorMsg(pParse, "out of memory");
|
sqlite3ErrorMsg(pParse, "out of memory");
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user