Comments (7)
You might want to elaborate... but I do see where there might be an issue with the existing code, in the (rare!) case where someone calls delscreen(), and then exits, under X11. (If it's a different situation that you're encounternig, please tell me.)
from pdcurses.
I think he's trying to avoid a re-free. Better way to do this might be to replace
if (icon_pixmap)
XFreePixmap(XCURSESDISPLAY, icon_pixmap);
if (icon_pixmap_mask)
XFreePixmap(XCURSESDISPLAY, icon_pixmap_mask);
with
if (icon_pixmap)
{
XFreePixmap(XCURSESDISPLAY, icon_pixmap);
icon_pixmap = NULL;
}
if (icon_pixmap_mask)
{
XFreePixmap(XCURSESDISPLAY, icon_pixmap_mask);
icon_pixmap_mask = NULL;
}
...i.e., if you free something, set it to NULL so you won't try to free it again.
I vaguely recall running into such issues when using Valgrind to search for memory leaks. As I recall, I got some example code using the VT, WinGui, and I think one other flavor to free all the memory that had been allocated. I couldn't get the X11 flavor to close that cleanly, but didn't really try all that hard. ncurses left lots of memory allocated; apparently, that's a known, won't-fix problem.
The above double-free situation may seem like a 'rare' case. But I do have code that uses
endwin( );
getch( );
initscr( ); /* and further Curses initialization */
so that I can (in ncurses and the VT and WinCon flavors of PDCurses) temporarily show what was on the console before Curses or PDCurses were started.
from pdcurses.
Further to this I get a double free on exiting THE. This is because THE calls XCursesExit() explicitly (because that was the way you had to do it) which calls PDC_scr_free(), and now PDCurses calls PDC_scr_free() atexit the double free occurs.
XCursesExit() should do nothing now.
from pdcurses.
Mark, I've implemented the solution proposed above for my fork. Does this do the trick for you?
If delscreen(SP)
is called, Valgrind finds only one memory leak in the X11 version, from XtVaGetApplicationResources()
. I don't know enough about X to know what's going on there or what to do about it.
For SDL1 and SDL2, lots of memory is allocated and never freed. In theory, I can do similar testing for WinCon and WinGUI by running them under Wine through Valgrind, but thus far, I've been unable to get that to work. The VT port appears to be properly freeing everything it allocates.
from pdcurses.
Bill. The link you provide is not to the x11/pdcscrn.c. Besides I am not calling delscreen(), I am calling XCursesExit() only for the x11 build of THE.
from pdcurses.
(Groan) Sorry, here's the correct link. I kinda confused things by mentioning delscreen(SP)
and XtVaGetApplicationResources()
; those are both memory leak issues, not double-frees. The pdcscrn.c
for X11 that I've posted just addresses the double-free issue you describe, and does so with the common rubric
if( pointer != NULL) /* don't try freeing it again if it's already been */
{ /* freed, or was never alloced in the first place */
free( pointer);
pointer = NULL;
}
(repeated several times within my revised PDC_scr_free()
for each of the various quantities that that function is expected to free up.)
from pdcurses.
Hi Bill. Yes that works well for me. Thanks.
from pdcurses.
Related Issues (20)
- Is it normal that several styles don't work correctly in PowerShell? HOT 7
- Enabling support for showing window after process put to sleep (SDL2) HOT 4
- SDL_GetError() returns "Parameter 'src' is invalid" after call to initscr() for sdl2 HOT 2
- ncurses compat: add WACS_D_LRCORNER and other double line drawings
- SDL2 port missing support for PDC_PRESERVE_SCREEN HOT 4
- WinCon, endwin() kills QuickEdit/InsertMode options and more.. HOT 8
- touchoverlap() un-touches parts of lines HOT 1
- addition of vt port from Bill-Gray HOT 1
- additional gitpod config
- No rule to make target '../common/libobjs.mif'. Stop. HOT 5
- Unable to get mouse position when hovering HOT 9
- SDL2 build fails for Mac/Linux in Github HOT 2
- When resizing the SDL2 window, the surface isn't refreshed
- Build failure when building PDcurses DLL library for Window console HOT 1
- Debugging? HOT 1
- printw.c - for Unicode? HOT 3
- wresize doesn't return ERR if the window size requested is too big HOT 3
- Unable to initialize soft label keys HOT 2
- missing escapes in configure script HOT 1
- Scrolling and inserting/deleting lines
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pdcurses.