Open sergei-mironov opened 5 years ago
Status:
Note meaningful comment by @szaszm https://github.com/ierton/xkb-switch/pull/30#issuecomment-493545416
Actually, all needed functions are already there. It can be done in two ways:
XkbRf_getNamesProp()
can receive XkbRF_VarDefsPtr
instead of reference toXkbRF_VarDefsRec
. Then, memory must be cleared with XkbRF_Free(vdr, True)
.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.
Good news, XkbRF_Free
looks like a correct solution. Thank you for the information. I'll be happy to accept the PR.
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.
OK. Related sources for reference is here https://github.com/mattl/opensource.apple.com/blob/master/src/X11libs/X11libs-60.2/libxkbfile/libxkbfile-1.0.7/include/X11/extensions/XKBrules.h#L170
Ref https://github.com/ierton/xkb-switch/pull/30