[dev] [dwm] drw_scm_free() and drw_clr_free() in drw.h

0 views
Skip to first unread message

Listeria monocytogenes

unread,
Sep 26, 2025, 6:16:23 PMSep 26
to d...@suckless.org
The Xft(3) man page says:

> XftColorAllocName() and XftColorAllocValue() request a color allocation
> from the X server (if necessary) and initialize the members of XftColor.
> XftColorFree() instructs the X server to free the color currently allo‐
> cated for an XftColor.

drw_scm_create() calls drw_clr_create() which in turn calls
XftColorAllocName(), but instructs the user to call free(3) on the
returned color scheme, which is insufficient, as the color allocated by
XftColorAllocName() was not free'd.

I suggest adding the functions drw_clr_free(Drw *drw, Clr *clr) and
drw_scm_free(Drw *drw, Clr *scm, size_t clrcount) to properly free the
allocated color and scheme.

Hiltjo Posthuma

unread,
Sep 27, 2025, 6:16:59 AMSep 27
to dev mail list
Hi,

Thanks for the feedback.

I've pushed patches to dwm and dmenu.

Please test them.

--
Kind regards,
Hiltjo

Listeria monocytogenes

unread,
Sep 28, 2025, 2:53:32 PMSep 28
to dev mail list
On Sat Sep 27, 2025 at 10:16 AM UTC, Hiltjo Posthuma wrote:
> Hi,
>
> Thanks for the feedback.
>
> I've pushed patches to dwm and dmenu.

Hi,

Thanks for the quick reply.

Given that drw_scm_create() is the one making the allocation, I would
consider having drw_scm_free() call free(3), as I don't see a case for
keeping the allocated buffer.

> Please test them.

Will do.

Hiltjo Posthuma

unread,
Sep 29, 2025, 12:51:14 PMSep 29
to dev mail list
Yeah that makes sense. I've pushed patches to dmenu, dwm and libsl again to
change this.

Thanks,

--
Kind regards,
Hiltjo

Reply all
Reply to author
Forward
0 new messages