Leak-fix in CheckFileChanges().

Previously neglected to clear allowuserlist of ServerAccess.
The connectionlist member should be clear already, in this code.
Enterprise leak-fix: clean up its report-book filters before exit.

Purely to calm valgrind down; it's a one-off leak, so not a problem
during normal running.
Add (partial) finalization for generic agent.

We have an initialization function for the generic agent, that calls
initialization code for cfnet; but neither had matching finalize code,
even though the cfnet one calls initializations that do have matching
shutdown code (that no-one calls).  Similar problems with server.

Begin sketching what relevant clean-up would look like, based on the
first few leaks I saw due to its absence ...

Fold EvalContextDestroy() and GenericAgentConfigDestroy() into
GenericAgentFinalize(), to simplify everywhere's final clean up.  In
the process, catch a few cases that used to neglect the former.
Leak-fix: clear away PRIVKEY and PUBKEY in TLSDeInitialize().
Leak-fix: free db_handles[*].filename in CloseAllDBExit().

The filename was created by xstrdup() via DBIdToPath() and
MapNameCopy(), so we have a duty to free() it eventually.

Cowardice: I'm only doing it, for now, if all DB users finished, since
I don't know what pain it might cause for one of them that's still
running ... but I left a TODO comment to look into that.
Move some fileno() calls outside locked intervals.

They don't need to be inside.
Close FILE* also on premature returns from cf_pclose().

At the same time, simplify the locking and make sure we don't call
cf_pwait(-1), which made no sense.  The check that CHILDREN is
non-NULL could have been invalidated, between unlock and lock, by
another thread's attempt to realloc() it failing, so the locking
change could avoid a crash.
Leak-fix: free(CHILDREN) when done with array.

If it makes sense for CloseChildrenFD() to close all the child FDs,
surely it also makes sense to clear the array.  The previous commit's
changes to locking in cf_pclose() make this safe.
Rename a variable for clarity.

SetChildFD's "new_fd" was just a new size for a buffer (indexed by
fd), not actually a "real" fd in any sense.

Add a TODO about why high fd values are reported as error (but handled
gracefully, so they're no real problem).  Not clear from the context.
Leak-fix: clean up lexer state after parsing.

Also make the provenance of yacc/lex globals explicit.
Document a known leak.
Clear auth and ACL data on exit, when possible.

Moved clean-up code for SV, *_acl and friends to a separate function
(shortening CheckFileChanges) and arranged for StartServer() to call
this, when it safely can, on exit to (try to) avoid some boring leaks
that clutter valgrind's logs.
Fixes for inappropriate formats in a test.

unsigned long isn't size_t.

It made no sense to use an intptr_t for the counter of a loop bounded
by an int.  The counter is cast to void*, but casting it via intptr_t
(to silence warnings about size-mangling casts) makes more sense than
making the counter actually be an intptr_t.  Likewise, when collecting
the int back from a void*, cast via intptr_t but use an int.
Merge pull request #1733 from ediosyncratic/leak-fixes

redmine 5708: Leak fixes in core

Passed all unit and acceptance tests locally.