added buffer length macro which uses buffer length + 1 for terminator