title: Pointer arithmetic for structures gives strange result
body: <p>I have following function:</p>
  
  <pre><code>void deleteInventory( struct book** inventory )
  {
      struct book* ptr = NULL;
      ptr = *inventory;
  
      while( length != 0)
      {
          free(ptr);
          length--;
          ++ptr;
      }
      free(inventory);
  }
  </code></pre>
  
  <p>Structure:</p>
  
  <pre><code>#define MAX_LENGTH 64
  #define ISBN_LENGTH 11
  
  struct book
  {
      char isbn[ISBN_LENGTH];
      char title[MAX_LENGTH];
      char author[MAX_LENGTH];
      int year;
      float price;
  };
  </code></pre>
  
  <p>Total size of the structure: <strong>147 bytes</strong> (11 + 64 + 64 + 4 + 4)
  sizeof(struct book) returns: <strong>148 bytes</strong></p>
  
  <p>My inventory variable is array of structures and contains 3 records</p>
  
  <p>Now, results of debugging in the function (addresses without high 2 bytes):</p>
  
  <pre><code>inventory[0] = 0x1350
  inventory[1] = 0x14e0
  inventory[2] = 0x1670
  </code></pre>
  
  <p>Difference in memory: 400 bytes, OK</p>
  
  <p>On first iteration everything is OK, first record deletes without a problems</p>
  
  <p>But after</p>
  
  <pre><code>++ptr;
  </code></pre>
  
  <p>ptr will contain: <strong>0x13e4</strong></p>
  
  <p><strong>inventory[0] - ptr = 148 bytes</strong> - correct difference according to structure's size</p>
  
  <p>but it does not refers to next record, because address of the next record in memory:  <strong>0x14e0</strong> and I'm getting corruption of the heap.</p>
  
  <p>Any suggestions: why?</p>