var pix []uint8
// ...
newLen := len(pix) / 3 * 4
pix = append(pix, make([]uint8, newLen-len(pix))...)
About the above lines of code, I’m receiving these comments:
Here actually we duplicate allocation.
Is it duplication?
Yes, because it would not be usually able to expand memory as memory size already allocated. It allocate new memory copy things there using memmove
it is efficient usually memgrow (malloc inplace) and memmove (malloc new memory release previous allocation)
Question
I don’t have enough knowledge about it. So I’m going to ask here:
Are the above comments accurate?