# SanityCheckMemDebug

Checks all current memory allocations to make sure all of the allocation cookies are intact

### Synopsis

`Err SanityCheckMemDebug(const TagArg *args);`

### Description

This function checks all current memory allocations to see if any of the memory cookies have been corrupted. This is useful when trying to track down at which point in a program's execution memory cookies are being trashed.

The routine will also complain about any memory allocated by a task or thread that doesn't exist anymore. This only happens if the MEMDEBUGF_ALLOW_OWNER_SWITCH flag was not specified when calling `CreateMemDebug()`.

### Arguments

args
  A pointer to an array of tag arguments containing extra data for this function. This must currently always be NULL.

### Return Value

Returns > = 0 if successful or a negative error code if not. Current possible error code is.

MEMDEBUG_ERR_BADTAG
  An undefined tag was supplied. Currently the args parameter to this function should always be NULL.

### Implementation

Library routine implemented in memdebug.lib V24.

### Associated Files

mem.h, memdebug.lib

### See Also

``CreateMemDebug`(), DeleteMemDebug(), DumpMemDebug()`

#