Re: [Libbt-devel] restructuring
Brought to you by:
ksmathers
From: Elliott M. <eh...@m5...> - 2005-02-24 04:34:38
|
>From: Alien <ali...@us...> > it looks like the benc types are all in types.h and as i understand that most > things started there, this is not how things should be: > > I intend to make the benc types and functions use benc instead of bt prefix. > combined with making the bencObject_t a union instead of how it is now. > furthermore, it has seemed to me that this allocated item that's in every > benc type looks useless. it seems that this type should be filled out in one > burst, to improve efficiency, (especially if frontends would use > multithreading). of course i could be wrong, so tell me. Sorry for the slow commentary, my BT energy has been spent elsewhere. My copy of the tree is also somewhat behind due to this. Unfortunatly a nice simple answer to the above two. NO. bt vs benc, look at what those structures are holding. They're holding digested values, not raw benc data. So bt* seems more appropriate to me. You clearly didn't examine how btObject is used closely enough though. You missed that the btObject is at the top of the structure, no pointers involved. They are allocated as a single blob. btObject has data that is required to be present in all of them, for which constructions of this sort make sense. Spend the time to look at them, and don't touch it until you understand why it was done. Key idea, this is object-oriented programming in C. My tendancy is to have the type information be a pointer to a jump table (notably the first thing being the deallocation function), rather than an enum. The current way works though. -- (\___(\___(\______ --=> 8-) EHM <=-- ______/)___/)___/) \ ( | EH...@gr... PGP 8881EF59 | ) / \_ \ | _____ -O #include <stddisclaimer.h> O- _____ | / _/ \___\_|_/82 04 A1 3C C7 B1 37 2A*E3 6E 84 DA 97 4C 40 E6\_|_/___/ |