Fix memory allocs for generate.

Use the ProtobufCAllocator malloc/free.  Handle failed mallocs.