Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

update memory allocate check #30

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

update memory allocate check #30

wants to merge 1 commit into from

Conversation

aronlt
Copy link

@aronlt aronlt commented Jan 24, 2016

If we pass an invalid pointer to _test_free() function, this function will be crashed. So I update this function, add some checking code. Therefore, cmockery can test cases that free invaild pointer, and free an allocated block twice.

@cryptomilk
Copy link

cmockery is dead since several years, you probably want to take a look at https://cmocka.org which is the successor of cmockery. We are happy to accept patches to improve it.

Copy link
Contributor

@stewartmiles stewartmiles left a comment

Choose a reason for hiding this comment

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

Sorry about the slow response on this.

@@ -1377,6 +1379,22 @@ void* _test_calloc(const size_t number_of_elements, const size_t size,
return ptr;
}

//Chech if the address is really allocated
Copy link
Contributor

Choose a reason for hiding this comment

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

Chech --> Check

const ListNode * const head = get_allocated_blocks_list();
const ListNode *node = head->next;
int rc = 0;
while(node != head){
Copy link
Contributor

Choose a reason for hiding this comment

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

We roughly follow google C++ style https://google.github.io/styleguide/cppguide.html in here.

So this should have some whitespace...

"while (node != head) {"

Copy link
Contributor

Choose a reason for hiding this comment

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

Same sort of this below with the "if" statements

@@ -21,7 +21,7 @@
#endif
#include <sys/types.h>

#if UNIT_TESTING
//#if UNIT_TESTING
Copy link
Contributor

Choose a reason for hiding this comment

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

We need to keep this in place so that the wrapper for the allocator is only in place when testing.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants