title: Dynamic memory reallocation for a static array field of a structure
body: <p>Consider the following structures:</p>
  
  <pre><code>// A simple structure to hold some information 
  struct A {
      unsigned long id; 
      char title[100]; 
  };
  
  // A simple database for storing records of B
  struct B {
      unsigned int tableSize; // Total available space in the 'table' field (initially, set to 5)
      unsigned int entriesUsed; // Number of used entries of the 'table' field
      struct A table[5]; 
  };
  </code></pre>
  
  <p>Is it correct to assume that the <code>realloc</code> function (line 5 below) in the following code increases the size of the <code>table</code> field correctly despite the fact that it is defined as a static array? </p>
  
  <pre><code>void add(struct B* db, struct A* newEntry)
  {
      if (db-&gt;entriesUsed &gt;= db-&gt;tableSize) {
          // Does the following line increase the size of 'table' correctly?
          db = (struct B*)realloc(db, sizeof(db) + 5*sizeof(struct A));
          db-&gt;rowsTotal += 5;
      }
  
      db-&gt;table[db-&gt;entriesUsed].id = newEntry-&gt;id;
      memcpy(db-&gt;table[db-&gt;entriesUsed].title, table-&gt;title, sizeof(newEntry-&gt;title));
  
      db-&gt;entriesUsed++;
  }
  </code></pre>