added checks for reentry.  Tried to make comment compatible with Doxygen.
allow zero length buffers if ptr is NULL

corrected tx length reported (was one greater than actual)