Move the malloc and free of scratch space out of the internal_mul