prefer to allocate temporary buffer on stack rather heap which leads to malloc/free calls inseard of simply restoring stack pointer.