If you declare tx_buffer at file scope why do you pass it around, make it function scope or keep it as is and just don't pass it as argument.