Skip to content

Commit

Permalink
Merge branch 'jsalvado:master' into avg_ramp
Browse files Browse the repository at this point in the history
  • Loading branch information
atrettin authored Aug 6, 2021
2 parents 1619c0e + 6eb1358 commit d85f827
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/SUNalg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,12 @@ isinit_d(false){}
SU_vector::SU_vector(const SU_vector& V):
dim(V.dim),
size(V.size),
isinit(true),
isinit(V.isinit || V.isinit_d),
isinit_d(false){
alloc_aligned(dim,size,components,ptr_offset);
std::copy(V.components,V.components+size,components);
if(isinit){
alloc_aligned(dim,size,components,ptr_offset);
std::copy(V.components,V.components+size,components);
}
}

SU_vector::SU_vector(SU_vector&& V):
Expand Down
12 changes: 12 additions & 0 deletions test/copy_construct_SU_vector.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,21 @@ void exercise_constructor(unsigned int dim){
std::cout << '\n';
}

void copy_empty(){
SU_vector v1; //owns and refers to no memory
CLEAR_MEM_CACHE;
alloc_counting::reset_allocation_counters();
SU_vector v2(v1); //should not allocate
auto allocated=alloc_counting::mem_allocated;
if(allocated)
std::cout << allocated << " bytes allocated when no allocation should occur\n";
}

int main(){
alloc_counting::pattern_fill_allocs=true;
alloc_counting::alloc_fill_pattern=0xFF;
for(unsigned int i=2; i<=6; i++)
exercise_constructor(i);

copy_empty();
}

0 comments on commit d85f827

Please sign in to comment.