copyonwrite() on nested LA types will recursively call element copyonwrites even if the top type had count=1
This commit is contained in:
14
sparsemat.cc
14
sparsemat.cc
@@ -143,7 +143,7 @@ while(l)
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void SparseMat<T>::copyonwrite(bool detachonly)
|
||||
void SparseMat<T>::copyonwrite(bool detachonly, bool deep)
|
||||
{
|
||||
if(!count)
|
||||
{
|
||||
@@ -152,6 +152,18 @@ void SparseMat<T>::copyonwrite(bool detachonly)
|
||||
return;
|
||||
}
|
||||
|
||||
if(*count == 1 && !LA_traits<T>::is_plaindata() && !detachonly && deep) //type-nested copyonwrite
|
||||
{
|
||||
matel<T> *l =list;
|
||||
while(l)
|
||||
{
|
||||
LA_traits<T>::copyonwrite(l->elem);
|
||||
l=l->next;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
if(*count > 1)
|
||||
{
|
||||
(*count)--;
|
||||
|
||||
Reference in New Issue
Block a user