Added a sanity check during free when compiled without -DNDEBUG.

There might be liftime issues with the allocated memory when copying
a pool. Therefore I added a check whether the memory was actually
allocated by the pool when freeing it.

(cherry picked from commit 614a8dfaae340730e23d66c1dbc9268d00d1e837)
Signed-off-by: Markus Blatt <markus@dr-blatt.de>
Fixed the free call in the test.

oelements stores longs which need to be converted to pointers before freeing.
Previously we actually free the entries of the array oelements and not the
stored pointers.

(cherry picked from commit f65912c20a884f755b2c5ee9e5ebe2e7ce7883c6)
Signed-off-by: Markus Blatt <markus@dr-blatt.de>
Only check for bad_alloc with -DNDEBUG.

(cherry picked from commit 016f2c7b32c77a4078fcb303dd6ba884aad442b6)
Signed-off-by: Markus Blatt <markus@dr-blatt.de>