change "uint32_t" to "size_t".

cache Buffer length and data pointer.
remove static cast.