Week 10 Class 18 Thu Mar 20 Posted: Mar 20
After Class
Project 2
I found two issues that I created were incorrect. They both involved a blank line after the filename in a header comment.
I added the label false positive to the issue in GitHub. I considered deleting the issue, but that would lose the history, including your comments.
For the score, if you did v2c, I added a point to your v2c score and your overall score. Each issue was worth 0.5 points.
Announcements
Exercise 54: Memory Due Date extended.
I gave a score and any feedback to those who successfully completed the exercise so they can then work on Memory II.
If you did not get a score, then one of the following applies:
valgrind
does not show a clean run with no memory leaksconsumer()
Whatever the reason above, I will allow you to fix it.
Producer/Consumer
Some of you treated the function consumer()
as a function for deleting memory. That is not the entire purpose of consumer()
. This is indicated by the:
which is the universal (code example) symbol for "Other processing will occur, but we are ignoring for now to make a point". Some example of what could occur in producer/consumer, in addition to memory allocation/deallocation:
Scenario | Producer Action | Consumer Action |
---|---|---|
Image Processing | Load an image from disk | Process the image (apply filters, resize, save output) |
Logging | Create a log entry with explanation, severity, and timestamp | Write the log entry to a file |
Database Connection | Initialize a database connection | Use the connection to execute a query or transaction |
Asynchronous Task Processing | Produce work items (e.g., tasks) | Retrieve a task from a shared queue and process |
Agenda
Exercise 58: Memory II
Note that Exercise 54: Memory is a prerequisite.
Replace the raw pointers (e.g., int* p
) with std::unique_ptr<int>
. Ensure it runs successfully and you have a clean Valgrind run. The include file for std::unique_ptr
is <memory>
. Once done, tag this in Git as smartpointer
Unless otherwise noted, exercises are due by 4:30 pm on Mon Mar 31