Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Borland C++ 2.x ( with Turbo C ) - <b>heapwalk() walk through the heap</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 heapwalk()              Walk Through the Heap

 #include   <alloc.h>

 int heapwalk(hinfo);
 struct heapinfo *hinfo;        Heap info structure.

        This function fills a heapinfo structure as follows:

               struct heapinfo
                {
                void *ptr;            // Address of this memory block.
                unsigned int size;    // Size in bytes.
                int in_use;           // In use flag.
                };

        The possible return values are:

                _HEAPOK         Heap is alright.
                _HEAPEMPTY      Heap is empty.
                _HEAPEND        End of the heap has been reached.

       Returns:     Greater than zero for success; negative otherwise.

   -------------------------------- Example ---------------------------------
        This example allocates, frees, and checks on a memory block.

    #include <stdio.h>
    #include <alloc.h>

    int main( void )
    {
       struct heapinfo hinfo;
       char *my_data;

          my_data = malloc(1000);
          free(my_data);

       hinfo.ptr = NULL;
       if(heapwalk(&hinfo) == _HEAPOK)
       printf("Heap is alright.\n");

       return 0;
    }

See Also: farheapwalk()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson