Browse Source
Supporess finalization when UnmanagedBlob allocation failed
pull/5324/head
Nikita Tsukanov
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
14 additions and
6 deletions
-
src/Shared/PlatformSupport/StandardRuntimePlatform.cs
|
|
|
@ -49,12 +49,20 @@ namespace Avalonia.Shared.PlatformSupport |
|
|
|
|
|
|
|
public UnmanagedBlob(StandardRuntimePlatform plat, int size) |
|
|
|
{ |
|
|
|
if (size <= 0) |
|
|
|
throw new ArgumentException("Positive number required", nameof(size)); |
|
|
|
_plat = plat; |
|
|
|
_address = plat.Alloc(size); |
|
|
|
GC.AddMemoryPressure(size); |
|
|
|
Size = size; |
|
|
|
try |
|
|
|
{ |
|
|
|
if (size <= 0) |
|
|
|
throw new ArgumentException("Positive number required", nameof(size)); |
|
|
|
_plat = plat; |
|
|
|
_address = plat.Alloc(size); |
|
|
|
GC.AddMemoryPressure(size); |
|
|
|
Size = size; |
|
|
|
} |
|
|
|
catch |
|
|
|
{ |
|
|
|
GC.SuppressFinalize(); |
|
|
|
throw; |
|
|
|
} |
|
|
|
#if DEBUG
|
|
|
|
_backtrace = Environment.StackTrace; |
|
|
|
lock (_btlock) |
|
|
|
|