Exemple #1
0
 /// <exception cref="System.IO.IOException"></exception>
 /// <exception cref="ICSharpCode.SharpZipLib.SharpZipBaseException"></exception>
 private byte[] Decompress(long position, int sz, WindowCursor curs)
 {
     byte[] dstbuf;
     try
     {
         dstbuf = new byte[sz];
     }
     catch (OutOfMemoryException)
     {
         // The size may be larger than our heap allows, return null to
         // let the caller know allocation isn't possible and it should
         // use the large object streaming approach instead.
         //
         // For example, this can occur when sz is 640 MB, and JRE
         // maximum heap size is only 256 MB. Even if the JRE has
         // 200 MB free, it cannot allocate a 640 MB byte array.
         return(null);
     }
     if (curs.Inflate(this, position, dstbuf, 0) != sz)
     {
         throw new EOFException(MessageFormat.Format(JGitText.Get().shortCompressedStreamAt
                                                     , Sharpen.Extensions.ValueOf(position)));
     }
     return(dstbuf);
 }
Exemple #2
0
 /// <exception cref="System.IO.IOException"></exception>
 /// <exception cref="ICSharpCode.SharpZipLib.SharpZipBaseException"></exception>
 internal virtual byte[] GetDeltaHeader(WindowCursor wc, long pos)
 {
     // The delta stream starts as two variable length integers. If we
     // assume they are 64 bits each, we need 16 bytes to encode them,
     // plus 2 extra bytes for the variable length overhead. So 18 is
     // the longest delta instruction header.
     //
     byte[] hdr = new byte[18];
     wc.Inflate(this, pos, hdr, 0);
     return(hdr);
 }