예제 #1
0
		/*
		** Make a full copy of pFrom into pTo.  Prior contents of pTo are
		** freed before the copy is made.
		*/

		private static int sqlite3VdbeMemCopy(Mem pTo, Mem pFrom)
		{
			int rc = SQLITE_OK;

			Debug.Assert((pFrom.flags & MEM_RowSet) == 0);
			sqlite3VdbeMemReleaseExternal(pTo);
			pFrom.CopyTo(ref 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;
		}
예제 #2
0
		/*
		** 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.
		*/

		private static void sqlite3VdbeMemMove(Mem pTo, Mem 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(pTo);
			pFrom.CopyTo(ref pTo);// memcpy(pTo, pFrom, Mem).Length;
			pFrom.flags = MEM_Null;
			pFrom.xDel = null;
			pFrom.z = null;
			sqlite3_free(ref pFrom.zBLOB); //pFrom.zMalloc=0;
		}
예제 #3
0
		/*
** 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).
		*/

		private static void sqlite3VdbeMemShallowCopy(Mem pTo, Mem pFrom, int srcType)
		{
			Debug.Assert((pFrom.flags & MEM_RowSet) == 0);
			sqlite3VdbeMemReleaseExternal(pTo);
			pFrom.CopyTo(ref pTo);//  memcpy(pTo, pFrom, MEMCELLSIZE);
			pTo.xDel = null;
			if ((pFrom.flags & MEM_Static) != 0)
			{
				pTo.flags = (u16)(pFrom.flags & ~(MEM_Dyn | MEM_Static | MEM_Ephem));
				Debug.Assert(srcType == MEM_Ephem || srcType == MEM_Static);
				pTo.flags |= (u16)srcType;
			}
		}