allow trivial copyonwrite() on empty vec/mat/...
This commit is contained in:
parent
9c6ab037cf
commit
6715260da7
@ -69,7 +69,6 @@ extern "C" {
|
||||
|
||||
namespace LA {
|
||||
|
||||
extern bool _LA_count_check;
|
||||
|
||||
//forward declarations
|
||||
template<typename C> class NRVec;
|
||||
|
@ -44,7 +44,8 @@ namespace LA {
|
||||
GPU_START gpu_start_instant;
|
||||
#endif
|
||||
|
||||
bool _LA_count_check=true;
|
||||
const bool _LA_count_check=true;
|
||||
const bool _LA_warn_empty_copyonwrite=false;
|
||||
|
||||
extern "C" void _findme(void) {}; //for autoconf test we need a function with C linkage
|
||||
|
||||
|
@ -28,6 +28,10 @@ extern int traceback(int flags);
|
||||
extern void sigtraceback(int sig,int flags);
|
||||
}
|
||||
|
||||
extern const bool _LA_warn_empty_copyonwrite;
|
||||
extern const bool _LA_count_check;
|
||||
|
||||
|
||||
//exception class for laerror
|
||||
class LAerror
|
||||
{
|
||||
|
8
mat.h
8
mat.h
@ -1089,7 +1089,13 @@ NRMat<T> & NRMat<T>::operator|=(const NRMat<T> &rhs) {
|
||||
******************************************************************************/
|
||||
template <typename T>
|
||||
void NRMat<T>::copyonwrite(bool detachonly) {
|
||||
if(!count) laerror("attempt to call copyonwrite() for a matrix with count == 0");
|
||||
if(!count)
|
||||
{
|
||||
if(nn||mm) laerror("nonempty matrix without reference count encountered");
|
||||
if(_LA_warn_empty_copyonwrite) std::cout <<"Warning: copyonwrite of empty matrix\n";
|
||||
return;
|
||||
}
|
||||
|
||||
if(*count > 1){
|
||||
(*count)--;
|
||||
count = new int;
|
||||
|
7
smat.h
7
smat.h
@ -957,7 +957,12 @@ NRSMat<T> & NRSMat<T>::operator=(const NRSMat<T> & rhs) {
|
||||
******************************************************************************/
|
||||
template <typename T>
|
||||
void NRSMat<T>::copyonwrite(bool detachonly) {
|
||||
if(!count) laerror("calling NRSMat<T>::copyonwrite() for undefined NRSMat<T> object");
|
||||
if(!count)
|
||||
{
|
||||
if(nn) laerror("nonempty smat without reference count encountered");
|
||||
if(_LA_warn_empty_copyonwrite) std::cout <<"Warning: copyonwrite of empty smat\n";
|
||||
return;
|
||||
}
|
||||
if(*count > 1){
|
||||
(*count)--;
|
||||
count = new int;
|
||||
|
@ -145,7 +145,13 @@ while(l)
|
||||
template <class T>
|
||||
void SparseMat<T>::copyonwrite(bool detachonly)
|
||||
{
|
||||
if(!count) laerror("probably an assignment to undefined sparse matrix");
|
||||
if(!count)
|
||||
{
|
||||
if(nn||mm) laerror("nonempty sparsemat without reference count encountered");
|
||||
if(_LA_warn_empty_copyonwrite) std::cout <<"Warning: copyonwrite of empty sparsemat\n";
|
||||
return;
|
||||
}
|
||||
|
||||
if(*count > 1)
|
||||
{
|
||||
(*count)--;
|
||||
|
7
vec.h
7
vec.h
@ -1011,7 +1011,12 @@ NRVec<T>::~NRVec() {
|
||||
******************************************************************************/
|
||||
template <typename T>
|
||||
void NRVec<T>::copyonwrite(bool detachonly) {
|
||||
if(!count) laerror("copyonwrite of an undefined vector");
|
||||
if(!count)
|
||||
{
|
||||
if(nn) laerror("nonempty vector without reference count encountered");
|
||||
if(_LA_warn_empty_copyonwrite) std::cout <<"Warning: copyonwrite of empty vector\n";
|
||||
return;
|
||||
}
|
||||
if(*count > 1) {
|
||||
(*count)--;
|
||||
count = new int;
|
||||
|
Loading…
Reference in New Issue
Block a user