FIND SIZE OF MEMORY ALLOCATE???

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Mikael Aronsson wrote:

>Hi !
>
>I think he wanted to know how much memory was allocated in the malloc
>request, like the _msize( ptr) function on Visual Studio, as far as I know
>there is no way to do that with gcc.
>
>Mikael
>
Hi

I think that what you are looking for is "sizemem = strlen( ptr ) + 1;" 
this will
return the number of characters where "sizeof( char )" is usualy one 
byte plus an
extra byte to account for the required NULL terminator.


I have used this scenario in the past :

int test1(char * data){
    char * string1;
    char buffer[257];



[Index of Archives]     [Kernel Newbies]     [Red Hat General]     [Fedora]     [Red Hat Install]     [Linux Kernel Development]     [Yosemite News]

  Powered by Linux