_msize
Go Up to malloc.h Index
Header File
malloc.h
Prototype
size_t _msize(void *block);
Description
Returns the size of a heap block.
_msize returns the size of the allocated heap block whose address is block. The block must have been allocated with malloc, calloc, or realloc. The returned size can be larger than the number of bytes originally requested when the block was allocated.
Return Value
_msize returns the size of the block in bytes.
Portability
POSIX | ANSI C | ANSI C++ | Win32 | Win64 | macOS | |
---|---|---|---|---|---|---|
_msize | + |
Example
#include <malloc.h> /* malloc() _msize() */
#include <stdio.h> /* printf() */
int main() {
int size;
int *buffer;
buffer = malloc(100 * sizeof(int));
size = _msize(buffer);
printf("Allocated %d bytes for 100 integers\n", size);
return (0);
}