You could move buf into this function.