--- rxvt-unicode/src/rxvttoolkit.C 2010/01/24 21:53:13 1.104 +++ rxvt-unicode/src/rxvttoolkit.C 2010/12/30 00:35:29 1.112 @@ -35,7 +35,7 @@ # include #endif -const char *const xa_names[] = +static const char *const xa_names[] = { "TEXT", "COMPOUND_TEXT", @@ -364,14 +364,14 @@ (unsigned char **)&val) == Success && actual_type == XA_STRING && actual_format == 8) - displayResource = val; - else - { - displayResource = 0; - - if (val) - XFree(val); - } + displayResource = val; + else + { + displayResource = 0; + + if (val) + XFree (val); + } #if XLIB_ILLEGAL_ACCESS dpy->xdefaults = displayResource; @@ -429,11 +429,11 @@ #ifdef LOCAL_X_IS_UNIX if (id[0] == ':') { - val = rxvt_malloc (5 + strlen (id) + 1); + if (!(val = rxvt_temp_buf (5 + strlen (id) + 1))) + return false; strcpy (val, "unix/"); strcat (val, id); dpy = XOpenDisplay (val); - free (val); } else #endif @@ -448,7 +448,7 @@ screen = DefaultScreen (dpy); root = DefaultRootWindow (dpy); - assert (sizeof (xa_names) / sizeof (char *) == NUM_XA); + assert (ARRAY_LENGTH(xa_names) == NUM_XA); XInternAtoms (dpy, (char **)xa_names, NUM_XA, False, xa); XrmSetDatabase (dpy, get_resources (false)); @@ -466,7 +466,7 @@ int fd = XConnectionNumber (dpy); - // try to detect wether we have a local connection. + // try to detect whether we have a local connection. // assume unix domain socket == local, everything else not // TODO: might want to check for inet/127.0.0.1 is_local = 0; @@ -490,7 +490,7 @@ void rxvt_display::ref_next () { - // TODO: somehow check wether the database files/resources changed + // TODO: somehow check whether the database files/resources changed // before affording re-loading/parsing XrmDestroyDatabase (XrmGetDatabase (dpy)); XrmSetDatabase (dpy, get_resources (true)); @@ -509,6 +509,7 @@ #ifdef USE_XIM xims.clear (); #endif + XrmDestroyDatabase (XrmGetDatabase (dpy)); XCloseDisplay (dpy); } @@ -530,10 +531,10 @@ if (XGetWindowProperty (dpy, root, xa[XA_XIM_SERVERS], 0L, 1000000L, False, XA_ATOM, &actual_type, &actual_format, &nitems, &bytes_after, (unsigned char **)&atoms) - != Success ) + != Success) return; - if (actual_type == XA_ATOM && actual_format == 32) + if (actual_type == XA_ATOM && actual_format == 32) for (int i = 0; i < nitems; i++) if (XGetSelectionOwner (dpy, atoms[i])) { @@ -609,8 +610,9 @@ if (cur_owner && cur_owner != owner) { - cur_owner->selection_clear (clipboard); - cur_owner->flush (); + rxvt_term *term = cur_owner; + term->selection_clear (clipboard); + term->flush (); } cur_owner = owner; @@ -636,7 +638,7 @@ l = strlen (locale); m = strlen (modifiers); - if (!(id = (char *)malloc (l + m + 2))) + if (!(id = rxvt_temp_buf (l + m + 2))) return 0; memcpy (id, locale, l); id[l] = '\n'; @@ -644,8 +646,6 @@ rxvt_xim *xim = xims.get (id); - free (id); - return xim; } @@ -887,19 +887,3 @@ ); } -#if TRACE_PIXMAPS -# undef XCreatePixmap -# undef XFreePixmap -Pixmap trace_XCreatePixmap (const char *file, int line, Display *dpy, Window r, unsigned int w, unsigned int h, unsigned int d) -{ - Pixmap res = XCreatePixmap (dpy, r, w, h, d); - fprintf (stderr, "%s:%d: XCreatePixmap (%p,%lX,%u,%u,%u) returned %lX\n", file, line, dpy, r, w, h, d, res); - return res; -} - -void trace_XFreePixmap (const char *file, int line, Display *dpy, Pixmap p) -{ - fprintf (stderr, "%s:%d: XFreePixmap (%p,%lX)\n", file, line, dpy, p); - XFreePixmap (dpy,p); -} -#endif