Reputation: 283
I have a following code
bool isValidDisplay() {
if (!XOpenDisplay(NULL)) {
return false;
}
return true;
}
As I understand XOpenDisplay is allocating resources, what is correct way to free the resources in the above code .Does calling XCloseDisplay will solve the purpose.
Upvotes: 1
Views: 491
Reputation: 43269
Yes, calling XCloseDisplay frees the result of a successful XOpenDisplay.
I'm guessing this is what you want, to free resources immediately.
bool isValidDisplay() {
Display *d;
if (!(d = XOpenDisplay(NULL))) {
return false;
}
XCloseDisplay(d);
return true;
}
Source:
$ man XOpenDisplay
Upvotes: 2