Keine Beschreibung
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

NativeArrayRaw.cs 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using System;
  2. using Unity.Collections.LowLevel.Unsafe;
  3. using Unity.Collections;
  4. namespace Burst.Compiler.IL.Tests.Helpers
  5. {
  6. // Only used to allow to call the delegate with a NativeArrayRaw
  7. // As we can't use a generic with pinvoke
  8. internal unsafe struct NativeArrayRaw : IDisposable
  9. {
  10. // MUST BE IN SYNC WITH NativeArray
  11. internal void* m_Buffer;
  12. internal int m_Length;
  13. #if ENABLE_UNITY_COLLECTIONS_CHECKS
  14. internal int m_MinIndex;
  15. internal int m_MaxIndex;
  16. internal AtomicSafetyHandle m_Safety;
  17. internal DisposeSentinel m_DisposeSentinel;
  18. #endif
  19. Allocator m_AllocatorLabel;
  20. public NativeArrayRaw(void* mBuffer, int mLength)
  21. {
  22. m_Buffer = mBuffer;
  23. m_Length = mLength;
  24. m_AllocatorLabel = Allocator.Persistent;
  25. #if ENABLE_UNITY_COLLECTIONS_CHECKS
  26. m_MinIndex = 0;
  27. m_MaxIndex = m_Length -1;
  28. m_Safety = AtomicSafetyHandle.Create();
  29. m_DisposeSentinel = null;
  30. #endif
  31. }
  32. public void Dispose()
  33. {
  34. #if ENABLE_UNITY_COLLECTIONS_CHECKS
  35. DisposeSentinel.Dispose(ref m_Safety, ref m_DisposeSentinel);
  36. #endif
  37. if (m_Buffer != (void*)0)
  38. {
  39. UnsafeUtility.Free((void*)m_Buffer, m_AllocatorLabel);
  40. m_Buffer = (void*)0;
  41. m_Length = 0;
  42. }
  43. }
  44. }
  45. }