Example #1
0
    unsafe static long Test(int size, Point1 a, Point1 b, Point1 c)
    {
        // Mutate the values stored in a, b and c
        // So if these have a shadow copy we will notice
        //
        a.Increase(ref a, arr[0]);
        b.Increase(ref b, arr[1]);
        c.Increase(ref c, arr[2]);

        DangerousBuffer db = new DangerousBuffer();

        db.a = -1;
        db.b = -2;
        db.c = -3;

        long *x1 = stackalloc long[size];

        long sum = 0;

        if (size >= 3)
        {
            x1[0] = a.Value();
            x1[1] = b.Value();
            x1[2] = c.Value();

            for (int i = 0; i < size; i++)
            {
                sum += x1[i];
            }
        }
        return(sum);
    }