Revert "malloc for each node added"

This reverts commit 368d867d29f4d812b2def94c724010730a5f78dc.