if (textures != null)
{
int count = textures.Count;
- int intptrBytes = checked(Marshal.SizeOf(typeof(IntPtr)) * count);
- if (intptrBytes > 0)
+ if (count > 0)
{
IntPtr[] texturesArray = new IntPtr[count];
for (int i = 0; i < count; i++)
{
texturesArray[i] = HandleRef.ToIntPtr(Texture.getCPtr(textures[i]));
}
- IntPtr unmanagedPointer = Marshal.AllocHGlobal(intptrBytes);
- Marshal.Copy(texturesArray, 0, unmanagedPointer, texturesArray.Length);
+ IntPtr unmanagedPointer = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(IntPtr)) * count);
+ Marshal.Copy(texturesArray, 0, unmanagedPointer, count);
- Interop.GLView.GlViewBindTextureResources(SwigCPtr, unmanagedPointer, texturesArray.Length);
+ Interop.GLView.GlViewBindTextureResources(SwigCPtr, unmanagedPointer, count);
Marshal.FreeHGlobal(unmanagedPointer);
}
}