By calling a function that returns a string buffer the code is clean, but it means the output string will be allocated twice.  Once inside the decode, and once inside this function.