PurifyIsReadable example

#include <windows.h>

#include <stdio.h>

#include "pure.h"

 

void main()

{

   char    *chunk;

   HANDLE  hHeap;

   hHeap = GetProcessHeap();

   chunk = (char *)HeapAlloc(hHeap, HEAP_GENERATE_EXCEPTIONS, 15);

 

   printf("IsReadable(chunk, 1)? %d\n",

          PurifyIsReadable(chunk, 1));    /* 0 */

 

   strcpy(chunk, "Hello");

 

   printf("IsReadable(chunk, 1)? %d\n",

          PurifyIsReadable(chunk, 1));    /* 1 */

 

   printf("IsReadable(chunk, 16)? %d\n",

          PurifyIsReadable(chunk, 16));   /* 0 */

}

(C) Copyright IBM Corporation 1992, 2010.