Skip to content
This repository was archived by the owner on Apr 17, 2026. It is now read-only.

update memory allocate check#30

Open
aronlt wants to merge 1 commit into
google:masterfrom
aronlt:master
Open

update memory allocate check#30
aronlt wants to merge 1 commit into
google:masterfrom
aronlt:master

Conversation

@aronlt

@aronlt aronlt commented Jan 24, 2016

Copy link
Copy Markdown

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
Copy Markdown

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.

@stewartmiles stewartmiles left a comment

Copy link
Copy Markdown
Contributor

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.

Comment thread src/cmockery.c
return ptr;
}

//Chech if the address is really allocated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Chech --> Check

Comment thread src/cmockery.c
const ListNode * const head = get_allocated_blocks_list();
const ListNode *node = head->next;
int rc = 0;
while(node != head){

Copy link
Copy Markdown
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
Copy Markdown
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

#include <sys/types.h>

#if UNIT_TESTING
//#if UNIT_TESTING

Copy link
Copy Markdown
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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants