Efficient and generalized are opposing forces. Malloc is fine for what it is but you can do better by specialising.