What should "*nft = *(struct need_to_free *) ntf->addr;" do?
Dan Merget
danm at hpnmdla.HP.COM
Mon Sep 10 07:58:50 AEST 1990
> {
> 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 at hpnmdla.HP.COM
More information about the Comp.lang.c
mailing list