I want to retrieve the size of a memory allocated by malloc
however g++ compiler does not regonize it.
‘_msize’ was not declared in this scope
I have included the following headers
malloc.h
stdlib.h
On the web someone say to use msize or malloc_size. Both of them does not work.
Is there any solutions? -------- I dont like 'new'
_msize is a Windows API extension
malloc_size is a MacOS extension
some other operating systems have their own extensions. Unix does not have one (although some Unix-compatible systems do)
What do you mean by "not liking" new? malloc and new do different things.
UPD: mallinfo() from <malloc.h> is commonly found on Unix systems (including Linux), but it does not give this information directly.
It seems mallinfo() can not get the memory size for a specific array
What I want is like
char* p=(char* )malloc(sizeof(chr)*10);
then how to get the size of memory p points to on unix system?