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

Memory leak due to missing deallocator #31

Open
sergei-mironov opened this issue May 16, 2019 · 5 comments
Open

Memory leak due to missing deallocator #31

sergei-mironov opened this issue May 16, 2019 · 5 comments

Comments

@sergei-mironov
Copy link
Owner

Ref #30

@sergei-mironov
Copy link
Owner Author

sergei-mironov commented May 17, 2019

alexandersolovyov added a commit to alexandersolovyov/xkb-switch that referenced this issue Jul 19, 2019
@alexandersolovyov
Copy link
Contributor

Actually, all needed functions are already there. It can be done in two ways:

  1. XkbRf_getNamesProp() can receive XkbRF_VarDefsPtr instead of reference toXkbRF_VarDefsRec. Then, memory must be cleared with XkbRF_Free(vdr, True).
  2. If You are using XkbRF_GetNamesProp() with a reference toXkbRF_VarDefsRec, memory should be returned using XkbRF_Free(&vdr, False).

libxkbfile is written in C, so they can not add any destructor. It is done by analogy with X library, where function XFree() must be used to return memory for all entities created by functions of this library.

You can see it yourself, search for XkbRF_Free and XkbRf_getNamesProp in source code:
XKBrules.h
maprules.c

Also be attentive when functions allocates memory for other pointers ;-)

Maybe I will do next pull request to close this issue soon.

@sergei-mironov
Copy link
Owner Author

Good news, XkbRF_Free looks like a correct solution. Thank you for the information. I'll be happy to accept the PR.

@alexandersolovyov
Copy link
Contributor

I made a mistake here. XkbRF_Free is made only for XkbRF_RulesPtr, not for XkbRF_VarDefsPtr. The best decision for freeing XkbRF_VarDefsPtr is already applied.

@sergei-mironov
Copy link
Owner Author

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

No branches or pull requests

2 participants