title: inserting in front of linked list without a dummy node
body: <p>I'm trying to insert in the front of a linked list which is sorted by node-> name and I do not have a dummy node in the filesystem-> curr->subdir</p>
  
  <pre><code>
  typedef struct Unix{
  
    struct Node *curr;
    struct Node *root;
  
  
  }Unix;
  
  typedef struct Node{
  
    struct Node *next;
    struct Node *subdir;
    struct Node *parent;
    char *name;
    char *field;
  
  }Node;
  </code></pre>
  
  <p>below is me inserting into the linked list sorted by names</p>
  
  <pre><code>
  /* iter is a node used to traverse LL */
  
  if(iter-&gt; next == NULL &amp;&amp; strcmp(iter-&gt;name, arg) &gt; 0){
        if(iter == filesystem-&gt; curr-&gt; subdir){
  /* error occurs when placing node in the front of the list */
      temp = malloc(sizeof(Node));
  
      temp-&gt; parent = filesystem-&gt; curr-&gt; subdir-&gt; parent;
      temp-&gt; subdir = NULL;
      temp-&gt; name = malloc(strlen(filesystem-&gt;curr-&gt;subdir-&gt;name) + 1);
      strcpy(temp-&gt; name, filesystem-&gt; curr-&gt; subdir-&gt; name);
      temp-&gt; next = NULL;
  
  /* add is the node that's being inserted */
      add-&gt; next = temp;
  
      filesystem-&gt; curr-&gt;subdir = add;
  
  </code></pre>
  
  <p>Error occurs when attempting to place add as the first node in filesystem-> curr-> subdir and moving the previous subdir node to be add-> next. </p>
  
  <p>EDIT: the program is a basic simulation of a unix machine. </p>