diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/func.c | 5 | ||||
-rw-r--r-- | src/vdbe.c | 13 | ||||
-rw-r--r-- | src/vdbeInt.h | 1 | ||||
-rw-r--r-- | src/vdbeapi.c | 13 | ||||
-rw-r--r-- | src/vdbeaux.c | 26 |
5 files changed, 32 insertions, 26 deletions
diff --git a/src/func.c b/src/func.c index 29ab4404d..7e820c8c5 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.72 2004/06/19 08:18:09 danielk1977 Exp $ +** $Id: func.c,v 1.73 2004/06/19 15:40:23 drh Exp $ */ #include <ctype.h> #include <math.h> @@ -308,7 +308,7 @@ struct LikePattern { struct LikeState { int val; /* Unicode codepoint or -1 for any char i.e. '_' */ int failstate; /* State to jump to if next char is not val */ - } aState[0]; + } aState[1]; }; typedef struct LikePattern LikePattern; @@ -1093,4 +1093,3 @@ void sqlite3RegisterBuiltinFunctions(sqlite *db){ } sqlite3RegisterDateTimeFunctions(db); } - diff --git a/src/vdbe.c b/src/vdbe.c index 2476c265a..f821f4f65 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.380 2004/06/19 09:35:37 danielk1977 Exp $ +** $Id: vdbe.c,v 1.381 2004/06/19 15:40:23 drh Exp $ */ #include "sqliteInt.h" #include "os.h" @@ -1309,16 +1309,7 @@ case OP_Function: { ** immediately call the destructor for any non-static values. */ if( ctx.pVdbeFunc ){ - int mask = pOp->p2; - for(i=0; i<ctx.pVdbeFunc->nAux; i++){ - struct AuxData *pAux = &ctx.pVdbeFunc->apAux[i]; - if( (i>31 || !(mask&(1<<i))) && pAux->pAux ){ - if( pAux->xDelete ){ - pAux->xDelete(pAux->pAux); - } - pAux->pAux = 0; - } - } + sqlite3VdbeDeleteAuxData(ctx.pVdbeFunc, pOp->p2); pOp->p3 = (char *)ctx.pVdbeFunc; pOp->p3type = P3_VDBEFUNC; } diff --git a/src/vdbeInt.h b/src/vdbeInt.h index bae5bba80..02fa033c7 100644 --- a/src/vdbeInt.h +++ b/src/vdbeInt.h @@ -373,6 +373,7 @@ int sqlite3VdbeSerialTypeLen(u32); u32 sqlite3VdbeSerialType(Mem*); int sqlite3VdbeSerialPut(unsigned char*, Mem*); int sqlite3VdbeSerialGet(const unsigned char*, u32, Mem*); +void sqlite3VdbeDeleteAuxData(VdbeFunc*, int); int sqlite2BtreeKeyCompare(BtCursor *, const void *, int, int, int *); int sqlite3VdbeIdxKeyCompare(Cursor*, int , const unsigned char*, int*); diff --git a/src/vdbeapi.c b/src/vdbeapi.c index 6aee6b673..b34b60fb4 100644 --- a/src/vdbeapi.c +++ b/src/vdbeapi.c @@ -218,7 +218,7 @@ void *sqlite3_get_auxdata(sqlite3_context *pCtx, int iArg){ if( !pVdbeFunc || iArg>=pVdbeFunc->nAux || iArg<0 ){ return 0; } - return pCtx->pVdbeFunc->apAux[iArg].pAux; + return pVdbeFunc->apAux[iArg].pAux; } /* @@ -233,18 +233,19 @@ void sqlite3_set_auxdata( void (*xDelete)(void*) ){ struct AuxData *pAuxData; + VdbeFunc *pVdbeFunc; if( iArg<0 ) return; - if( !pCtx->pVdbeFunc || pCtx->pVdbeFunc->nAux<=iArg ){ - VdbeFunc *pVdbeFunc; - int nMalloc = sizeof(VdbeFunc)+sizeof(struct AuxData)*iArg; - pCtx->pVdbeFunc = pVdbeFunc = sqliteRealloc(pCtx->pVdbeFunc, nMalloc); + pVdbeFunc = pCtx->pVdbeFunc; + if( !pVdbeFunc || pVdbeFunc->nAux<=iArg ){ + int nMalloc = sizeof(VdbeFunc) + sizeof(struct AuxData)*iArg; + pCtx->pVdbeFunc = pVdbeFunc = sqliteRealloc(pVdbeFunc, nMalloc); if( !pVdbeFunc ) return; pVdbeFunc->nAux = iArg+1; pVdbeFunc->pFunc = pCtx->pFunc; } - pAuxData = &pCtx->pVdbeFunc->apAux[iArg]; + pAuxData = &pVdbeFunc->apAux[iArg]; if( pAuxData->pAux && pAuxData->xDelete ){ pAuxData->xDelete(pAuxData->pAux); } diff --git a/src/vdbeaux.c b/src/vdbeaux.c index a4df0af08..4a7da7b51 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -1310,6 +1310,25 @@ int sqlite3VdbeFinalize(Vdbe *p, char **pzErrMsg){ } /* +** Call the destructor for each auxdata entry in pVdbeFunc for which +** the corresponding bit in mask is set. Auxdata entries beyond 31 +** are always destroyed. To destroy all auxdata entries, call this +** routine with mask==-1. +*/ +void sqlite3VdbeDeleteAuxData(VdbeFunc *pVdbeFunc, int mask){ + int i; + for(i=0; i<pVdbeFunc->nAux; i++){ + struct AuxData *pAux = &pVdbeFunc->apAux[i]; + if( (i>31 || !(mask&(1<<i))) && pAux->pAux ){ + if( pAux->xDelete ){ + pAux->xDelete(pAux->pAux); + } + pAux->pAux = 0; + } + } +} + +/* ** Delete an entire VDBE. */ void sqlite3VdbeDelete(Vdbe *p){ @@ -1338,12 +1357,7 @@ void sqlite3VdbeDelete(Vdbe *p){ if( pOp->p3type==P3_VDBEFUNC ){ int j; VdbeFunc *pVdbeFunc = (VdbeFunc *)pOp->p3; - for(j=0; j<pVdbeFunc->nAux; j++){ - struct AuxData *pAuxData = &pVdbeFunc->apAux[j]; - if( pAuxData->pAux && pAuxData->xDelete ){ - pAuxData->xDelete(pAuxData->pAux); - } - } + sqlite3VdbeDeleteAuxData(pVdbeFunc, -1); sqliteFree(pVdbeFunc); } #ifndef NDEBUG |