I wasn't mallocing the right way when I first tried. Works now