Re: C and zero-sized arrays - what is the standard?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> This is for my knowlege in which kind
> of situations you make use of these
> type of structure definitions.

We are using this to store the virtual methods table that belongs to classes 
meta-data in an object-oriented operating system. Every class is defined by 
the same structure (CardClass), but they each class have different methods 
and therefore the number of methods is not fixed (but known statically).

Using a pointer that we would allocate is not an option. First, because we are 
in the kernel-space of the operating system, and second, because this 
operating system is designed for very small and limited embedded systems 
(typically smartcards). By declaring a variable-length table of virtual 
methods we are sure that the vtable will be located right with the rest of 
the structure (and not allocated god-knows-where). This makes it possible to 
write smaller, more efficient code and saves us a pointer to the vtable. And 
yes, 4 bytes are worth saving on a smartcard. ;)

Alex.


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux