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

Allow custom memory management #11

Merged
merged 1 commit into from
Apr 16, 2024
Merged

Allow custom memory management #11

merged 1 commit into from
Apr 16, 2024

Conversation

francisbouvier
Copy link
Member

Provides functions to replace standard malloc/calloc/realloc/free

Closes #8

{
return (*my_calloc)(elementCount, size);
};
void _free(void *ptr)
Copy link
Member

Choose a reason for hiding this comment

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

Why we have no *_ prefix here? And what does the *_ prefix mean?

Copy link
Member Author

@francisbouvier francisbouvier Mar 8, 2024

Choose a reason for hiding this comment

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

* is just to say it's pointer. free signature in C is void free(void *ptr) so we do not need a pointer here. You can write type* value, type * value or type *value, it's the same.

Personnaly I prefer the first version as it's more clear that the type is a pointer, but netsurf is using the last one so I tried to stick to this style.

Regarding the _ it's just the name I choose for the custom calls. I could have choose whatever name, as long as I'm using it in the macro #define free(ptr) _free(ptr)

Copy link
Member

Choose a reason for hiding this comment

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

oh ok 🤦 I was confused with the void * in fact, I did'nt realize it's a any pointer type...

Provides functions to replace standard malloc/calloc/realloc/free

Signed-off-by: Francis Bouvier <[email protected]>
@krichprollsch krichprollsch merged commit 6a7a00a into master Apr 16, 2024
5 checks passed
@krichprollsch krichprollsch deleted the custom_memory branch April 16, 2024 14:28
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.

Replace malloc/calloc/free
2 participants