Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Microsoft C - <b>_msize() return size of memory block</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
_msize()                 Return Size of Memory Block

 #include   <malloc.h>                   Required for declarations only

 unsigned   int _msize(ptr);
 char       *ptr;                        Pointer to allocated memory block

    _msize() returns the size, in bytes, of the memory block pointed to
    by 'ptr'.  The memory block should have been allocated by calloc(),
    malloc(), or realloc(), and may have had its size changed by
    realloc() or _expand().

    Returns:    Size in bytes of the memory block.

      Notes:    Use _fmsize() to get the size of blocks allocated with
                _fmalloc(). Use _nmsize() to get the size of blocks
                allocated with _nmalloc().

  -------------------------------- Example ---------------------------------

    The following statements allocate 500 bytes and report the size of
    the memory allocated.

            #include <malloc.h>
            #include <stdio.h>     /* for printf and NULL */

            char *memptr;

            main()
            {
                if ((memptr = malloc(500)) == NULL)
                    printf("not enough room to allocate memory\n");
                else
                    printf("%u bytes allocated\n", _msize(memptr));
            }

See Also: calloc() _expand() malloc() realloc()

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