Skip to content

Conversation

@kab163
Copy link
Collaborator

@kab163 kab163 commented Jul 7, 2025

Updating lesson 3 to also include memset operator


// TODO: uncomment this print statement
//std::cout << "Allocated " << (100 * sizeof(double)) << " bytes and set to "
// << data[0] << " using the " << allocator.getName() << " allocator."
Copy link
Member

@rhornung67 rhornung67 Jul 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using memset to set an array of values to '0' and printing out the first value may not be convincing to some since sometimes memory allocations are initialized to zero by default. What do you think of doing an example like this https://www.geeksforgeeks.org/cpp/memset-in-cpp/ or something similar where the value is more convincing?

// TODO: uncomment this print statement
//std::cout << "Allocated " << (100 * sizeof(double)) << " bytes and set to "
// << data[0] << " using the " << allocator.getName() << " allocator."
// << std::endl;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, what do you think about doing a realloc operation after the memset that grows the array and then show that the values set by memset are preserved, but the new array entries are uninitialized? I think it would make the example more interesting.

@artv3
Copy link
Member

artv3 commented Jul 14, 2025

Review and merge...

@kab163 kab163 merged commit 820b9ce into main Jul 15, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants