C Debugging

Help me debug the proxy code in c in the file uv_proxy_busted.c.  It uses libuv.  There are 3 missing frees.  There are a couple logic flaws in the editing of the client’s request.  There is a string typo in the processing of the server’s response.  There are a couple of other memory management problems.  There are a couple of type errors.  Use valgrind and gdb to help debug.  For each fix, write in a comment explaining the fix.