Replaced mallocs with alloca.  This prevents memory leaks i guess?