internal TxnStatStruct txn_stat(uint flags) { int err = 0; uint size = 0; int offset = Marshal.SizeOf(typeof(DB_TXN_ACTIVE)); IntPtr ptr = txn_stat(flags, ref size, ref err); DatabaseException.ThrowException(err); TxnStatStruct ret = new TxnStatStruct(); ret.st = (TransactionStatStruct)Marshal.PtrToStructure(ptr, typeof(TransactionStatStruct)); ret.st_txnarray = new DB_TXN_ACTIVE[ret.st.st_nactive]; ret.st_txngids = new byte[ret.st.st_nactive][]; ret.st_txnnames = new string[ret.st.st_nactive]; for (int i = 0; i < ret.st.st_nactive; i++) { IntPtr activep = new IntPtr((IntPtr.Size == 4 ? ret.st.st_txnarray.ToInt32() : ret.st.st_txnarray.ToInt64()) + i * size); ret.st_txnarray[i] = (DB_TXN_ACTIVE)Marshal.PtrToStructure(activep, typeof(DB_TXN_ACTIVE)); ret.st_txngids[i] = new byte[DbConstants.DB_GID_SIZE]; IntPtr gidp = new IntPtr((IntPtr.Size == 4 ? activep.ToInt32() : activep.ToInt64()) + offset); Marshal.Copy(gidp, ret.st_txngids[i], 0, (int)DbConstants.DB_GID_SIZE); IntPtr namep = new IntPtr((IntPtr.Size == 4 ? gidp.ToInt32() : gidp.ToInt64()) + DbConstants.DB_GID_SIZE); ret.st_txnnames[i] = Marshal.PtrToStringAnsi(namep); } libdb_csharp.__os_ufree(null, ptr); return(ret); }
internal TransactionStats(Internal.TxnStatStruct stats) { st = stats.st; lastCkp = new LSN(st.st_last_ckp.file, st.st_last_ckp.offset); txns = new List <ActiveTransaction>(); for (int i = 0; i < st.st_nactive; i++) { txns.Add(new ActiveTransaction( stats.st_txnarray[i], stats.st_txngids[i], stats.st_txnnames[i])); } }
internal TxnStatStruct txn_stat(uint flags) { int err = 0; uint size = 0; int offset = Marshal.SizeOf(typeof(DB_TXN_ACTIVE)); IntPtr ptr = txn_stat(flags, ref size, ref err); DatabaseException.ThrowException(err); TxnStatStruct ret = new TxnStatStruct(); ret.st = (TransactionStatStruct)Marshal.PtrToStructure(ptr, typeof(TransactionStatStruct)); ret.st_txnarray = new DB_TXN_ACTIVE[ret.st.st_nactive]; ret.st_txngids = new byte[ret.st.st_nactive][]; ret.st_txnnames = new string[ret.st.st_nactive]; for (int i = 0; i < ret.st.st_nactive; i++) { IntPtr activep = new IntPtr((IntPtr.Size == 4 ? ret.st.st_txnarray.ToInt32() : ret.st.st_txnarray.ToInt64()) + i * size); ret.st_txnarray[i] = (DB_TXN_ACTIVE)Marshal.PtrToStructure(activep, typeof(DB_TXN_ACTIVE)); ret.st_txngids[i] = new byte[DbConstants.DB_GID_SIZE]; IntPtr gidp = new IntPtr((IntPtr.Size == 4 ? activep.ToInt32() : activep.ToInt64()) + offset); Marshal.Copy(gidp, ret.st_txngids[i], 0, (int)DbConstants.DB_GID_SIZE); IntPtr namep = new IntPtr((IntPtr.Size == 4 ? gidp.ToInt32() : gidp.ToInt64()) + DbConstants.DB_GID_SIZE); ret.st_txnnames[i] = Marshal.PtrToStringAnsi(namep); } libdb_csharp.__os_ufree(null, ptr); return ret; }