Remove use of malloc/free