title: How would I go about freeing this malloc in order to prevent any memory leaks when using valgrind
body: <p>How and where would I put a free() function in this piece of code in order to prevent memory leaks when I valgrind. (This is just a piece of a larger code)</p>
  <pre class="lang-c prettyprint-override"><code>pizzaNode * AddTopping1 (char *s, pizzaNode * head) {
  
      pizzaNode * newPtr = (pizzaNode *)(malloc(sizeof(pizzaNode)));
      
      // set values of the new node
      strcpy(newPtr-&gt;topping, s);
      newPtr-&gt;next = NULL;
      
      // Add the topping to the beginning of the list:
      if (head == NULL)
      {
          head = newPtr;
      }
      else
      {
          newPtr-&gt;next = head;
          //head = newPtr;
      }
  
      
      return newPtr;  // newPtr is the new head now
  }
  </code></pre>
  <p>Or at least what is the syntax to write a free() function for this malloc?</p>