/* ** Make a full copy of pFrom into pTo. Prior contents of pTo are ** freed before the copy is made. */ static int sqlite3VdbeMemCopy( MemRef pTo, MemRef pFrom ) { int rc = SQLITE_OK; Debug.Assert( ( pFrom.flags & MEM_RowSet ) == 0 ); sqlite3VdbeMemReleaseExternal( pTo ); pFrom.CopyTo( pTo );// memcpy(pTo, pFrom, MEMCELLSIZE); pTo.flags = (u16)( pTo.flags & ~MEM_Dyn ); if ( ( pTo.flags & ( MEM_Str | MEM_Blob ) ) != 0 ) { if ( 0 == ( pFrom.flags & MEM_Static ) ) { pTo.flags |= MEM_Ephem; rc = sqlite3VdbeMemMakeWriteable( pTo ); } } return rc; }
/* ** Transfer the contents of pFrom to pTo. Any existing value in pTo is ** freed. If pFrom contains ephemeral data, a copy is made. ** ** pFrom contains an SQL NULL when this routine returns. */ static void sqlite3VdbeMemMove( ref Mem pTo, MemRef pFrom ) { Debug.Assert( pFrom.db == null || sqlite3_mutex_held( pFrom.db.mutex ) ); Debug.Assert( pTo.db == null || sqlite3_mutex_held( pTo.db.mutex ) ); Debug.Assert( pFrom.db == null || pTo.db == null || pFrom.db == pTo.db ); sqlite3VdbeMemRelease( ref pTo ); pFrom.CopyTo( ref pTo );// memcpy(pTo, pFrom, Mem).Length; pFrom.flags = MEM_Null; pFrom.xDel = null; pFrom.z = null; pFrom.zBLOB = null; //pFrom.zMalloc=null; }
/* ** Size of struct Mem not including the Mem.zMalloc member. */ //#define MEMCELLSIZE (size_t)(&(((Mem *)0).zMalloc)) /* ** Make an shallow copy of pFrom into pTo. Prior contents of ** pTo are freed. The pFrom.z field is not duplicated. If ** pFrom.z is used, then pTo.z points to the same thing as pFrom.z ** and flags gets srcType (either MEM_Ephem or MEM_Static). */ static void sqlite3VdbeMemShallowCopy( MemRef pTo, MemRef pFrom, int srcType ) { Debug.Assert( ( pFrom.flags & MEM_RowSet ) == 0 ); sqlite3VdbeMemReleaseExternal( pTo ); pFrom.CopyTo( pTo );// memcpy(pTo, pFrom, MEMCELLSIZE); pTo.xDel = null; if ( ( pFrom.flags & MEM_Dyn ) != 0 ) {//|| pFrom.z==pFrom.zMalloc ){ pTo.flags = (u16)( pFrom.flags & ~( MEM_Dyn | MEM_Static | MEM_Ephem ) ); Debug.Assert( srcType == MEM_Ephem || srcType == MEM_Static ); pTo.flags |= (u16)srcType; } }