Added VALGRIND_MALLOCLIKE_BLOCK and VALGRIND_FREELIKE_BLOCK which allow you to
use a custom-allocator and detect almost as many errors as you could detect if
you used malloc/new/new[].  (eg. leaks detected, free errors, free mismatch,
etc).

Had to fiddle with mac_malloc_wrappers.c a bit to factor out the appropriate
code to be called from the client request handling code.  Also had to add a
new element `MAC_AllocCustom' to the MAC_AllocKind type.

Also added a little documentation, and a regression test.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1643 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/memcheck/mac_shared.h b/memcheck/mac_shared.h
index 302d9ff..ff1cea3 100644
--- a/memcheck/mac_shared.h
+++ b/memcheck/mac_shared.h
@@ -128,7 +128,8 @@
    enum {
       MAC_AllocMalloc = 0,
       MAC_AllocNew    = 1,
-      MAC_AllocNewVec = 2
+      MAC_AllocNewVec = 2,
+      MAC_AllocCustom = 3
    }
    MAC_AllocKind;
    
@@ -285,6 +286,12 @@
 
 extern Bool MAC_(shared_recognised_suppression) ( Char* name, Supp* su );
 
+extern void MAC_(new_block) ( ThreadState* tst, Addr p, UInt size,
+                              UInt rzB, Bool is_zeroed,
+                              MAC_AllocKind kind );
+extern void MAC_(handle_free) ( ThreadState* tst, Addr p, UInt rzB,
+                                MAC_AllocKind kind );
+
 extern void MAC_(record_address_error)     ( Addr a, Int size, Bool isWrite );
 extern void MAC_(record_core_mem_error)    ( ThreadState* tst, Bool isWrite,
                                              Char* s );