Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ MemFreeAfterAddress()

static unsafe ulong System.Runtime.MemoryFailPoint.MemFreeAfterAddress ( void * address,
ulong size )
inlinestaticprivate

Definition at line 180 of file MemoryFailPoint.cs.

181 {
182 if (size >= s_topOfMemory)
183 {
184 return 0uL;
185 }
186 ulong num = 0uL;
188 UIntPtr dwLength = (UIntPtr)(ulong)sizeof(Interop.Kernel32.MEMORY_BASIC_INFORMATION);
189 while ((ulong)((long)address + (long)size) < s_topOfMemory)
190 {
191 UIntPtr uIntPtr = Interop.Kernel32.VirtualQuery(address, ref lpBuffer, dwLength);
192 if (uIntPtr == UIntPtr.Zero)
193 {
195 }
196 ulong num2 = lpBuffer.RegionSize.ToUInt64();
197 if (lpBuffer.State == 65536)
198 {
199 if (num2 >= size)
200 {
201 return num2;
202 }
203 num = Math.Max(num, num2);
204 }
205 address = (void*)((ulong)address + num2);
206 }
207 return num;
208 }
static UIntPtr VirtualQuery(SafeHandle lpAddress, ref MEMORY_BASIC_INFORMATION lpBuffer, UIntPtr dwLength)
static Exception GetExceptionForLastWin32Error(string path="")
static readonly ulong s_topOfMemory

References System.IO.Win32Marshal.GetExceptionForLastWin32Error(), System.Math.Max(), System.Runtime.MemoryFailPoint.s_topOfMemory, Interop.Kernel32.VirtualQuery(), and System.UIntPtr.Zero.

Referenced by System.Runtime.MemoryFailPoint.CheckForFreeAddressSpace().