bug-ncurses
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: A Valgrind-observant ncurses


From: Bill Gray
Subject: Re: A Valgrind-observant ncurses
Date: Thu, 20 Jun 2024 15:08:38 -0400
User-agent: Mozilla Thunderbird

Hi Branden,

On 6/20/24 14:00, G. Branden Robinson wrote:
Right.  One approach I saw somewhere in X11 was to double the buffer
size once it was exceeded.  I seem to remember adding some code to
reallocate it smaller if usage fell to one-quarter of capacity.  (Not
half, because then you could have thrash if your callers, probably
unwittingly, bounced back and forth around your arbitrarily chosen
buffer size.)

Yes, I have such "buffer expansion" code routinely in my code. I usually don't bother much with the shrinkage, and am simply careful to clean up buffers when closing. But the logic you describe for shrinking is sometimes quite helpful.

I imagine many curses applications never call `printw()` at all.
Ones that try to stick rigidly to the wide API won't.

printw(3):

NOTES
      No wide character counterpart functions are defined by the “wide”
      ncurses configuration nor by any standard.  To format and write a
      wide‐character string to a curses window, consider using
      swprintf(3) and waddwstr(3NCURSES) or similar.

The idea of adding wide-character counterparts was proposed as an extension for PDCurses (not Mod)...

https://github.com/wmcbrine/PDCurses/issues/160

...and then shot down. William McBrine was unwilling to add them unless they were adopted by X/Open. (I didn't see a need for them in PDCursesMod, because they don't require access to curses internals. If used, those functions should be implemented outside the curses library, as sort of a "bolted on" addition. That way, you can use them with _any_ curses implementation, instead of just PDCurses or PDCursesMod or ncurses.)

-- Bill

Regards,
Branden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]