I have two functions:
zero free_this (this * this) {THIS * This_tmp; While (it_tmp = this) {if (it-> str) is free (this-> str); This is = this_tmp-> next; Free (this_tmp); }} Zero free_ (that * key) {THAT * that_tmp; Whereas (that_tmp = key) {if (that-> id) is free (that-> id); That = that_tmp-> next; Free (that_tmp); }}
Since they are very similar, I was trying to come to a ceremony to handle both of them. I can already use an indicator as per the correct data (i.e. this structure either for the straight or the ID of that structure) but I can not understand what type of straight worked with Being because I can not just use the zero indicator because there is no member of the name 'next' in the name of zero *.
Any thoughts?
Maybe I should add two strokes to this combination in some way? Here they are:
typingfifth Straight This {Straight * Next; Four * str; } this; Typedef structure that is {struct of * next; Four * id; Unsigned lesser results; The second option; } That;
Can I possibly use the offset function to get the next element?
You can enforce a free function with zero * and field offsets Attested:
zero-less_Next (zero * or so, size_t other_offset, size_t next_offet) {zero * or_tmp; While (either_tmp = either) {free ((* four *) either + other_offset); Either_tmp = (four *) either + next_offset; Free (either); }} Free_It (this, offsetof (this, str), offsetof (this, next)); Free_either (that is, offsetof (i.e., id), offsetof (next to that));
You can create macros to replace the old free_this
or free_that
functions.
No comments:
Post a Comment