OiO.lk Blog C# Calculating the allocation needs for malloc(): should code use row*col*sizeof or sizeof*row*col?
C#

Calculating the allocation needs for malloc(): should code use row*col*sizeof or sizeof*row*col?


Is multiplication order important when allocating?

Even if multiplication may affect things in general, what about common ordering concerns with allocation sizing?

data = malloc(row * col * sizeof data[0]); 
// vs.
data = malloc(sizeof data[0] * row * col); 



You need to sign in to view this answers

Exit mobile version