Skip to content

NOT_ENOUGH_MEMORY from ramsurf after bad malloc#4

Open
lancelotsix wants to merge 1 commit into
masterfrom
return_NOT_ENOUGH_MEMORY_if_malloc_fails
Open

NOT_ENOUGH_MEMORY from ramsurf after bad malloc#4
lancelotsix wants to merge 1 commit into
masterfrom
return_NOT_ENOUGH_MEMORY_if_malloc_fails

Conversation

@lancelotsix
Copy link
Copy Markdown
Contributor

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

@serge-sans-paille
Copy link
Copy Markdown
Contributor

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

Comment thread ramsurflib.c Outdated
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.

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