[dev] Re: [dmenu] [patch] add xft and fix possible memory leak in version 4.2.1

From: Dan Brown <danbrown_AT_gmail.com>
Date: Sun, 21 Nov 2010 09:18:55 -0800

Hello. Continuing the discussion ...

Connor Lane Smith <cls_AT_lubutu.com> wrote:
> Anselm R Garbe <garbeam_AT_gmail.com> wrote:
>> Well for clarity and consistency reasons I prefer if dmenu cleans up
>> all resources acquired at the end. So that cleanup() was removes looks
>> more like a bug to me and thanks to Dan for pointing this out.
>It was intentional. It is not even possible for there to be a memory
>leak, so all we get is a slower dmenu with more complex code, with
>absolutely no benefit. The more items there are the slower it gets,
>and most of the heap doesn't get freed until exit anyway. cleanup() is
>like sweeping the floor for the apocalypse.
That makes sense. Actually, both approaches make sense to me. I will
leave it up to you to decide which way to go.

>On 21 November 2010 03:56, Dan Brown <danbrown_AT_gmail.com> wrote:
>> 1) Attached is a patch that enables xft fonts in dmenu 4.2.1.
>There has been a discussion about Xft fonts in dmenu before [1]. I
>haven't come to a decision myself. Is there really not a way to add
>Xft support without making huge changes to the code to compensate?
...
>[1]: http://lists.suckless.org/dev/1009/5855.html
This was the patch I used as an starting point for adding xft support.
After studying it, I came up with a few ways to simplify it that I
think you'll appreciate. In particular, I wanted to work within with
the existing DC data structure, rather than bolting on whole new
fields with different approaches. The patch I sent adds only 2 fields
to DC (compared to the patch you reference, which adds 7 or 8 to DC,
along with one global variable and a few function variables). The
other data change in this patch deals with colors, to allow different
data types to be grouped in one place (xft colors and regular x colors
are different data types). By harmonizing the data structures, the
code becomes much simpler. This made it easy to remove all references
to xft from dmenu.c and even made the draw.c code simpler, too. These
simplifying improvements may have been obscured by the presence of
other code changes in the patch. (and yes, the token matching is taken
verbatim from http://tools.suckless.org/dmenu/patches/dmenu-tip-tok.diff)

>Also when I applied your patch and tried to run 'dmenu -fn fixed' I
>instead got some sans-serif font..?
This has been fixed in the attached patch. For some reason, the xft
font name lookup is very aggressive, and seems to match even bogus
strings to the default xft font. To deal with this behavior, the code
will attempt to match xft fonts as a last resort after trying to find
regular x fonts and fontsets first. Not ideal, but I couldn't see how
to tell the xft font lookup function to be more picky.

Dan

Received on Sun Nov 21 2010 - 18:18:55 CET

This archive was generated by hypermail 2.2.0 : Sun Nov 21 2010 - 18:24:02 CET