Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!princeton!caip!topaz!uwvax!uwslh!jiml From: jiml@uwslh.UUCP (Jim Leinweber) Newsgroups: net.unix Subject: Re: get size of malloc'd object Message-ID: <139@uwslh.UUCP> Date: Tue, 24-Jun-86 12:15:15 EDT Article-I.D.: uwslh.139 Posted: Tue Jun 24 12:15:15 1986 Date-Received: Thu, 26-Jun-86 04:07:09 EDT Organization: U of Wisconsin-Madison, State Hygiene Lab Lines: 20 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@uwslh.uucp State Hygiene Laboratory {seismo, harvard, topaz, ihnp4,...}! University of Wisconsin uwvax!uwslh!jiml 465 Henry Mall internet: uwslh!jiml@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