add a macro to calculate required buffer size for key-value data