On Tue, Jan 27, 2009 at 08:37:08 -0800, ge...@gnu.org wrote: > Hi hackers, > > I attach a patch for stack based iterators, in list and hash modules. > > BTW, the current gnulib iterators are 28 bytes long, correct me if I'm wrong. > I gave 48 bytes to iterators, though this remains open to discussion.
They're 56 bytes on x86_64. Since all the struct's values are pointers or size_t (which is pointer-sized on x86/x86_64), it would make sense to use a type like intptr_t instead of char. We should also verify sizeof(pdf_list_iterator_s) >= sizeof(gl_list_iterator_t) and sizeof(pdf_hash_iterator_s) >= sizeof(gl_list_iterator_t) Is there a portable way to do this at compile time? If not, assertions could be used in pdf_{list,hash}_iterator. I'm not sure how much padding we should have. The 'i' and 'j' fields are already unused by gnulib, effectively making our structure more than twice as large as necessary; but programs probably won't be allocating more than 1 or 2 iterators at a time, so I'd say it's fine as it is now (sizeof(intptr_t)*12). Are the _iterator_free methods necessary? gl_list_iterator_free doesn't do anything, and it would be a bit simpler to use the types without them. If _iterator can't fail with ENOMEM, I don't see what we'd need to free in the future. -- Michael
signature.asc
Description: Digital signature