Mail Archives: djgpp/1999/03/05/08:59:12
In article <Pine DOT SV4 DOT 3 DOT 93 DOT 990304205056 DOT 29767A-100000 AT tagore> you wrote:
> hi,
[...]
> Is there any way by which I can find the length of
> the allocated memory block, given a pointer to the block?
In general: no. If you really want to do that, and are willing to make
your code dependent on something as volatile as the DJGPP library
revision you're compiling with, you can look up the sources for
malloc(), and see where it stores its internal information about the
memory blocks (usually a short distance before the pointer it returns
to the application).
But again: such a feature is not available to an anywhere near
'stable' or 'portable' program, in C. If at all possible, re-think
your strategy. You'll have to either take an additional argument to
that function, or force the user to use a 'malloc()' replacement
provided by you, that keeps a record of what block was given out at
what size.
--
Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de)
Even if all the snow were burnt, ashes would remain.
- Raw text -