cmp_mem() improvements

- NULL for got and expected is handled
- reworked logic so memcmp() is not needed
- cosmetic fix in diagnostics
Make a function for finding memory difference offsets