title: How to compare linked list nodes?
body: <p>GLib library done like this to compare two singly linked list nodes:</p>
  
  <pre><code> typedef struct _GSList {
    _GSList *link;
     void *data;
  } GSList;
  
      int g_sListPosition(GSList *list, GSList *llink) {
          int cnt = 0;
          while(list) {
              if(list == llink)  // Note here
                  return cnt;
              cnt++;
              list = list-&gt;link;
          }
  
          return -1;
      }
  </code></pre>
  
  <p>But when I compare the nodes like this. It return false:</p>
  
  <pre><code>int main(void) {
      GSList *list = NULL, *list2 = NULL;
      list2 = g_sListAppend(list2, "def");
      list = g_sListAppend(list, "abc");
      list = g_sListAppend(list, "def");
      list = g_sListAppend(list, "ghi");
      printf("%d", g_sListPosition(list, list2));   // Return -1 ?
  }
  </code></pre>
  
  <p>So, what's compare here (in the DOC, it's written <em>gets the position of the given element in the GSList</em>), a node or the data contained in the list ?</p>
  
  <p>Edit: Thanks to all the given, my mistake I was actually doing it in wrong way. I have to compare same instance of the list. </p>