public int Read(byte[] buffer, int offset, int count) { int num = 0; while (count != 0) { int num2 = this.headEntry.Read(buffer, offset, count); offset += num2; count -= num2; num += num2; this.cachedLength -= num2; if (this.headEntry.Length == 0) { ByteCache.CacheEntry cacheEntry = this.headEntry; this.headEntry = this.headEntry.Next; if (this.headEntry == null) { this.tailEntry = null; } cacheEntry.Next = this.freeList; this.freeList = cacheEntry; } if (count == 0 || this.headEntry == null) { break; } } return(num); }
public void ReportRead(int count) { this.headEntry.ReportRead(count); this.cachedLength -= count; if (this.headEntry.Length == 0) { ByteCache.CacheEntry cacheEntry = this.headEntry; this.headEntry = this.headEntry.Next; if (this.headEntry == null) { this.tailEntry = null; } cacheEntry.Next = this.freeList; this.freeList = cacheEntry; } }
public void Reset() { while (this.headEntry != null) { this.headEntry.Reset(); ByteCache.CacheEntry cacheEntry = this.headEntry; this.headEntry = this.headEntry.Next; if (this.headEntry == null) { this.tailEntry = null; } cacheEntry.Next = this.freeList; this.freeList = cacheEntry; } this.cachedLength = 0; }
private void AllocateTail(int size) { ByteCache.CacheEntry cacheEntry = this.freeList; if (cacheEntry != null) { this.freeList = cacheEntry.Next; cacheEntry.Next = null; } else { cacheEntry = new ByteCache.CacheEntry(size); } if (this.tailEntry != null) { this.tailEntry.Next = cacheEntry; } else { this.headEntry = cacheEntry; } this.tailEntry = cacheEntry; }