title: Cannot free memory after using strdup
body: <p>gcc 4.5.1 c89</p>
  
  <p>I am trying to free some memory. However, when I check with valgrind the memory hasn't been freed. I am wondering what I am doing wrong.</p>
  
  <p>I have the following structure:</p>
  
  <pre><code>typedef struct tag_cand_results {
      char *candidate_winners[NUMBER_OF_CANDIDATES];
  } cand_results;
  </code></pre>
  
  <p>I create an object of this structure:</p>
  
  <pre><code>cand_results *results = NULL;
  </code></pre>
  
  <p>I allocate some memory for the structure.</p>
  
  <pre><code>results = calloc(1, sizeof *results);
  </code></pre>
  
  <p>Assign some data to it</p>
  
  <pre><code>results-&gt;candidate_winners[0] = strdup("Steve Martin");
  results-&gt;candidate_winners[1] = strdup("Jack Jones");
  </code></pre>
  
  <p>Then I try to free all the memory allocated:</p>
  
  <pre><code>free(results-&gt;candidate_winners[0]);
  free(results-&gt;candidate_winners[1]);
  free(results);
  
  Just to be safe assign to NULL
  results = NULL;
  </code></pre>
  
  <p>I get the following output from valgrind.</p>
  
  <pre><code>==8119== 72 bytes in 6 blocks are definitely lost in loss record 1 of 2
  ==8119==    at 0x4A05E46: malloc (vg_replace_malloc.c:195)
  ==8119==    by 0x3FE2E82A91: strdup (strdup.c:43)
  ==8119==    by 0x400E5A: main (driver.c:116)
  ==8119== 
  ==8119== 72 bytes in 6 blocks are definitely lost in loss record 2 of 2
  ==8119==    at 0x4A05E46: malloc (vg_replace_malloc.c:195)
  ==8119==    by 0x3FE2E82A91: strdup (strdup.c:43)
  ==8119==    by 0x400E72: main (driver.c:117)
  </code></pre>
  
  <p>I don't know why the memory is not been freed?</p>
  
  <p>Many thanks for any suggestions,</p>