Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!caip!seismo!gatech!akgua!whuxlm!whuxl!houxm!hropus!riccb!ihopa!ihnp4!ltuxa!ttrdc!levy From: levy@ttrdc.UUCP (Daniel R. Levy) Newsgroups: net.unix,net.unix-wizards,net.arch,net.lang.c Subject: Re: get size of malloc'd object Message-ID: <1014@ttrdc.UUCP> Date: Sat, 28-Jun-86 18:47:37 EDT Article-I.D.: ttrdc.1014 Posted: Sat Jun 28 18:47:37 1986 Date-Received: Mon, 30-Jun-86 06:06:59 EDT References: <165@daisy.UUCP> <334@valid.UUCP> <2206@peora.UUCP> <2081@umcp-cs.UUCP> <9894@ucsfcgl.ucsfcgl.UUCP> Organization: AT&T, Computer Systems Division, Skokie, IL Lines: 18 Xref: watmath net.unix:8456 net.unix-wizards:18666 net.arch:3618 net.lang.c:9659 In article <9894@ucsfcgl.ucsfcgl.UUCP>, arnold@ucsfcgl.UUCP writes: >In article <2081@umcp-cs.UUCP> chris@umcp-cs.UUCP (Chris Torek) writes: >So put the int at the end of the space, after increasing the size >to be allocated by sizeof (int) + enough space to align the int >on a byte which is a multiple of sizeof (int). Then return the >original malloc()ed pointer. > >Can we say "hack"? > > Ken Arnold Now tell me please, how is one supposed to get at the int containing the size later on (only knowing the pointer)? You have to know the size in order to calculate the offset to reach the size data! Hardly sounds useful (that's why the other suggestions have been to PREpend the size data, so its location is known, though details have to be ironed out which has been fueling much of the debate).