+STATIC_IF_DEBUG void
+checking_free (void *ptr)
+{
+ /* Wget's xfree() must not be passed a NULL pointer. This is for
+ historical reasons: pre-C89 systems were reported to bomb at
+ free(NULL), and Wget was careful to not call xfree when there was
+ a possibility of PTR being NULL. (It might have been better to
+ simply have xfree() do nothing if ptr==NULL.)
+
+ Since the code is already written that way, this assert simply
+ enforces the existing constraint. The benefit is double-checking
+ the logic: code that thinks it can't be passed a NULL pointer,
+ while it in fact can, aborts here. If you trip on this, either
+ the code has a pointer handling bug or should have called
+ xfree_null instead of xfree. Correctly written code should never
+ trigger this assertion.
+
+ The downside is that the uninitiated might not expect xfree(NULL)
+ to abort. If the assertion proves to be too much of a hassle, it
+ can be removed and a check that makes NULL a no-op placed in its
+ stead. If that is done, xfree_null is no longer needed and
+ should be removed. */
+ assert (ptr != NULL);
+
+ free (ptr);
+}
+\f