Merge from ast-arena.  This reduces the code in Python/ast.c by ~300 lines,
simplifies a lot of error handling code, and fixes many memory leaks.
diff --git a/Parser/asdl_c.py b/Parser/asdl_c.py
index f45bee4..b1fc77d 100755
--- a/Parser/asdl_c.py
+++ b/Parser/asdl_c.py
@@ -249,8 +249,9 @@
         if args:
             argstr = ", ".join(["%s %s" % (atype, aname)
                                 for atype, aname, opt in args])
+            argstr += ", PyArena *arena"
         else:
-            argstr = "void"
+            argstr = "PyArena *arena"
         self.emit("%s %s(%s);" % (ctype, name, argstr), 0)
 
     def visitProduct(self, prod, name):
@@ -265,6 +266,10 @@
             self.emit(s, depth, reflow)
         argstr = ", ".join(["%s %s" % (atype, aname)
                             for atype, aname, opt in args + attrs])
+        if argstr:
+            argstr += ", PyArena *arena"
+        else:
+            argstr = "PyArena *arena"
         self.emit("%s" % ctype, 0)
         emit("%s(%s)" % (name, argstr))
         emit("{")
@@ -280,7 +285,7 @@
                 emit('return NULL;', 2)
                 emit('}', 1)
 
-        emit("p = (%s)malloc(sizeof(*p));" % ctype, 1)
+        emit("p = (%s)PyArena_Malloc(arena, sizeof(*p));" % ctype, 1);
         emit("if (!p) {", 1)
         emit("PyErr_NoMemory();", 2)
         emit("return NULL;", 2)
@@ -655,7 +660,7 @@
     c = ChainOfVisitors(TypeDefVisitor(f),
                         StructVisitor(f),
                         PrototypeVisitor(f),
-                        FreePrototypeVisitor(f),
+##                        FreePrototypeVisitor(f),
                         )
     c.visit(mod)
     f.close()
@@ -671,8 +676,8 @@
     print >> f
     v = ChainOfVisitors(MarshalPrototypeVisitor(f),
                         FunctionVisitor(f),
-                        FreeUtilVisitor(f),
-                        FreeVisitor(f),
+##                        FreeUtilVisitor(f),
+##                        FreeVisitor(f),
                         MarshalUtilVisitor(f),
                         MarshalFunctionVisitor(f),
                         )