public static async Task <int> BufferAsync(this HGlobalCache <char> hGCache, TextReader textReader) { int offset = 0; Loop: if (offset >= hGCache.Count) { hGCache.Expand(1218); } IntPtr address; unsafe { address = (IntPtr)(hGCache.GetPointer() + offset); } int readCount = await ReadCharsAsync( textReader, address, hGCache.Count - offset); offset += readCount; if (offset == hGCache.Count) { goto Loop; } return(offset); }
public static unsafe int Buffer(this HGlobalCache <char> hGCache, TextReader textReader) { int offset = 0; Loop: if (offset >= hGCache.Count) { hGCache.Expand(1218); } int readCount = ReadChars( textReader, hGCache.GetPointer() + offset, hGCache.Count - offset); offset += readCount; if (offset == hGCache.Count) { goto Loop; } return(offset); }
private void ReadStringToHGlobal(int bytesLength) { if (hGlobal.Capacity <= GetUtf8MaxCharsLength(bytesLength)) { hGlobal.Expand(GetUtf8MaxCharsLength(bytesLength)); } hGlobal.Count = GetUtf8Chars(current, bytesLength, hGlobal.GetPointer()); current += bytesLength; }
private void InternalExpand(int expandMinSize) { if (HGCache.Capacity == HGlobalCache <byte> .MaxSize && Stream != null && offset != 0) { HGCache.Count = offset; HGCache.WriteTo(Stream); offset = 0; Expand(expandMinSize); } else { HGCache.Expand(expandMinSize); } }