1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-05 15:55:57 +03:00

Code cleanup: get rid of the sqlite3SetNString utility function. (CVS 1984)

FossilOrigin-Name: 9ef4c24a9acc2128891303de1ffd2ef4509d779c
This commit is contained in:
drh
2004-09-25 14:39:18 +00:00
parent 94a11211f5
commit ae29ffbe23
11 changed files with 50 additions and 127 deletions

View File

@@ -1,5 +1,5 @@
C Code\ssimplifications\sand\ssize\sreductions.\s(CVS\s1983) C Code\scleanup:\sget\srid\sof\sthe\ssqlite3SetNString\sutility\sfunction.\s(CVS\s1984)
D 2004-09-25T13:12:15 D 2004-09-25T14:39:18
F Makefile.in abdeb5bd9d017822691884935c320037c33f6ee6 F Makefile.in abdeb5bd9d017822691884935c320037c33f6ee6
F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457 F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457
F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
@@ -30,7 +30,7 @@ F src/attach.c e49d09dad9f5f9fb10b4b0c1be5a70ae4c45e689
F src/auth.c 65408baa7e6621520882478dfa1e6b8c1d6c1850 F src/auth.c 65408baa7e6621520882478dfa1e6b8c1d6c1850
F src/btree.c 470e00b08688f065c2e62a6dcd3fb18880e8e309 F src/btree.c 470e00b08688f065c2e62a6dcd3fb18880e8e309
F src/btree.h 94dfec0a1722d33359b23e7e310f2b64ffedf029 F src/btree.h 94dfec0a1722d33359b23e7e310f2b64ffedf029
F src/build.c c5ecf114af4ebc2963a03142b6bd6f2284ee35fc F src/build.c 86318bdcd291919d4f87700385fdb73146436531
F src/date.c eb8d5fa1a6d5cfc09031c8852d10ff742a94b15b F src/date.c eb8d5fa1a6d5cfc09031c8852d10ff742a94b15b
F src/delete.c d862b383a9abc0b79f4588783c2619fe52d74ea7 F src/delete.c d862b383a9abc0b79f4588783c2619fe52d74ea7
F src/expr.c f255c5c56c0371cb2955cbc2733621051e4f79f8 F src/expr.c f255c5c56c0371cb2955cbc2733621051e4f79f8
@@ -39,7 +39,7 @@ F src/hash.c a97721a55440b7bea31ffe471bb2f6b4123cddd5
F src/hash.h 1b0c445e1c89ff2aaad9b4605ba61375af001e84 F src/hash.h 1b0c445e1c89ff2aaad9b4605ba61375af001e84
F src/insert.c 2c10c001f62cde92e9517ec7516b6584519754d1 F src/insert.c 2c10c001f62cde92e9517ec7516b6584519754d1
F src/legacy.c d58ea507bce885298a2c8c3cbb0f4bff5d47830b F src/legacy.c d58ea507bce885298a2c8c3cbb0f4bff5d47830b
F src/main.c 82a952ef3e5f7bacaa1b20060d0588f8767a6774 F src/main.c b86dacaaa09eb614dec7051a8a006434a7bcaa06
F src/md5.c 7ae1c39044b95de2f62e066f47bb1deb880a1070 F src/md5.c 7ae1c39044b95de2f62e066f47bb1deb880a1070
F src/os.h d1780e0db95cad01f213d48da22ab490eb4fd345 F src/os.h d1780e0db95cad01f213d48da22ab490eb4fd345
F src/os_common.h cd7eb025fdab7dc91e0e97bf6310f1648205857f F src/os_common.h cd7eb025fdab7dc91e0e97bf6310f1648205857f
@@ -54,31 +54,31 @@ F src/os_win.h babd4e912967c6b09088cfe38a45e8005a07ba44
F src/pager.c 705a61117f05d7dd031762408f9a279834e88c3a F src/pager.c 705a61117f05d7dd031762408f9a279834e88c3a
F src/pager.h 67739fe649f33be55dba522ca8a9cc4e42d14f71 F src/pager.h 67739fe649f33be55dba522ca8a9cc4e42d14f71
F src/parse.y 93edda0f1e9b25bee7cdfb5bf624ae85f8e9e5c9 F src/parse.y 93edda0f1e9b25bee7cdfb5bf624ae85f8e9e5c9
F src/pragma.c 5fb6647fda4c95edb08447a505e6c98c041e5b31 F src/pragma.c 45978cc82fdf91f00d024a8e875c2b679fbce488
F src/printf.c 40770e1f553612d13dfc86d236086e69baa62fe1 F src/printf.c 40770e1f553612d13dfc86d236086e69baa62fe1
F src/random.c eff68e3f257e05e81eae6c4d50a51eb88beb4ff3 F src/random.c eff68e3f257e05e81eae6c4d50a51eb88beb4ff3
F src/select.c 97c5f11b2b456dc6113454e592dbf03dc46e2b9d F src/select.c 96b1489111abe9b584be2f2cce26ad6f2d425b4e
F src/shell.c 0856973c2b94e22664bc43f398ba3fc22d5e080c F src/shell.c 0856973c2b94e22664bc43f398ba3fc22d5e080c
F src/sqlite.h.in e29a526593b806f148017ed8bada760ada84cf2f F src/sqlite.h.in e29a526593b806f148017ed8bada760ada84cf2f
F src/sqliteInt.h 581437ae245e5b8294bfc20c9a06a16bb6b3d281 F src/sqliteInt.h 1259d965d61209d35e5fb3704ab5167a8a123a72
F src/table.c 8168c6e824009f8485bff79fc60ea8fea6829b10 F src/table.c 549f324e3239d3c3658e333e5e422bdcab81b9a0
F src/tclsqlite.c 0302e3f42f015d132d1291f3388c06e86c24a008 F src/tclsqlite.c 0302e3f42f015d132d1291f3388c06e86c24a008
F src/test1.c 1305825c29575ee55a1c8b98a191669fd78b6287 F src/test1.c 1305825c29575ee55a1c8b98a191669fd78b6287
F src/test2.c 0f3e0ad7b675a6f3323211ab4ea95490855654c3 F src/test2.c 0f3e0ad7b675a6f3323211ab4ea95490855654c3
F src/test3.c 5b5b0f3d11b097399c1054fff73d8f3711092301 F src/test3.c 5b5b0f3d11b097399c1054fff73d8f3711092301
F src/test4.c 7c6b9fc33dd1f3f93c7f1ee6e5e6d016afa6c1df F src/test4.c 7c6b9fc33dd1f3f93c7f1ee6e5e6d016afa6c1df
F src/test5.c b001fa7f1b9e2dc5c2331de62fc641b5ab2bd7a1 F src/test5.c b001fa7f1b9e2dc5c2331de62fc641b5ab2bd7a1
F src/tokenize.c 418ef7ba1149603a30dcf0057e04a3ea0e99edbe F src/tokenize.c 85a5b0de4635bc96ec9860274449448ff0d0726d
F src/trigger.c d1f770ee37a80391dd6d0948ee821b0272f99ae7 F src/trigger.c d1f770ee37a80391dd6d0948ee821b0272f99ae7
F src/update.c 7157084216c4b02a23cdb23eb6d246aa9034fa4d F src/update.c 7157084216c4b02a23cdb23eb6d246aa9034fa4d
F src/utf.c f4f83acd73389090e32d6589d307fc55d794c7ed F src/utf.c f4f83acd73389090e32d6589d307fc55d794c7ed
F src/util.c f9b661a3b80a1469777771776a59a5f0e2f193fc F src/util.c 39a6718b221b5c575e09bb9069ec7c7fb539d5a5
F src/vacuum.c 257de36230cb988842f66eb08dc6c0250b8e05f3 F src/vacuum.c 257de36230cb988842f66eb08dc6c0250b8e05f3
F src/vdbe.c 0542852785220807feb02b9dee1150ac2e592c8d F src/vdbe.c 0542852785220807feb02b9dee1150ac2e592c8d
F src/vdbe.h 067ca8d6750ba4f69a50284765e5883dee860181 F src/vdbe.h 067ca8d6750ba4f69a50284765e5883dee860181
F src/vdbeInt.h 6017100adff362b8dfa37a69e3f1431f084bfa5b F src/vdbeInt.h 6017100adff362b8dfa37a69e3f1431f084bfa5b
F src/vdbeapi.c 81ab9e84c55f5762f552904e6e5d309269b02017 F src/vdbeapi.c 81ab9e84c55f5762f552904e6e5d309269b02017
F src/vdbeaux.c dc3848209aee05b32636a9c1dd913a56ef8dac79 F src/vdbeaux.c 598af6c20124a205306475cd9dcee04317d0c622
F src/vdbemem.c ef9ac7d32acfe4bce5c5b408b1294c8d9e0cdb56 F src/vdbemem.c ef9ac7d32acfe4bce5c5b408b1294c8d9e0cdb56
F src/where.c 04d3ee039d8e66c520e3b6bd5103dc3b8c3eb76b F src/where.c 04d3ee039d8e66c520e3b6bd5103dc3b8c3eb76b
F test/all.test 929bfa932b55e75c96fe2203f7650ba451c1862c F test/all.test 929bfa932b55e75c96fe2203f7650ba451c1862c
@@ -247,7 +247,7 @@ F www/tclsqlite.tcl 560ecd6a916b320e59f2917317398f3d59b7cc25
F www/vdbe.tcl 59288db1ac5c0616296b26dce071c36cb611dfe9 F www/vdbe.tcl 59288db1ac5c0616296b26dce071c36cb611dfe9
F www/version3.tcl 092a01f5ef430d2c4acc0ae558d74c4bb89638a0 F www/version3.tcl 092a01f5ef430d2c4acc0ae558d74c4bb89638a0
F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4 F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4
P b2f3d4bb8e24212d3cef7615c24da13f29c1440c P cb631a135da92fd689ee40a8b7e2695a510eb765
R 7b7549a8227df9a562548ecaa05d3fba R 0e57f8bf788b1fab54d791e8a0ff38cb
U drh U drh
Z e21d66c92b9e14b190cf7982b2d07af5 Z 4e1f4e3ae25eddb22e2a4ce1e3a8ec1c

View File

@@ -1 +1 @@
cb631a135da92fd689ee40a8b7e2695a510eb765 9ef4c24a9acc2128891303de1ffd2ef4509d779c

View File

@@ -23,7 +23,7 @@
** ROLLBACK ** ROLLBACK
** PRAGMA ** PRAGMA
** **
** $Id: build.c,v 1.253 2004/09/15 13:38:11 drh Exp $ ** $Id: build.c,v 1.254 2004/09/25 14:39:18 drh Exp $
*/ */
#include "sqliteInt.h" #include "sqliteInt.h"
#include <ctype.h> #include <ctype.h>
@@ -785,8 +785,8 @@ void sqlite3AddColumnType(Parse *pParse, Token *pFirst, Token *pLast){
pCol = &p->aCol[i]; pCol = &p->aCol[i];
pz = &pCol->zType; pz = &pCol->zType;
n = pLast->n + Addr(pLast->z) - Addr(pFirst->z); n = pLast->n + Addr(pLast->z) - Addr(pFirst->z);
sqlite3SetNString(pz, pFirst->z, n, (char*)0); assert( pCol->zType==0 );
z = *pz; z = pCol->zType = sqlite3MPrintf("%.*s", n, pFirst->z);
if( z==0 ) return; if( z==0 ) return;
for(i=j=0; z[i]; i++){ for(i=j=0; z[i]; i++){
int c = z[i]; int c = z[i];
@@ -808,17 +808,13 @@ void sqlite3AddColumnType(Parse *pParse, Token *pFirst, Token *pLast){
void sqlite3AddDefaultValue(Parse *pParse, Token *pVal, int minusFlag){ void sqlite3AddDefaultValue(Parse *pParse, Token *pVal, int minusFlag){
Table *p; Table *p;
int i; int i;
char **pz; char *z;
if( (p = pParse->pNewTable)==0 ) return; if( (p = pParse->pNewTable)==0 ) return;
i = p->nCol-1; i = p->nCol-1;
if( i<0 ) return; if( i<0 ) return;
pz = &p->aCol[i].zDflt; assert( p->aCol[i].zDflt==0 );
if( minusFlag ){ z = p->aCol[i].zDflt = sqlite3MPrintf("%s%T", minusFlag ? "-" : "", pVal);
sqlite3SetNString(pz, "-", 1, pVal->z, pVal->n, (char*)0); sqlite3Dequote(z);
}else{
sqlite3SetNString(pz, pVal->z, pVal->n, (char*)0);
}
sqlite3Dequote(*pz);
} }
/* /*
@@ -1016,8 +1012,7 @@ static int synthCollSeq(Parse *pParse, CollSeq *pColl){
} }
} }
if( pParse->nErr==0 ){ if( pParse->nErr==0 ){
sqlite3SetNString(&pParse->zErrMsg, "no such collation sequence: ", sqlite3ErrorMsg(pParse, "no such collation sequence: %.*s", n, z);
-1, z, n, (char*)0);
} }
pParse->nErr++; pParse->nErr++;
return SQLITE_ERROR; return SQLITE_ERROR;
@@ -1082,6 +1077,7 @@ CollSeq *sqlite3LocateCollSeq(Parse *pParse, const char *zName, int nName){
u8 enc = pParse->db->enc; u8 enc = pParse->db->enc;
u8 initbusy = pParse->db->init.busy; u8 initbusy = pParse->db->init.busy;
CollSeq *pColl = sqlite3FindCollSeq(pParse->db, enc, zName, nName, initbusy); CollSeq *pColl = sqlite3FindCollSeq(pParse->db, enc, zName, nName, initbusy);
if( nName<0 ) nName = strlen(zName);
if( !initbusy && (!pColl || !pColl->xCmp) ){ if( !initbusy && (!pColl || !pColl->xCmp) ){
/* No collation sequence of this type for this encoding is registered. /* No collation sequence of this type for this encoding is registered.
** Call the collation factory to see if it can supply us with one. ** Call the collation factory to see if it can supply us with one.
@@ -1101,10 +1097,8 @@ CollSeq *sqlite3LocateCollSeq(Parse *pParse, const char *zName, int nName){
/* If nothing has been found, write the error message into pParse */ /* If nothing has been found, write the error message into pParse */
if( !initbusy && (!pColl || !pColl->xCmp) ){ if( !initbusy && (!pColl || !pColl->xCmp) ){
if( pParse->nErr==0 ){ if( pParse->nErr==0 ){
sqlite3SetNString(&pParse->zErrMsg, "no such collation sequence: ", -1, sqlite3ErrorMsg(pParse, "no such collation sequence: %.*s", nName, zName);
zName, nName, (char*)0);
} }
pParse->nErr++;
pColl = 0; pColl = 0;
} }
return pColl; return pColl;

View File

@@ -14,7 +14,7 @@
** other files are for internal use by SQLite and should not be ** other files are for internal use by SQLite and should not be
** accessed by users of the library. ** accessed by users of the library.
** **
** $Id: main.c,v 1.260 2004/09/15 13:38:11 drh Exp $ ** $Id: main.c,v 1.261 2004/09/25 14:39:18 drh Exp $
*/ */
#include "sqliteInt.h" #include "sqliteInt.h"
#include "os.h" #include "os.h"
@@ -669,9 +669,7 @@ void sqlite3_interrupt(sqlite3 *db){
** SQLite is a DLL. For some reason, it does not work to call free() ** SQLite is a DLL. For some reason, it does not work to call free()
** directly. ** directly.
** **
** Note that we need to call free() not sqliteFree() here, since every ** Note that we need to call free() not sqliteFree() here.
** string that is exported from SQLite should have already passed through
** sqlite3StrRealloc().
*/ */
void sqlite3_free(char *p){ free(p); } void sqlite3_free(char *p){ free(p); }

View File

@@ -11,7 +11,7 @@
************************************************************************* *************************************************************************
** This file contains code used to implement the PRAGMA command. ** This file contains code used to implement the PRAGMA command.
** **
** $Id: pragma.c,v 1.66 2004/09/17 20:25:25 drh Exp $ ** $Id: pragma.c,v 1.67 2004/09/25 14:39:19 drh Exp $
*/ */
#include "sqliteInt.h" #include "sqliteInt.h"
#include <ctype.h> #include <ctype.h>
@@ -207,8 +207,7 @@ void sqlite3Pragma(
zLeft = sqlite3NameFromToken(pId); zLeft = sqlite3NameFromToken(pId);
if( !zLeft ) return; if( !zLeft ) return;
if( minusFlag ){ if( minusFlag ){
zRight = 0; zRight = sqlite3MPrintf("-%T", pValue);
sqlite3SetNString(&zRight, "-", 1, pValue->z, pValue->n, (char*)0);
}else{ }else{
zRight = sqlite3NameFromToken(pValue); zRight = sqlite3NameFromToken(pValue);
} }

View File

@@ -12,7 +12,7 @@
** This file contains C code routines that are called by the parser ** This file contains C code routines that are called by the parser
** to handle SELECT statements in SQLite. ** to handle SELECT statements in SQLite.
** **
** $Id: select.c,v 1.210 2004/09/25 13:12:16 drh Exp $ ** $Id: select.c,v 1.211 2004/09/25 14:39:19 drh Exp $
*/ */
#include "sqliteInt.h" #include "sqliteInt.h"
@@ -116,13 +116,12 @@ int sqlite3JoinType(Parse *pParse, Token *pA, Token *pB, Token *pC){
(jointype & (JT_INNER|JT_OUTER))==(JT_INNER|JT_OUTER) || (jointype & (JT_INNER|JT_OUTER))==(JT_INNER|JT_OUTER) ||
(jointype & JT_ERROR)!=0 (jointype & JT_ERROR)!=0
){ ){
static Token dummy = { 0, 0 }; const char *zSp1 = " ";
char *zSp1 = " ", *zSp2 = " "; const char *zSp2 = " ";
if( pB==0 ){ pB = &dummy; zSp1 = 0; } if( pB==0 ){ zSp1++; }
if( pC==0 ){ pC = &dummy; zSp2 = 0; } if( pC==0 ){ zSp2++; }
sqlite3SetNString(&pParse->zErrMsg, "unknown or unsupported join type: ", 0, sqlite3ErrorMsg(pParse, "unknown or unsupported join type: "
pA->z, pA->n, zSp1, 1, pB->z, pB->n, zSp2, 1, pC->z, pC->n, (char*)0); "%T%s%T%s%T", pA, zSp1, pB, zSp2, pC);
pParse->nErr++;
jointype = JT_INNER; jointype = JT_INNER;
}else if( jointype & JT_RIGHT ){ }else if( jointype & JT_RIGHT ){
sqlite3ErrorMsg(pParse, sqlite3ErrorMsg(pParse,
@@ -480,7 +479,6 @@ static int selectInnerLoop(
if( pOrderBy ){ if( pOrderBy ){
pushOntoSorter(pParse, v, pOrderBy); pushOntoSorter(pParse, v, pOrderBy);
}else{ }else{
char const *affStr;
char aff = (iParm>>16)&0xFF; char aff = (iParm>>16)&0xFF;
aff = sqlite3CompareAffinity(pEList->a[0].pExpr, aff); aff = sqlite3CompareAffinity(pEList->a[0].pExpr, aff);
sqlite3VdbeOp3(v, OP_MakeRecord, 1, 0, &aff, 1); sqlite3VdbeOp3(v, OP_MakeRecord, 1, 0, &aff, 1);

View File

@@ -11,7 +11,7 @@
************************************************************************* *************************************************************************
** Internal interface definitions for SQLite. ** Internal interface definitions for SQLite.
** **
** @(#) $Id: sqliteInt.h,v 1.323 2004/09/25 13:12:16 drh Exp $ ** @(#) $Id: sqliteInt.h,v 1.324 2004/09/25 14:39:19 drh Exp $
*/ */
#ifndef _SQLITEINT_H_ #ifndef _SQLITEINT_H_
#define _SQLITEINT_H_ #define _SQLITEINT_H_
@@ -197,16 +197,13 @@ struct BusyHandler {
# define sqliteRealloc(X,Y) sqlite3Realloc_(X,Y,__FILE__,__LINE__) # define sqliteRealloc(X,Y) sqlite3Realloc_(X,Y,__FILE__,__LINE__)
# define sqliteStrDup(X) sqlite3StrDup_(X,__FILE__,__LINE__) # define sqliteStrDup(X) sqlite3StrDup_(X,__FILE__,__LINE__)
# define sqliteStrNDup(X,Y) sqlite3StrNDup_(X,Y,__FILE__,__LINE__) # define sqliteStrNDup(X,Y) sqlite3StrNDup_(X,Y,__FILE__,__LINE__)
void sqlite3StrRealloc(char**);
#else #else
# define sqliteFree sqlite3FreeX # define sqliteFree sqlite3FreeX
# define sqliteMalloc sqlite3Malloc # define sqliteMalloc sqlite3Malloc
# define sqliteMallocRaw sqlite3MallocRaw # define sqliteMallocRaw sqlite3MallocRaw
# define sqliteRealloc sqlite3Realloc # define sqliteRealloc sqlite3Realloc
/* # define sqliteRealloc_(X,Y) sqlite3Realloc(X,Y) */ # define sqliteStrDup sqlite3StrDup
# define sqlite3StrRealloc(X) # define sqliteStrNDup sqlite3StrNDup
# define sqliteStrDup sqlite3StrDup
# define sqliteStrNDup sqlite3StrNDup
#endif #endif
/* /*
@@ -1208,7 +1205,6 @@ char *sqlite3VMPrintf(const char*, va_list);
void sqlite3DebugPrintf(const char*, ...); void sqlite3DebugPrintf(const char*, ...);
void *sqlite3TextToPtr(const char*); void *sqlite3TextToPtr(const char*);
void sqlite3SetString(char **, const char *, ...); void sqlite3SetString(char **, const char *, ...);
void sqlite3SetNString(char **, ...);
void sqlite3ErrorMsg(Parse*, const char*, ...); void sqlite3ErrorMsg(Parse*, const char*, ...);
void sqlite3Dequote(char*); void sqlite3Dequote(char*);
int sqlite3KeywordCode(const char*, int); int sqlite3KeywordCode(const char*, int);

View File

@@ -150,11 +150,9 @@ int sqlite3_get_table(
if( res.zErrMsg ){ if( res.zErrMsg ){
if( pzErrMsg ){ if( pzErrMsg ){
free(*pzErrMsg); free(*pzErrMsg);
*pzErrMsg = res.zErrMsg; *pzErrMsg = sqlite3_mprintf("%s",res.zErrMsg);
sqlite3StrRealloc(pzErrMsg);
}else{
sqliteFree(res.zErrMsg);
} }
sqliteFree(res.zErrMsg);
} }
return res.rc; return res.rc;
} }

View File

@@ -15,7 +15,7 @@
** individual tokens and sends those tokens one-by-one over to the ** individual tokens and sends those tokens one-by-one over to the
** parser for analysis. ** parser for analysis.
** **
** $Id: tokenize.c,v 1.87 2004/09/08 15:09:41 drh Exp $ ** $Id: tokenize.c,v 1.88 2004/09/25 14:39:19 drh Exp $
*/ */
#include "sqliteInt.h" #include "sqliteInt.h"
#include "os.h" #include "os.h"
@@ -500,8 +500,11 @@ int sqlite3RunParser(Parse *pParse, const char *zSql, char **pzErrMsg){
break; break;
} }
case TK_ILLEGAL: { case TK_ILLEGAL: {
sqlite3SetNString(pzErrMsg, "unrecognized token: \"", -1, if( pzErrMsg ){
pParse->sLastToken.z, pParse->sLastToken.n, "\"", 1, (char*)0); sqliteFree(*pzErrMsg);
*pzErrMsg = sqlite3MPrintf("unrecognized token: \"%T\"",
&pParse->sLastToken);
}
nErr++; nErr++;
goto abort_parse; goto abort_parse;
} }

View File

@@ -14,7 +14,7 @@
** This file contains functions for allocating memory, comparing ** This file contains functions for allocating memory, comparing
** strings, and stuff like that. ** strings, and stuff like that.
** **
** $Id: util.c,v 1.117 2004/09/08 20:13:06 drh Exp $ ** $Id: util.c,v 1.118 2004/09/25 14:39:19 drh Exp $
*/ */
#include "sqliteInt.h" #include "sqliteInt.h"
#include <stdarg.h> #include <stdarg.h>
@@ -214,28 +214,6 @@ void *sqlite3Realloc_(void *oldP, int n, char *zFile, int line){
return p; return p;
} }
/*
** Make a duplicate of a string into memory obtained from malloc()
** Free the original string using sqliteFree().
**
** This routine is called on all strings that are passed outside of
** the SQLite library. That way clients can free the string using free()
** rather than having to call sqliteFree().
*/
void sqlite3StrRealloc(char **pz){
char *zNew;
if( pz==0 || *pz==0 ) return;
zNew = malloc( strlen(*pz) + 1 );
if( zNew==0 ){
sqlite3_malloc_failed++;
sqliteFree(*pz);
*pz = 0;
}
strcpy(zNew, *pz);
sqliteFree(*pz);
*pz = zNew;
}
/* /*
** Make a copy of a string in memory obtained from sqliteMalloc() ** Make a copy of a string in memory obtained from sqliteMalloc()
*/ */
@@ -389,48 +367,6 @@ void sqlite3SetString(char **pz, const char *zFirst, ...){
#endif #endif
} }
/*
** Works like sqlite3SetString, but each string is now followed by
** a length integer which specifies how much of the source string
** to copy (in bytes). -1 means use the whole string. The 1st
** argument must either be NULL or point to memory obtained from
** sqliteMalloc().
*/
void sqlite3SetNString(char **pz, ...){
va_list ap;
int nByte;
const char *z;
char *zResult;
int n;
if( pz==0 ) return;
nByte = 0;
va_start(ap, pz);
while( (z = va_arg(ap, const char*))!=0 ){
n = va_arg(ap, int);
if( n<=0 ) n = strlen(z);
nByte += n;
}
va_end(ap);
sqliteFree(*pz);
*pz = zResult = sqliteMallocRaw( nByte + 1 );
if( zResult==0 ) return;
va_start(ap, pz);
while( (z = va_arg(ap, const char*))!=0 ){
n = va_arg(ap, int);
if( n<=0 ) n = strlen(z);
memcpy(zResult, z, n);
zResult += n;
}
*zResult = 0;
#ifdef SQLITE_DEBUG
#if SQLITE_DEBUG>1
fprintf(stderr,"string at 0x%x is %s\n", (int)*pz, *pz);
#endif
#endif
va_end(ap);
}
/* /*
** Set the most recent error code and error string for the sqlite ** Set the most recent error code and error string for the sqlite
** handle "db". The error code is set to "err_code". ** handle "db". The error code is set to "err_code".

View File

@@ -304,7 +304,8 @@ void sqlite3VdbeChangeP3(Vdbe *p, int addr, const char *zP3, int n){
pOp->p3 = (char*)zP3; pOp->p3 = (char*)zP3;
pOp->p3type = n; pOp->p3type = n;
}else{ }else{
sqlite3SetNString(&pOp->p3, zP3, n, (char*)0); if( n==0 ) n = strlen(zP3);
pOp->p3 = sqliteStrNDup(zP3, n);
pOp->p3type = P3_DYNAMIC; pOp->p3type = P3_DYNAMIC;
} }
} }