From 628db36a7429391bab25aaaeb054445019e4d1f1 Mon Sep 17 00:00:00 2001 From: Michael Gernoth Date: Thu, 22 Jan 2004 20:31:59 +0000 Subject: [PATCH] fix g_null_pointer memleak fixes for compiles on NetBSD & FreeBSD git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/trunk/rdesktop@575 423420c4-83ab-492f-b58f-81f9feb106b5 --- disk.c | 2 +- rdpdr.c | 2 ++ xwin.c | 22 ++++++++++------------ 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/disk.c b/disk.c index abf07da..1478935 100644 --- a/disk.c +++ b/disk.c @@ -88,7 +88,7 @@ #define STATFS_T statvfs #define F_NAMELEN(buf) ((buf).f_namemax) -#elif defined(__OpenBSD__) +#elif (defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__)) #include #include #define STATFS_FN(path, buf) (statfs(path,buf)) diff --git a/rdpdr.c b/rdpdr.c index adb626e..02a1fcb 100644 --- a/rdpdr.c +++ b/rdpdr.c @@ -1,4 +1,6 @@ #include +#include +#include #include "rdesktop.h" #define IRP_MJ_CREATE 0x00 diff --git a/xwin.c b/xwin.c index ba4c25d..0d274c5 100644 --- a/xwin.c +++ b/xwin.c @@ -42,8 +42,7 @@ static int g_x_socket; static Screen *g_screen; Window g_wnd; BOOL g_enable_compose = False; -static GC g_gc; -static BOOL g_gc_initialized = False; +static GC g_gc = NULL; static Visual *g_visual; static int g_depth; static int g_bpp; @@ -51,7 +50,7 @@ static XIM g_IM; static XIC g_IC; static XModifierKeymap *g_mod_map; static Cursor g_current_cursor; -static HCURSOR g_null_cursor; +static HCURSOR g_null_cursor = NULL; static Atom g_protocol_atom, g_kill_atom; static BOOL g_focused; static BOOL g_mouse_in_wnd; @@ -64,8 +63,7 @@ static int g_red_shift_l, g_blue_shift_l, g_green_shift_l; /* software backing store */ static BOOL g_ownbackstore; -static Pixmap g_backstore; -static BOOL g_backstore_initialized = False; +static Pixmap g_backstore = NULL; /* Moving in single app mode */ static BOOL g_moving_wnd; @@ -851,6 +849,9 @@ ui_deinit(void) { if (g_IM != NULL) XCloseIM(g_IM); + + if (g_null_cursor != NULL) + ui_destroy_cursor(g_null_cursor); XFreeModifiermap(g_mod_map); @@ -888,13 +889,10 @@ ui_create_window(void) CWBackPixel | CWBackingStore | CWOverrideRedirect | CWColormap | CWBorderPixel, &attribs); - if ( ! g_gc_initialized ) - { + if (g_gc == NULL) g_gc = XCreateGC(g_display, g_wnd, 0, NULL); - g_gc_initialized = True; - } - if ((g_ownbackstore) && (! g_backstore_initialized)) + if ((g_ownbackstore) && (g_backstore == NULL)) { g_backstore = XCreatePixmap(g_display, g_wnd, g_width, g_height, @@ -903,7 +901,6 @@ ui_create_window(void) /* clear to prevent rubbish being exposed at startup */ XSetForeground(g_display, g_gc, BlackPixelOfScreen(g_screen)); XFillRectangle(g_display, g_backstore, g_gc, 0, 0, g_width, g_height); - g_backstore_initialized = True; } XStoreName(g_display, g_wnd, g_title); @@ -970,7 +967,8 @@ ui_create_window(void) XSetWMProtocols(g_display, g_wnd, &g_kill_atom, 1); /* create invisible 1x1 cursor to be used as null cursor */ - g_null_cursor = ui_create_cursor(0, 0, 1, 1, null_pointer_mask, null_pointer_data); + if (g_null_cursor == NULL) + g_null_cursor = ui_create_cursor(0, 0, 1, 1, null_pointer_mask, null_pointer_data); return True; }