NULL-checks before free()

I thought I'd send a few quick cleanup diffs if people are interested.
I'm an OpenBSD dev and we include Unbound in our base system, so these
are just things I've noticed over the past few months.

Here's the first one. POSIX specifies that free() is NULL-safe. All
modern and almost all prehistoric platforms conform to this, and most
codebases already assume it.

Index: testcode/replay.c

free() has been NULL-safe since C89. (Allocators were not very standard
before then so I would expect 1980s pre-standard free() to behave
weirdly.)

Tony.

Hi Michael,

Hi Michael,

I thought I'd send a few quick cleanup diffs if people are
interested. I'm an OpenBSD dev and we include Unbound in our
base system, so these are just things I've noticed over the
past few months.

Here's the first one. POSIX specifies that free() is
NULL-safe. All modern and almost all prehistoric platforms
conform to this, and most codebases already assume it.

Thank for you for your patch, I have included it in the source.

Thanks!

Here's another: just removing a bunch of malloc casts.

I can see that was a lot of work, but the casts are necessary.
Otherwise, an assignment from an incompatible pointer type warning is
printed on some systems. Others allow it, but it is not universal.

Best regards, Wouter