We should avoid malloc and use new uint8_t[size] instead. Do you want me to fix it?