properly initialize a malloc'ed buffer