get size of malloc'd object
Mike Umansky
misha at daisy.UUCP
Fri Jun 13 08:22:27 AEST 1986
I have a need in my application to find the size of a
previously malloc'd object (maybe an array or structure).
For example, one routine may allocate some array or just
one big chunk of memory and pass a pointer to the chunk to
another routine. This other routine now needs to know the
size of the area pointed to by this pointer. Also, this
other routine has no idea about the structure of this area
and doesn't even care. Now, the question, how can this
other routine get the size of the area pointed to by passed
pointer. Would (sizeof(*ptr)) work or will it just give
me the size of the pointer type? Another possibility would
be to write a routine which would scan malloc's allocation
array and try to match the pointers; then the size is
easily obtained. Any help and comments on this would be
greately appreciated. Either post your answers or mail them
directly please. Thanks for consideration.
--
--
NAME: Michael Umansky (misha)
E-MAIL: ucbvax!hplabs!nsc!daisy!misha
WORK:
Daisy Systems Corp.
700B Middlefield Road
Mountain View, CA 94039-7006
(415) 960-7166 (work)
HOME:
94 Cassia Ct.
Hayward, CA 94544
(415) 886-4805 (home)
More information about the Comp.lang.c
mailing list