Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!philabs!prls!pyramid!pesnta!valid!ed From: ed@valid.UUCP (Ed Patriquin) Newsgroups: net.unix,net.unix-wizards,net.arch,net.lang.c Subject: Re: get size of malloc'd object Message-ID: <334@valid.UUCP> Date: Fri, 13-Jun-86 16:30:37 EDT Article-I.D.: valid.334 Posted: Fri Jun 13 16:30:37 1986 Date-Received: Sun, 15-Jun-86 04:15:35 EDT References: <165@daisy.UUCP> Organization: Valid Logic, San Jose, CA Lines: 31 Xref: linus net.unix:7438 net.unix-wizards:15319 net.arch:3123 net.lang.c:8616 > Xref: pesnta net.unix:21451 net.unix-wizards:22133 net.arch:21118 net.lang.c:21930 > > > I have a need in my application to find the size of a > previously malloc'd object (maybe an array or structure). > 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. > NAME: Michael Umansky (misha) > Daisy Systems Corp. Well in UNIX(TM) one could write their own memory allocator and include a chunksize (ptr) function, I don't know how you would do it in DNIX(TM). But really, why not establish a protocol between the offending functions. Since some function somewhere knows how big the chunk is, create a data structure which contains the information and make it available to the rest of the program. It is really hard to come up which general purpose algorithmic solutions to problems without having even a glimmer of what environment you are talking about, i.e. passing around display lists, or strings or matrix inversion. -- IRS: Ed Patriquin USENET: ...!ucbvax!hplabs!pesnta!valid!ed USPS: Valid Logic, 2820 Orchard Parkway, San Jose, Calif 95134 ATT: (408) 945-9400 This disclaimer is to disclaim any knowledge of a disclaimer.