Syntax
#include <stdlib.h> /* also in <malloc.h> */ size_t _msize(void *ptr)Description
You cannot pass the argument of an object that has been freed.
This example displays the size of an allocated object from malloc.
#include <stdlib.h> #include <stdio.h> int main(void) { char *ptr; if (NULL == (ptr = malloc(10))) { puts("Could not allocate memory block."); exit(EXIT_FAILURE); } memset(ptr, 'x', 5); printf("The size of the allocated object is %u.\n",_msize(ptr)); return 0; /**************************************************************************** The output should be similar to : The size of the allocated object is 10. ****************************************************************************/ }Related Information