/* ** Set the auxillary data pointer and delete function, for the iArg'th ** argument to the user-function defined by pCtx. Any previous value is ** deleted by calling the delete function specified when it was set. */ public static void sqlite3_set_auxdata( sqlite3_context pCtx, int iArg, object pAux //void (*xDelete)(void) ) { AuxData pAuxData; VdbeFunc pVdbeFunc; if ( iArg < 0 ) goto failed; Debug.Assert( sqlite3_mutex_held( pCtx.s.db.mutex ) ); pVdbeFunc = pCtx.pVdbeFunc; if ( null == pVdbeFunc || pVdbeFunc.nAux <= iArg ) { int nAux = ( pVdbeFunc != null ? pVdbeFunc.nAux : 0 ); ////int nMalloc = iArg; //VdbeFunc+ sizeof(struct AuxData)*iArg; if ( pVdbeFunc == null ) { //pVdbeFunc = (VdbeFunc)sqlite3DbRealloc( pCtx.s.db, pVdbeFunc, nMalloc ); pVdbeFunc = new VdbeFunc(); if ( null == pVdbeFunc ) { goto failed; } pCtx.pVdbeFunc = pVdbeFunc; } pVdbeFunc.apAux[nAux] = new AuxData();//memset(pVdbeFunc.apAux[nAux], 0, sizeof(struct AuxData)*(iArg+1-nAux)); pVdbeFunc.nAux = iArg + 1; pVdbeFunc.pFunc = pCtx.pFunc; } pAuxData = pVdbeFunc.apAux[iArg]; if ( pAuxData.pAux != null && pAuxData.pAux is IDisposable ) { (pAuxData.pAux as IDisposable).Dispose(); } pAuxData.pAux = pAux; return; failed: if ( pAux != null && pAux is IDisposable) { (pAux as IDisposable).Dispose(); } }
/* ** Set the auxillary data pointer and delete function, for the iArg'th ** argument to the user-function defined by pCtx. Any previous value is ** deleted by calling the delete function specified when it was set. */ public static void sqlite3_set_auxdata( sqlite3_context pCtx, int iArg, string pAux, dxDel xDelete//void (*xDelete)(void*) ) { AuxData pAuxData; VdbeFunc pVdbeFunc; if (iArg < 0) goto failed; Debug.Assert(sqlite3_mutex_held(pCtx.s.db.mutex)); pVdbeFunc = pCtx.pVdbeFunc; if (null == pVdbeFunc || pVdbeFunc.nAux <= iArg) { int nAux = (pVdbeFunc != null ? pVdbeFunc.nAux : 0); int nMalloc = iArg; ;//VdbeFunc+ sizeof(struct AuxData)*iArg; if (pVdbeFunc == null) { //pVdbeFunc = (VdbeFunc)sqlite3DbRealloc( pCtx.s.db, pVdbeFunc, nMalloc ); pVdbeFunc = new VdbeFunc(); if (null == pVdbeFunc) { goto failed; } pCtx.pVdbeFunc = pVdbeFunc; } pVdbeFunc.apAux[nAux] = new AuxData();//memset(pVdbeFunc.apAux[nAux], 0, sizeof(struct AuxData)*(iArg+1-nAux)); pVdbeFunc.nAux = iArg + 1; pVdbeFunc.pFunc = pCtx.pFunc; } pAuxData = pVdbeFunc.apAux[iArg]; if (pAuxData.pAux != null && pAuxData.xDelete != null) { pAuxData.xDelete(ref pAuxData.pAux); } pAuxData.pAux = pAux; pAuxData.xDelete = xDelete; return; failed: if (xDelete != null) { xDelete(ref pAux); } }
/* ** Call the destructor for each auxdata entry in pVdbeFunc for which ** the corresponding bit in mask is clear. Auxdata entries beyond 31 ** are always destroyed. To destroy all auxdata entries, call this ** routine with mask==0. */ static void sqlite3VdbeDeleteAuxData( VdbeFunc pVdbeFunc, int mask ) { int i; for ( i = 0; i < pVdbeFunc.nAux; i++ ) { AuxData pAux = pVdbeFunc.apAux[i]; if ( ( i > 31 || ( mask & ( ( (u32)1 ) << i ) ) == 0 && pAux.pAux != null ) ) { if ( pAux.xDelete != null ) { pAux.xDelete( ref pAux.pAux ); } pAux.pAux = null; } } }
/* ** Call the destructor for each auxdata entry in pVdbeFunc for which ** the corresponding bit in mask is clear. Auxdata entries beyond 31 ** are always destroyed. To destroy all auxdata entries, call this ** routine with mask==0. */ static void sqlite3VdbeDeleteAuxData( VdbeFunc pVdbeFunc, int mask ) { int i; for ( i = 0; i < pVdbeFunc.nAux; i++ ) { AuxData pAux = pVdbeFunc.apAux[i]; if ( ( i > 31 || ( mask & ( ( (u32)1 ) << i ) ) == 0 && pAux.pAux != null ) ) { if ( pAux.pAux != null && pAux.pAux is IDisposable ) { (pAux.pAux as IDisposable).Dispose(); } pAux.pAux = null; } } }
public static void DeleteAuxData(VdbeFunc func, int mask) { for (int i = 0; i < func.AuxsLength; i++) { VdbeFunc.AuxData aux = func.Auxs[i]; if ((i > 31 || (mask & (((uint)1) << i)) == 0 && aux.Aux != null)) { if (aux.Aux != null && aux.Aux is IDisposable) (aux.Aux as IDisposable).Dispose(); if (aux.Delete != null) aux.Delete(aux.Aux); aux.Aux = null; } } }