Skip to content

Commit

Permalink
Dropped useless bigdata member in the functions example
Browse files Browse the repository at this point in the history
It served no purpose (copy was not slow there, only a sleep made it slow) and was discovered (the hard way) to make windows users having very strange segfaults. Simply because it was too large to be on the stack in such context and was screwing memory !
  • Loading branch information
Sebastien Ponce authored and sponce committed Sep 1, 2023
1 parent 6ed1585 commit 79b509b
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 2 deletions.
1 change: 0 additions & 1 deletion exercises/functions/Structs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,4 @@ SlowToCopy::SlowToCopy(const SlowToCopy& other) {
std::cout << __func__ << ": Please don't copy me. This is slow.\n";
std::this_thread::sleep_for(std::chrono::seconds(3));
name = other.name;
std::memcpy(bigdata, other.bigdata, sizeof(bigdata));
}
1 change: 0 additions & 1 deletion exercises/functions/Structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ struct FastToCopy {

struct SlowToCopy {
std::string name;
int bigdata[1000000];

// Functions to create and copy this struct.
// We go into details on the next days.
Expand Down

0 comments on commit 79b509b

Please sign in to comment.