another method to malloc buffer