you are right! There must be a strange error with the sizeof() Macro.
This version runs correctly:
Code:
function main()
{
int n = sizeof(short);
short *var1 = sys_malloc(10 * n), *var2;
// or using constants: short *var1 = sys_malloc(10 * 2), *var2;
int i;
for (i=0; i<10; i++)
var1[i] = i;
var2 = var1; // correct
printf("%d", var1[6]);
printf("%d", var2[6]); // Expected result "6"
}
where this version turns var2 into a pointer to a short pointer:
Code:
short *var1 = sys_malloc(10 * sizeof(short)), *var2;