Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

NOT_ENOUGH_MEMORY from ramsurf after bad malloc #4

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

Conversation

lancelotsix
Copy link
Contributor

Return NOT_ENOUGH_MEMORY from ramsurf in case a malloc or a realloc
fails during the computatoin.

@serge-sans-paille
Copy link
Contributor

There is a typo in the commit description: computatoin -> computation

#ifdef __SSE3__
_MM_SET_FLUSH_ZERO_MODE(flush_mode);
#endif
return NOT_ENOUGH_MEMORY;
Copy link
Contributor

Choose a reason for hiding this comment

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

There is an obvious code duplication for the cleaning part here. The common way to avoid this is to use a goto end: that would perform the error checking before returning, or to nest tests. Either ways, duplicating the #ifdef looks bad to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought about it but was not sure what would be the plocy about gotos. I do not like this code duplication solution either, it is a nightmare to maintain..
I'll change my proposal with the goto solution.

@serge-sans-paille
Copy link
Contributor

Maybe you should add a test case that triggers the OUT-OF-MEMORY scenario too?

Return NOT_ENOUGH_MEMORY from ramsurf in case a malloc or a realloc
fails during the computatoin.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants