1
0
Fork 0
mirror of https://github.com/polybar/polybar.git synced 2024-11-03 04:33:30 -05:00

fix: Memory leak

This commit is contained in:
Michael Carlberg 2016-11-19 04:06:05 +01:00
parent 51d8f289fa
commit ab5666a7ea
3 changed files with 19 additions and 15 deletions

View file

@ -13,17 +13,18 @@ namespace bspwm_util {
auto children = conn.query_tree(conn.screen()->root).children();
for (auto it = children.begin(); it != children.end(); it++) {
auto cookie = xcb_icccm_get_wm_class(conn, *it);
xcb_icccm_get_wm_class_reply_t reply;
reply.class_name = reply.instance_name = nullptr;
if (xcb_icccm_get_wm_class_reply(conn, cookie, &reply, nullptr) == 0)
continue;
if (xcb_icccm_get_wm_class_reply(conn, xcb_icccm_get_wm_class(conn, *it), &reply, nullptr)) {
if (string_util::compare("Bspwm", reply.class_name) && string_util::compare("root", reply.instance_name)) {
roots.emplace_back(*it);
}
}
if (!string_util::compare("Bspwm", reply.class_name) ||
!string_util::compare("root", reply.instance_name))
continue;
roots.emplace_back(*it);
if (reply.class_name != nullptr || reply.instance_name != nullptr) {
xcb_icccm_get_wm_class_reply_wipe(&reply);
}
}
return roots;

View file

@ -19,16 +19,18 @@ namespace i3_util {
auto children = conn.query_tree(conn.screen()->root).children();
for (auto it = children.begin(); it != children.end(); it++) {
auto cookie = xcb_icccm_get_wm_name(conn, *it);
xcb_icccm_get_text_property_reply_t reply;
reply.name = nullptr;
if (xcb_icccm_get_wm_name_reply(conn, cookie, &reply, nullptr) == 0)
continue;
if (xcb_icccm_get_wm_name_reply(conn, xcb_icccm_get_wm_name(conn, *it), &reply, nullptr)) {
if (("[i3 con] output " + output_name).compare(0, 16 + output_name.length(), reply.name) == 0) {
roots.emplace_back(*it);
}
}
if (("[i3 con] output " + output_name).compare(0, 16 + output_name.length(), reply.name) != 0)
continue;
roots.emplace_back(*it);
if (reply.name != nullptr) {
xcb_icccm_get_text_property_reply_wipe(&reply);
}
}
return roots;

View file

@ -3,6 +3,7 @@
#include "x11/connection.hpp"
LEMONBUDDY_NS
/**
* Preload required xcb atoms
*/