KnowledgeBase Archive

An Archive of Early Microsoft KnowledgeBase Articles

View on GitHub

Q66703: C 6.00/6.00a Online Help Example for _heapwalk() Is Incorrect

Article: Q66703
Product(s): See article
Version(s): 6.00 6.00a | 6.00 6.00a
Operating System(s): MS-DOS | OS/2
Keyword(s): ENDUSER | docerr _heapwalk | mspl13_c
Last Modified: 28-JAN-1991

The program example HEAPWALK.C that is found in the C versions 6.00
and 6.00a online help is incorrect. Compiling the program under large
model in OS/2 causes a general protection error. When compiling the
program without the Quick Compile option (/qc) turned on, the
following warning message will appear twice:

   Warning c4061: long/short mismatch in argument: conversion supplied

This warning message is cause by the failure to type cast the
following statement

   heapdump(254);

to the following:

   heapdump((char)254);

The second "for" loop in the program causes the general protection
fault. The variable "i" is not initialized to the correct value. The
code currently reads as follows:

   for( ; i >= 0; i-- )
   {
      free( p[i] );
      printf("Deallocating %u at %Fp\n",
               _msize( p[i] ), (void _far *)p[i]);
   }

It should read as follows:

   for( i=9; i >= 0; i-- )    // <--- THIS LINE HAS BEEN CHANGED.
   {
      free( p[i] );
      printf( "Deallocating %u at %Fp\n",
              _msize( p[i] ), (void _far *)p[i] );
   }

The problem with the loop is that the value of i is equal to 10 when
the loop begins; it should be 9.

THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Copyright Microsoft Corporation 1986-2002.