title: fastest multi-type array solution?
body: <p>I need high-performance iteration over transient arrays (on stack and/or in heap) which can store mixed types of data, including various types of pointers.</p>
  
  <p>I thought of using unions to determine largest size of several supported array members.</p>
  
  <p>is the following, the fastest (safe) architecture and solution?</p>
  
  <pre><code>union array_sizer {
      void *(* funcPtr)();
      void *dataPtr;
      struct {int i} *strPtr;
      int intVal;
      float floatVal;
  }
  
  // create an array of 10 item *pairs*.
  union array_sizer *myArray = malloc(22 * sizeof(union array_sizer));
  
  // fill up the (null-terminated) array 
  
  // then, knowing that every *even* item is an int...
  for(int i=0; myArray[i].intVal; i+=2){
      //(... do something in loop ...)
  }
  </code></pre>
  
  <p>the array data will be created from functions which enforce data integrity, so the for loop can be pretty skimpy on error checking beyond null-termination.</p>