[Previous]
[Contents]
[Next]

_msize(), _bmsize(), _fmsize(), _nmsize()

return the size of an allocated block of memory

Synopsis:

#include <malloc.h>
size_t _msize( void *buffer );
size_t _bmsize( __segment seg,
                void __based(void) *buffer );
size_t _fmsize( void __far *buffer );
size_t _nmsize( void __near *buffer );

Description:

The _msize() functions return the size of the memory block pointed to by buffer that was allocated by a call to the appropriate version of the calloc(), malloc() or realloc() functions.

You must use the correct _msize() function as listed below, depending on which heap the memory block belongs to:

_msize()
Depends on data model of the program (see below)
_bmsize()
Based heap specified by seg value
_fmsize()
Far heap (outside the default data segment)
_nmsize()
Near heap (inside the default data segment)

In small data models (small and medium memory models), _msize() maps to _nmsize(). In large data models (compact, large and huge memory models), _msize() maps to _fmsize().

Returns:

The size of the memory block pointed to by buffer.

Examples:

#include <stdio.h>
#include <malloc.h>

void main()
  {
    void *buffer;

    buffer = malloc( 999 );
    printf( "Size of block is %u bytes\n",
        _msize( buffer ) );
  }

produces the output:

Size of block is 1000 bytes

Classification:

WATCOM

Safety:
Interrupt handler Yes
Signal handler Yes
Thread Yes

See also:

calloc(), _expand(), free(), halloc(), hfree(), malloc(), realloc(), sbrk()


[Previous]
[Contents]
[Next]