Пример #1
0
 public SvnData(string str, AprPool pool)
 {
     byte[] utf8str = Encoder.GetBytes(str);
     mString = pool.Alloc(utf8str.Length + 1);
     Marshal.Copy(utf8str, 0, mString, utf8str.Length);
     Marshal.WriteByte(mString, utf8str.Length, 0);
 }
Пример #2
0
        public void Alloc()
        {
            AprPool p = new AprPool();

            Assert.IsTrue(p.IsNull, "#E01");

            p = AprPool.Create();
            Assert.IsFalse(p.IsNull, "#E02");

            Assert.IsTrue(p.Alloc(128).ToInt32() != 0, "#E03");
            Assert.IsTrue(p.Alloc(256).ToInt32() != 0, "#E04");
            Assert.IsTrue(p.Alloc(512).ToInt32() != 0, "#E05");
            Assert.IsTrue(p.Alloc(1024).ToInt32() != 0, "#E06");
            Assert.IsTrue(p.Alloc(2048).ToInt32() != 0, "#E07");
            Assert.IsTrue(p.Alloc(4096).ToInt32() != 0, "#E08");
            Assert.IsTrue(p.Alloc(6148).ToInt32() != 0, "#E09");
            Assert.IsTrue(p.Alloc(9216).ToInt32() != 0, "#E10");
            Assert.IsTrue(p.Alloc(12265).ToInt32() != 0, "#E11");
            Assert.IsTrue(p.Alloc(16384).ToInt32() != 0, "#E12");

            p.Destroy();
            Assert.IsTrue(p.IsNull, "#E13");
        }
Пример #3
0
        internal unsafe svn_opt_revision_t AllocSvnRevision(AprPool pool)
        {
            if (pool is null)
            {
                throw new ArgumentNullException(nameof(pool));
            }

            var rev = (svn_opt_revision_t.__Internal *)pool.Alloc(
                sizeof(svn_opt_revision_t.__Internal));

            *rev = ToSvnRevision();

            return(svn_opt_revision_t.__CreateInstance(new IntPtr(rev)));
        }
Пример #4
0
        public void AllocLoop()
        {
            AprPool p = new AprPool();

            Assert.IsTrue(p.IsNull, "#G000001");

            p = AprPool.Create();
            Assert.IsFalse(p.IsNull, "#G000002");

            for (int i = 24; i < 4096; i += 24)
            {
                Assert.IsTrue(p.Alloc(i).ToInt32() != 0, String.Format("#G{0,6}", i));
            }

            p.Destroy();
            Assert.IsTrue(p.IsNull, "#G000004");
        }
Пример #5
0
        public void CAllocLoop()
        {
            AprPool p = new AprPool();

            Assert.IsTrue(p.IsNull, "#H000001");

            p = AprPool.Create();
            Assert.IsFalse(p.IsNull, "#H000002");

            for (int i = 24; i < 4096; i += 24)
            {
                IntPtr m = p.CAlloc(i);
                Assert.IsTrue(m.ToInt32() != 0, String.Format("#H{0,6}a", i));
                Assert.IsTrue(Marshal.ReadInt32(m) == 0, String.Format("#H{0,6}b", i));
                Assert.IsTrue(p.Alloc(i).ToInt32() != 0, String.Format("#H{0,6}c", i));
            }

            p.Destroy();
            Assert.IsTrue(p.IsNull, "#H000004");
        }
Пример #6
0
        unsafe bool InternalLog(ICollection <string> targets, Uri searchRoot, SvnRevision altPegRev, SvnLogArgs args, EventHandler <SvnLogEventArgs> logHandler)
        {
            if (targets == null)
            {
                throw new ArgumentNullException(nameof(targets));
            }
            if (args == null)
            {
                throw new ArgumentNullException(nameof(args));
            }

            EnsureState(SvnContextState.AuthorizationInitialized);
            using var pool  = new AprPool(_pool);
            using var store = new ArgsStore(this, args, pool);

            args._mergeLogLevel = 0; // Clear log level
            args._searchRoot    = searchRoot;

            if (logHandler != null)
            {
                args.Log += logHandler;
            }

            try
            {
                apr_array_header_t retrieveProperties;

                if (args.RetrieveAllProperties)
                {
                    retrieveProperties = null;
                }
                else if (args.RetrievePropertiesUsed)
                {
                    retrieveProperties = AllocArray(args.RetrieveProperties, pool);
                }
                else
                {
                    retrieveProperties = svn_compat.svn_compat_log_revprops_in(pool.Handle);
                }

                svn_opt_revision_t pegRev = args.OriginRevision.Or(altPegRev).AllocSvnRevision(pool);

                int count          = args.RangesUsed ? args.Ranges.Count : 1;
                var revisionRanges = apr_tables.apr_array_make(
                    pool.Handle, count, sizeof(svn_opt_revision_range_t.__Internal *));

                if (args.RangesUsed)
                {
                    foreach (SvnRevisionRange r in args.Ranges)
                    {
                        var range = (svn_opt_revision_range_t.__Internal *)pool.Alloc(
                            sizeof(svn_opt_revision_range_t.__Internal));

                        range->start = r.StartRevision.Or(SvnRevision.Head).ToSvnRevision();
                        range->end   = r.EndRevision.Or(SvnRevision.Zero).ToSvnRevision();

                        *((svn_opt_revision_range_t.__Internal * *)apr_tables.apr_array_push(revisionRanges)) = range;
                    }
                }
                else
                {
                    var range = (svn_opt_revision_range_t.__Internal *)pool.Alloc(
                        sizeof(svn_opt_revision_range_t.__Internal));

                    range->start = args.Start.Or(args.OriginRevision).Or(SvnRevision.Head).ToSvnRevision();
                    range->end   = args.End.Or(SvnRevision.Zero).ToSvnRevision();

                    *((svn_opt_revision_range_t.__Internal * *)apr_tables.apr_array_push(revisionRanges)) = range;
                }

                using var svnclient_log_receiver_handle = new SafeFuncHandle <svn_log_entry_receiver_t>(svnclient_log_handler);

                svn_error_t err = svn_client.svn_client_log5(
                    AllocArray(targets, pool),
                    pegRev,
                    revisionRanges,
                    args.Limit,
                    args.RetrieveChangedPaths,
                    args.StrictNodeHistory,
                    args.RetrieveMergedRevisions,
                    retrieveProperties,
                    svnclient_log_receiver_handle.Get(),
                    _clientBaton.Handle,
                    CtxHandle,
                    pool.Handle);

                return(args.HandleResult(this, err, targets));
            }
            finally
            {
                if (logHandler != null)
                {
                    args.Log -= logHandler;
                }

                args._searchRoot    = null;
                args._mergeLogLevel = 0;
            }
        }