get size of malloc'd object
Jim Leinweber
jiml at uwslh.UUCP
Wed Jun 25 02:15:15 AEST 1986
One nasty efficiency quirk probably ought to be mentioned. The schemes which
add extra user information to remember the size of the object are okay,
modulo some pointer alignment details. Care with the size of the objects
may be needed if you are allocating lots of them, though. Some memory
allocators allocate things in fixed sizes, such as power-of-two minus some
internal overhead. If a program is allocating funny sized buffers scaled to
cooperate with brain damaged allocators, and then adds extra overhead, the
resulting size may cause poor allocators to waste lots of space. Of course,
'knowing' the size of blocks actually allocated is not portable. But if you
are tight on address space or physical memory, it could matter.
Jim Leinweber usenet: jiml at uwslh.uucp
State Hygiene Laboratory {seismo, harvard, topaz, ihnp4,...}!
University of Wisconsin uwvax!uwslh!jiml
465 Henry Mall internet: uwslh!jiml at wisc.edu
Madison, Wisconsin, USA 53706 phone: (608) 262-8092
--
James E. Leinweber ...!{seismo,harvard,topaz,ihnp4}!uwvax!uwslh!jiml
Wisconsin State Hygiene Lab (608) 262-8092
University of Wisconsin; 465 Henry Mall; Madison, WI 53706
More information about the Comp.unix
mailing list