Skip to content

Commit

Permalink
always use delete[] when memory was allocated with new[]
Browse files Browse the repository at this point in the history
  • Loading branch information
ennorehling committed Nov 13, 2015
1 parent 57fde25 commit 3c65633
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions astring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 161,7 @@ AString AString::operator (const AString &s)
temp[i ] = s.str[j];
}
AString temp2 = AString(temp);
delete temp;
delete[] temp;
return temp2;
}

Expand Down Expand Up @@ -303,7 303,7 @@ AString *AString::getlegal()

*temp2 = '\0';
AString * retval = new AString(temp);
delete temp;
delete[] temp;
return retval;
}

Expand Down Expand Up @@ -365,6 365,6 @@ istream & operator >>(istream & is,AString & s)
s.len = strlen(buf);
s.str = new char[s.len 1];
strcpy(s.str,buf);
delete buf;
delete[] buf;
return is;
}

0 comments on commit 3c65633

Please sign in to comment.