Nitpick: A space before the opening paraenthesis after these malloc's and sizeof's.