title: C: Function do Delete a Node on a Generic Linked List
body: <p>I'm having trouble writing a function that will delete a node on a generic linked list. </p>
  
  <p>I have my linked list declared as follow (this is the way my professor wants us to do):</p>
  
  <pre><code>typedef enum _STATUS {ERROR,OK} STATUS;
  typedef enum _BOOLEAN {FALSE, TRUE} BOOLEAN;
  
  #define MAX_NOME 20
  
  
  typedef struct _FUNC
  {
      char name[MAX_NOME];
      char dept[MAX_NOME];
      BOOLEAN permanent;
  } FUNC;
  
  
  typedef struct _LIST_NODE
  {
      void * data;
      struct _LIST_NODE * next;
  } LIST_NODE;
  
  
  typedef LIST_NODE * LIST;
  
  #define DATA(node) ((node)-&gt;data)
  #define NEXT(node) ((node)-&gt;next)
  </code></pre>
  
  <p>I've come with this function to delete all nodes with permanent == FALSE, but it is really not working. </p>
  
  <pre><code>void DeleteFuncNotPermanent(LIST *list)
  {
  
      LIST *node = list;
  
      while ((*list)-&gt;next != NULL)
      {
          if(((FUNC*)DATA(*list))-&gt;permament == FALSE)
          {
              node = list;
              list = &amp;(NEXT(*node));
  
              free(DATA(*node));
              free(*node);
  
          }
          else
          {
              list = NEXT(*list);
          }
      }
  }
  </code></pre>
  
  <p>Any feedback would be greatly appreciated. Thank you. </p>