mirror of
https://github.com/kamranahmedse/developer-roadmap.git
synced 2025-08-16 06:04:24 +02:00
Change to the correct data type (#4343)
This commit is contained in:
committed by
GitHub
parent
3b7e5d5ce2
commit
5cff162a94
@@ -22,7 +22,7 @@ For example, this code will not have a memory leak:
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
void no_memory_leak() {
|
void no_memory_leak() {
|
||||||
std::shared_ptr<int> ptr = std::make_shared<int[]>(100); // Allocating memory in the heap for an array of integers using shared_ptr
|
std::shared_ptr<int[]> ptr = std::make_shared<int[]>(100); // Allocating memory in the heap for an array of integers using shared_ptr
|
||||||
// Some code...
|
// Some code...
|
||||||
} // shared_ptr goes out of scope and it will automatically deallocate the memory block assigned to it.
|
} // shared_ptr goes out of scope and it will automatically deallocate the memory block assigned to it.
|
||||||
```
|
```
|
||||||
|
Reference in New Issue
Block a user