title: C delete a record from struct where dynamic memory allocated
body: <p>using ANSI C and gcc with -Wall -pedantic</p>
  
  <p>I have struct and I pre-populate its data in a loop. Later on I will need to delete a record from it. Let's say record number 3. If I use <code>free(snode[2]);</code> would it be enough? Will it decrease the record count automatically?</p>
  
  <hr>
  
  <p><strong>EDITED</strong></p>
  
  <pre><code>struct stock_data 
  {
      int ticket_price;
      int stock_level;
  };
  
  typedef struct stock_node 
  {
      struct stock_data * data;
  } stock_node;
  
  stock_node * snode = NULL;
  
  for(x = 0; x &lt; 6; x++) {
     snode = (stock_node *) realloc(snode, x+1 * sizeof(stock_node));
     if (snode == NULL) { exit(1); }
  
     snode[x].data = (struct stock_data *) calloc(1, sizeof(struct stock_data));
  
     snode[count - 1].data-&gt;ticket_price = 100;
  
     snode[count - 1].data-&gt;stock_level = 10;
  
  }
  </code></pre>