fix: must use the total bytes to the memory allocation calculation.
add: buf_term helper function has been added.