Compare commits
No commits in common. "5417870cb57fcd9c106e734376aa645d90d095ac" and "337c9a2f79c6e742cd7215605b067c765d3b119e" have entirely different histories.
5417870cb5
...
337c9a2f79
3 changed files with 19 additions and 23 deletions
|
@ -1,9 +1,5 @@
|
||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
## Upcoming Changes
|
|
||||||
|
|
||||||
Internal refactorings.
|
|
||||||
|
|
||||||
## Version 2.9
|
## Version 2.9
|
||||||
|
|
||||||
Add checking/stat-printing of when NULL pointers are free'd.
|
Add checking/stat-printing of when NULL pointers are free'd.
|
||||||
|
|
|
@ -35,21 +35,21 @@ namespace SC_AM_Internal {
|
||||||
Malloced::Malloced() : address(nullptr), size(0), id(0) {}
|
Malloced::Malloced() : address(nullptr), size(0), id(0) {}
|
||||||
Malloced::Malloced(void *address, std::size_t size) : address(address), size(size), id(0) {}
|
Malloced::Malloced(void *address, std::size_t size) : address(address), size(size), id(0) {}
|
||||||
|
|
||||||
void ListNode::add_to_list(ListNode *head, Malloced *data) {
|
void ListNode::add_to_list(ListNode *tail, Malloced *data) {
|
||||||
ListNode *new_node = reinterpret_cast<ListNode*>(real_malloc(sizeof(ListNode)));
|
ListNode *new_node = reinterpret_cast<ListNode*>(real_malloc(sizeof(ListNode)));
|
||||||
new_node->prev = head;
|
new_node->next = tail;
|
||||||
new_node->next = head->next;
|
new_node->prev = tail->prev;
|
||||||
head->next->prev = new_node;
|
tail->prev->next = new_node;
|
||||||
head->next = new_node;
|
tail->prev = new_node;
|
||||||
|
|
||||||
new_node->data = data;
|
new_node->data = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ListNode::add_to_list(ListNode *head, ListNode *node) {
|
void ListNode::add_to_list(ListNode *tail, ListNode *node) {
|
||||||
node->prev = head;
|
node->next = tail;
|
||||||
node->next = head->next;
|
node->prev = tail->prev;
|
||||||
head->next->prev = node;
|
tail->prev->next = node;
|
||||||
head->next = node;
|
tail->prev = node;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ListNode::remove_from_list(ListNode *head,
|
bool ListNode::remove_from_list(ListNode *head,
|
||||||
|
@ -117,7 +117,7 @@ namespace SC_AM_Internal {
|
||||||
if (is_env_status == ANOTHER_MEMCHECK_QUIET_NOT_EXISTS) {
|
if (is_env_status == ANOTHER_MEMCHECK_QUIET_NOT_EXISTS) {
|
||||||
std::clog << " id: " << data->id << std::endl;
|
std::clog << " id: " << data->id << std::endl;
|
||||||
}
|
}
|
||||||
ListNode::add_to_list(malloced_list_head, data);
|
ListNode::add_to_list(malloced_list_tail, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
((std::recursive_mutex*)recursive_mutex)->unlock();
|
((std::recursive_mutex*)recursive_mutex)->unlock();
|
||||||
|
@ -136,7 +136,7 @@ namespace SC_AM_Internal {
|
||||||
if (is_env_status == ANOTHER_MEMCHECK_QUIET_NOT_EXISTS) {
|
if (is_env_status == ANOTHER_MEMCHECK_QUIET_NOT_EXISTS) {
|
||||||
std::clog << " id: " << data->id << std::endl;
|
std::clog << " id: " << data->id << std::endl;
|
||||||
}
|
}
|
||||||
ListNode::add_to_list(malloced_list_head, data);
|
ListNode::add_to_list(malloced_list_tail, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
((std::recursive_mutex*)recursive_mutex)->unlock();
|
((std::recursive_mutex*)recursive_mutex)->unlock();
|
||||||
|
@ -161,7 +161,7 @@ namespace SC_AM_Internal {
|
||||||
if (is_env_status == ANOTHER_MEMCHECK_QUIET_NOT_EXISTS) {
|
if (is_env_status == ANOTHER_MEMCHECK_QUIET_NOT_EXISTS) {
|
||||||
std::clog << ", adding id: " << deferred_node->data->id << std::endl;
|
std::clog << ", adding id: " << deferred_node->data->id << std::endl;
|
||||||
}
|
}
|
||||||
ListNode::add_to_list(malloced_list_head, deferred_node);
|
ListNode::add_to_list(malloced_list_tail, deferred_node);
|
||||||
deferred_node = nullptr;
|
deferred_node = nullptr;
|
||||||
} else {
|
} else {
|
||||||
Malloced *data = reinterpret_cast<Malloced*>(real_malloc(sizeof(Malloced)));
|
Malloced *data = reinterpret_cast<Malloced*>(real_malloc(sizeof(Malloced)));
|
||||||
|
@ -171,7 +171,7 @@ namespace SC_AM_Internal {
|
||||||
if (is_env_status == ANOTHER_MEMCHECK_QUIET_NOT_EXISTS) {
|
if (is_env_status == ANOTHER_MEMCHECK_QUIET_NOT_EXISTS) {
|
||||||
std::clog << ", adding id: " << data->id << std::endl;
|
std::clog << ", adding id: " << data->id << std::endl;
|
||||||
}
|
}
|
||||||
ListNode::add_to_list(malloced_list_head, data);
|
ListNode::add_to_list(malloced_list_tail, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -204,9 +204,9 @@ namespace SC_AM_Internal {
|
||||||
// it is expected for the OS to reclaim memory from stopped processes and
|
// it is expected for the OS to reclaim memory from stopped processes and
|
||||||
// this function only runs at the end of program execution.
|
// this function only runs at the end of program execution.
|
||||||
std::clog << "List of unfreed memory:\n";
|
std::clog << "List of unfreed memory:\n";
|
||||||
auto *node = malloced_list_tail;
|
auto *node = malloced_list_head;
|
||||||
while (node->prev != nullptr) {
|
while (node->next != nullptr) {
|
||||||
node = node->prev;
|
node = node->next;
|
||||||
|
|
||||||
if (node->data) {
|
if (node->data) {
|
||||||
std::clog << " " << node->data->address
|
std::clog << " " << node->data->address
|
||||||
|
|
|
@ -35,8 +35,8 @@ namespace SC_AM_Internal {
|
||||||
struct ListNode {
|
struct ListNode {
|
||||||
ListNode() : next(nullptr), prev(nullptr), data(nullptr) {}
|
ListNode() : next(nullptr), prev(nullptr), data(nullptr) {}
|
||||||
|
|
||||||
static void add_to_list(ListNode *head, Malloced *data);
|
static void add_to_list(ListNode *tail, Malloced *data);
|
||||||
static void add_to_list(ListNode *head, ListNode *node);
|
static void add_to_list(ListNode *tail, ListNode *node);
|
||||||
/// Returns true if removed.
|
/// Returns true if removed.
|
||||||
static bool remove_from_list(ListNode *head,
|
static bool remove_from_list(ListNode *head,
|
||||||
void *ptr,
|
void *ptr,
|
||||||
|
|
Loading…
Reference in a new issue