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

functions umf<pool/provider name>ops() should return const ptr. #1080

Open
lplewa opened this issue Feb 6, 2025 · 0 comments
Open

functions umf<pool/provider name>ops() should return const ptr. #1080

lplewa opened this issue Feb 6, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@lplewa
Copy link
Contributor

lplewa commented Feb 6, 2025

Functions like umf_memory_provider_ops_t *umfOsMemoryProviderOps(void); should return const ptr.
They return static struct which should not by modified. Otherwise user can do something like this

 umf_memory_provider_ops_t *a = umfOsMemoryProviderOps(void);
 a.free = myFree();
umfProviderCreate(a, /*...*/);
/*...*/
*b = umfOsMemoryProviderOps(void);
umfProviderCreate(b, /*...*/); // still free is modified. 

This change require the change in users code. Unless they use auto, or they create provider in this way umfProviderCreate(umfOsMemoryProviderOps(), /*...*/);

@lplewa lplewa added the bug Something isn't working label Feb 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant