You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Just want to note, that whenever you write code (you usually see this kind of thing in various tutorials) like this
m_matrix = new T*[rows]; // rows
for ( size_t i = 0 ; i < rows ; i++ ) {
m_matrix[i] = new T[columns]; // columns
}
you have a memory leak, because any of the new T[columns] can throw an exception.
Standard way to fix that is to either use std::unique_ptr or std::vector. But even better thing to do here is to use one std::vector of size columns * rows, because that will improve cache locality.
The text was updated successfully, but these errors were encountered:
Make deleted functions (copy constructor and assignment operator)
public, because preserving them private hides the original intention.
Issue: saebyn#27
Signed-off-by: Gluttton <gluttton@ukr.net>
Gluttton
added a commit
to Gluttton/munkres-cpp
that referenced
this issue
Nov 5, 2022
Make deleted functions (copy constructor and assignment operator)
public, because preserving them private hides the original intention.
Issue: saebyn#27
Signed-off-by: Gluttton <gluttton@ukr.net>
Just want to note, that whenever you write code (you usually see this kind of thing in various tutorials) like this
you have a memory leak, because any of the
new T[columns]
can throw an exception.Standard way to fix that is to either use
std::unique_ptr
orstd::vector
. But even better thing to do here is to use onestd::vector
of sizecolumns * rows
, because that will improve cache locality.The text was updated successfully, but these errors were encountered: