title: Copying a pointer (instead of it's content) using memcpy
body: <p>I have a program to handle generic linked list. In one case I use it to hold strings. 
  In the function where i add the new node to the list i perform the following (among other stuff..): </p>
  
  <pre><code>void list_append(list *list, void *element)
  {
  
    // create the new node... 
    listNode *node = (listNode *)malloc(sizeof(listNode));
    node-&gt;data = malloc(list-&gt;elementSize); // NOTE : elementSize is set to be sizeof(char *)
    node-&gt;next = NULL;
    memcpy(node-&gt;data, element, list-&gt;elementSize);   //**
  
    // rest of the insertion operation....
  </code></pre>
  
  <p>Now , in the function that calls the list_append function i perform the following:</p>
  
  <pre><code> int numNames = 5;
   const char *names[] = { "David", "Kevin", "Michael", "Craig", "Jimi" }; //*
  
   int i;
   list list;
   list_new(&amp;list, sizeof(char *), free_string ,compareString);
  
   char *name;
   for(i = 0; i &lt; numNames; i++) {
   name = strdup(names[i]);
   list_append(&amp;list, &amp;name);  //****
   }
  </code></pre>
  
  <p>In addition , I have a "compare method" to compare 2 strings:</p>
  
  <pre><code>int compareString(void *str1,void *str2)
  {
  
  return strcmp(*(char **)str1 ,*(char **)str2);
  }
  </code></pre>
  
  <p>If so I have few questions:
  1) What is copied in the line where memcpy is in action ( line //** - the pointer or the content ?
  does it has anything to do with the way the data to copied is stored in the calling function (line //*)?
  2) The node of the generic linked list is defined to have : void *data; so why when i use the compare method I have to cast it to <em>(char *</em>)str1 .... would the cast be different if I had copied the string in another manner? 
  Thanks allot (!!) in advance ,Guy. </p>
  
  <p>3)Another thing - if I change the copy action performed by memcpy into :</p>
  
  <pre><code>memcpy(node-&gt;data, element, strlen((char *)element) + 1); //**
  </code></pre>
  
  <p>It works also - is there a difference in the 2 different ways ? if so - what is better ?</p>