Skip to main content
Code Review

Return to Answer

Commonmark migration
Source Link

###Memory Leak###

Memory Leak

These lines here create a memory leak, because you allocate a node and never free it:

 // creates a temp node and sets it to head
 Node *temp = new Node;
 temp = head;

You don't need to allocate another node there, because you aren't actually ever using it. You can just set the temp pointer directly to head:

 Node *temp = head;

###Memory Leak###

These lines here create a memory leak, because you allocate a node and never free it:

 // creates a temp node and sets it to head
 Node *temp = new Node;
 temp = head;

You don't need to allocate another node there, because you aren't actually ever using it. You can just set the temp pointer directly to head:

 Node *temp = head;

Memory Leak

These lines here create a memory leak, because you allocate a node and never free it:

 // creates a temp node and sets it to head
 Node *temp = new Node;
 temp = head;

You don't need to allocate another node there, because you aren't actually ever using it. You can just set the temp pointer directly to head:

 Node *temp = head;
Source Link
JS1
  • 28.8k
  • 3
  • 41
  • 83

###Memory Leak###

These lines here create a memory leak, because you allocate a node and never free it:

 // creates a temp node and sets it to head
 Node *temp = new Node;
 temp = head;

You don't need to allocate another node there, because you aren't actually ever using it. You can just set the temp pointer directly to head:

 Node *temp = head;
lang-cpp

AltStyle によって変換されたページ (->オリジナル) /