Dave Robillard wrote:
> I still don't see where you're getting all this messy code stuff.
> Adding 8 to a pointer isn't any more or less messy than adding 16 to a
> pointer.
uint32_t *p = &some_int_array[0];
p += 7;
Q: Where does p point now?
A: 28 bytes ahead of its previous value.
That's where the elegance-related problem lies (IMO).
If the struct size is 16, and you want to increase the pointer by 8
bytes, you need to cast to char*, increase by 8, and cast back to
LV2_EVENT_HEADER. That's what was (and is) bugging me.
i += (events[i].size+7) >> 3;
is a bit nicer than:
p = (LV2_EVENT_HDR *)((char *)p + ((p->size + 7) &~7));
to me. Still, it's just one line of code, and can be put inside of a
macro or something, so the messiness might be perfectly bearable. I
might also keep the current pointer as char * for easy incrementing, and
cast to LV2_EVENT_HEADER * (or whatever) when needed.
Putting things in perspective, it's not even nearly as ugly as what goes
on inside plugins' inner loops, so it might be perfectly acceptable ;)
Krzysztof
_______________________________________________
Linux-audio-dev mailing list
Linux-audio-dev@email-addr-hidden
http://lists.linuxaudio.org/mailman/listinfo/linux-audio-dev
Received on Sun Dec 2 04:15:04 2007
This archive was generated by hypermail 2.1.8 : Sun Dec 02 2007 - 04:15:04 EET