Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!wuarchive!zaphod.mps.ohio-state.edu!sdd.hp.com!hplabs!hpl-opus!hpnmdla!danm From: danm@hpnmdla.HP.COM (Dan Merget) Newsgroups: comp.lang.c Subject: Re: Re: Re: What should "*nft = *(struct need_to_free *) ntf->addr;" do? Message-ID: <4040001@hpnmdla.HP.COM> Date: 9 Sep 90 21:58:50 GMT References: <1518@athen.sinix.UUCP> Organization: HP Network Measurements Div, Santa Rosa, CA Lines: 48 > { > struct need_to_free { > struct need_to_free *addr; > int nbytes; > } *ntf = &kmem_info.need_to_free_list; > > *ntf = *(struct need_to_free *) ntf->addr; > } I don't claim to be any C guru (I'm still trying to decipher that ANSI paragraph you quoted). However, it seems to me that your code simply copies the first sizeof(struct need_to_free) bytes from the second object in the linked list to the first object. In that case, I think that your code would give you the following linked list: +-------------+ +------------+ +-------------+ | | | | | | ntf -> | addr p2 ----------> | addr p3 -------> | addr p4 | | | | | | | +-------------+ +------------+ +-------------+ | | | | | | | nbytes n1 | | nbytes n3 | | nbytes n4 | | | | | | | +-------------+ +------------+ +-------------+ To get the result you're looking for, the last line of code should be either: ntf = ntf->addr; or: *(need_to_free_list_type *) ntf = *(need_to_free_list_type *) ntf->addr; where "need_to_free_list_type" is the type of kmem_info.need_to_free_list. On the other hand, maybe I simply need to sign up for "Oversimplifiers Anonymous". :-) _ | | /\ ________________________________________________ __| |__/ /_/\____/\__\ This note is not intended to represent the \ / _ |_ __/ \__/ \___ viewpoints of my god, my country, my company,\ / / | |/ / / /\ \/ /\ \ \ or my family. I'm not even certain that \ \ \_| |\ \/\ \ \ / / / / it accurately represents my own. / \____| \__/\/ \/ \/ /_______________________________________________/ Dan Merget danm@hpnmdla.HP.COM