Skip to content

Commit 4a61218

Browse files
committed
'New' X11 port : found/worked around remaining X11 memory leaks. Updated docs for this port, and incremented version month/day.
1 parent 0a16083 commit 4a61218

4 files changed

Lines changed: 22 additions & 16 deletions

File tree

curses.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ Defined by this header:
4040
#define PDC_VER_MAJOR 4
4141
#define PDC_VER_MINOR 5
4242
#define PDC_VER_CHANGE 0
43-
#define PDC_VER_YEAR 2024
44-
#define PDC_VER_MONTH 12
45-
#define PDC_VER_DAY 31
43+
#define PDC_VER_YEAR 2025
44+
#define PDC_VER_MONTH 3
45+
#define PDC_VER_DAY 26
4646

4747
#define PDC_STRINGIZE( x) #x
4848
#define PDC_stringize( x) PDC_STRINGIZE( x)

x11new/README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
PDCurses for X11 (new, experimental)
2-
=====================================
1+
PDCursesMod for X11 (new, experimental)
2+
========================================
33

4-
This port of PDCurses for X11 has been written from scratch, with
4+
This port of PDCursesMod for X11 has been written from scratch, with
55
(thus far) only the key remapping array taken from pdckbd.c of the
66
"original" X11 port. It is, as yet, unclear if this will be a
77
replacement for the original port. As noted in the 'to do' section,
@@ -12,31 +12,31 @@ Building
1212
--------
1313

1414
- Run "make". Add UTF8=Y to force the wide-character version. Add
15-
DEBUG=Y for the debug version. Add the target "demos" to build
16-
the sample programs, and/or "tests" for the test programs.
15+
DEBUG=Y for the debug version. Add NO_LEAKS=Y to avoid Xlib's tendency
16+
to leak lots of memory (this does limit you to a US keyboard; see
17+
pdckbd.c.) Add the target "demos" to build the sample programs,
18+
and/or "tests" for the test programs.
1719

1820
- Currently, there is no "make install".
1921

2022
Usage
2123
-----
2224

2325
When compiling your application, you need to include the \<curses.h\>
24-
that comes with PDCurses. You also need to link your code with
26+
that comes with PDCursesMod. You also need to link your code with
2527
libXCurses. You will need to link with the following libraries:
2628

2729
-lX11 -lpthread
2830

2931
To do
3032
-----
3133

32-
- Add mouse handling
34+
- Add mouse wheel handling
3335
- Combining and fullwidth characters
3436
- How to do SMB (Unicode > 0xffff)?
35-
- Blinking text
3637
- Under/over/strikeout/left/right lines
3738
- Bold & italic text
3839
- Respond to Ctrl-plus and Ctrl-minus with font size changes?
39-
- Programmatic resizing?
4040

4141
Most of these shouldn't be all that tough to do.
4242

@@ -45,7 +45,7 @@ Interaction with stdio
4545

4646
Be aware that curses programs that expect to have a normal tty
4747
underneath them will be very disappointed! Output directed to stdout
48-
will go to the xterm that invoked the PDCurses application, or to the
48+
will go to the xterm that invoked the PDCursesMod application, or to the
4949
console if not invoked directly from an xterm. Similarly, stdin will
5050
expect its input from the same place as stdout.
5151

x11new/pdckbd.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -297,9 +297,9 @@ static struct
297297
attempt to clean up all allocations, this can be a significant problem; the
298298
memory you leak will be overwhelmed by hundreds of small allocations that
299299
Xlib neglects to free. Almost all of these allocations are in XIM (X Input
300-
Methods). Compile with -DNO_LEAKS, and XIM will not be used, and most
301-
of the memory will be correctly freed, making it _much_ easier to see any
302-
mistakes you've made.
300+
Methods), plus a couple in the font code (see pdcscrn.c). Compile with
301+
-DNO_LEAKS, and XIM will not be used, and memory should be correctly freed,
302+
making it _much_ easier to see any mistakes you've made.
303303
304304
Unfortunately, without XIM, some keyboard input will not be correctly
305305
translated, and a US keyboard is assumed. So this is for debugging only.

x11new/pdcscrn.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,12 @@ static Font _load_font( Display *dis, const char *font_name)
9595

9696
assert( xfont);
9797
XTextExtents( xfont, "A", 1, &direction, &font_ascent, &font_descent, &overall);
98+
#ifdef NO_LEAKS
99+
if( xfont->properties)
100+
free( xfont->properties); /* frees 368 bytes */
101+
if( xfont->per_char)
102+
free( xfont->per_char); /* frees 786,432 bytes */
103+
#endif
98104
XFreeFontInfo( NULL, xfont, 0);
99105
PDC_font_descent = font_descent;
100106
PDC_font_width = overall.width;

0 commit comments

Comments
 (0)