title: Valgrind finding memory leak for string even after I free it
body: <p>In my program I declare some nodes in a linked list:</p>
  
  <pre><code>node_t* newSymbol = malloc(sizeof(node_t));
  
  newSymbol-&gt;symbol.name = strdup(name); //name is a (const) char* that is a parameter to function I'm in.
  newSymbol-&gt;symbol.addr = addr;
  </code></pre>
  
  <p>I use strdup because assigning the symbols name to the parameter directly like this: </p>
  
  <pre><code>newSymbol-&gt;symbol.name = name;
  </code></pre>
  
  <p>says there is an error when I discard the const property of the passed param. </p>
  
  <p><strong><em>Issue</em></strong>: I read on another stack overflow that you need to free memory created by strdup. I do the following for each node as my program exits:</p>
  
  <pre><code>free((void*)node-&gt;symbol.name);//free the memory allocated by strdup
  free((void*)node);//here I free the node itself
  </code></pre>
  
  <p>I've managed to clear all leak issues except one:</p>
  
  <pre><code>8 bytes in 1 blocks are definetely lost in loss record 1 of 1
      at 0x4C2DB6B: malloc (vg_replace_malloc.c:299)
      by 0x4ECE489: strdup (in /usr/lib64/libc-2.25.so)
      by 0x400EE7: symbol_add (symbol.c:117)
  </code></pre>
  
  <p>I checked line 117 of symbol.c and sure enough it's where strdup is used as I have pasted above. I'm not sure how to clear the memory associated with this so I don't get any memory leaks. Please Help! Thanks so much.</p>