This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Determining the size of allocated memory from a pointer


Justin_10 <justi_10@rediffmail.com> writes:

> I am doing image processing application in which i will be getting two
> things pointer and a memory size pointed by this pointer.
>
> So for each invocation down the line i have to pass this two parameters.
>
> Is it possible to know the size of memory from the pointer itself.
>
> Please suggest for suitable solutions.
>
> for eg msize on windows.

This is actually not a compiler issue.  It depends on the code that you
are using to allocate memory.  Many memory allocators do not record the
exact size of the memory block that you request; they only record the
size of the memory block that they allocate, which may be larger than
the amount you request.  That is true of the memory allocator used by
glibc on GNU/Linux, for example.  So in general there is no way to get
this information, unless you use your own memory allocator.

Ian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]