*** empty log message ***
authorpcg <pcg>
Fri, 13 Feb 2004 13:28:17 +0000 (13:28 +0000)
committerpcg <pcg>
Fri, 13 Feb 2004 13:28:17 +0000 (13:28 +0000)
Changes
src/defaultfont.C
src/defaultfont.h
src/init.C
src/main.C
src/rxvt.h
src/rxvtd.C

diff --git a/Changes b/Changes
index 5848e2297e89bda82f4f204aa32a5334cd893800..54c1ac441d2a2a54a036aa2da5ff58a684ede331 100644 (file)
--- a/Changes
+++ b/Changes
@@ -8,7 +8,7 @@
           crashes when you kill your input method (xterm crashes, too).
         - fix bugs in x flushing, causing an empty screen after startup
           the first until the first event arives.
-        - fix ~15kb memleak per term in rxvtd.
+        - fix various memleaks in rxvtd.
 
 1.8  Mon Feb  2 20:09:18 CET 2004
        - almost total conversion to C++. Except for introducing
index 6835eb91e11c3dc09ab93c386632028ede9f03c9..09d8e2883be8a8291b325ec01cbe115ec05a3c6c 100644 (file)
@@ -430,7 +430,7 @@ rxvt_font_x11::set_properties (rxvt_fontprop &p, const char *name)
 
   if (f)
     {
-      // the font should really exists now. if not, we have a problem
+      // the font should really exist now. if not, we have a problem
       // (e.g. if the user did xset fp rehash just when we were searching fonts).
       // in that case, just return garbage.
       bool ret = set_properties (p, f);
index 5e14c7686d80ccbec84d4b9f6b270bdb85d27c08..c6e917acd7391b72ca6a72ad336af2bb2fa7e8b6 100644 (file)
@@ -49,7 +49,7 @@ struct rxvt_font {
   }
 
   rxvt_font () { name = 0; }
-  ~rxvt_font () { clear (); free (name); };
+  ~rxvt_font () { free (name); };
 
   void clear_rect (int x, int y, int w, int h, int color);
 
@@ -65,9 +65,7 @@ struct rxvt_font {
                      int fg, int bg) = 0;
 };
 
-//#define FONT_REF(obj) (obj)->refcnt++
-//#define FONT_UNREF(obj) if (!--(obj)->refcnt) delete (obj)
-#define FONT_UNREF(f) delete f
+#define FONT_UNREF(f) do { (f)->clear (); delete (f); } while (0)
 
 struct rxvt_fallback_font;
 
index e7b68c477a112ed46bba7094e327ae930a580c47..42617590dc14b4b9d4bf1140025fa3b40c4a93aa 100644 (file)
@@ -764,9 +764,12 @@ rxvt_term::init_env ()
    * @ COLORTERM: terminal sub-name and also indicates its color
    * @ TERM:      terminal name
    * @ TERMINFO:  path to terminfo directory
+   * @ COLORFGBG: fg;bg color codes
    */
   putenv (env_display);
   putenv (env_windowid);
+  if (env_colorfgbg)
+    putenv (env_colorfgbg);
 
 #ifdef RXVT_TERMINFO
   putenv ("TERMINFO=" RXVT_TERMINFO);
@@ -1363,6 +1366,8 @@ rxvt_term::run_command (const char *const *argv)
       case 0:
         close (cfd);             /* only keep tty_fd and STDERR open */
 
+        init_env ();
+
         if (rxvt_control_tty (tty_fd, ttydev) < 0)
           rxvt_print_error ("could not obtain control of tty");
         else
index e771aba2a73035ece3726c4b95c05b23690387ae..c3c7e87d47938b6bca92c701a6c608276aa3f8a3 100644 (file)
@@ -110,6 +110,10 @@ rxvt_term::~rxvt_term ()
 
   scr_release ();
 
+  free (env_windowid);
+  free (env_display);
+  free (env_term);
+  free (env_colorfgbg);
   free (locale);
   free (codeset);
 
@@ -126,6 +130,9 @@ rxvt_term::~rxvt_term ()
   delete TermWin.fontset;
 
   displays.put (display);
+
+  delete envv;
+  delete argv;
 }
 
 void
@@ -286,7 +293,6 @@ rxvt_term::init (int argc, const char *const *argv)
   XMapWindow (display->display, TermWin.vt);
   XMapWindow (display->display, TermWin.parent[0]);
 
-  init_env ();
   init_command (cmd_argv);
 
   pty_ev.start (cmd_fd, EVENT_READ);
@@ -875,8 +881,8 @@ rxvt_term::set_colorfgbg ()
 #endif
         break;
       }
+
   sprintf (env_colorfgbg, "COLORFGBG=%s;%s%s", fstr, xpmb, bstr);
-  putenv (env_colorfgbg);
 
 #ifndef NO_BRIGHTCOLOR
   colorfgbg = DEFAULT_RSTYLE;
index 4d8b39c15d255033922a3f074c316388b6d62253..51a4e745bab9426176f39f30063967de2173fe07 100644 (file)
@@ -1059,6 +1059,7 @@ struct rxvt_term : rxvt_vars {
   unsigned char  *v_buffer;   /* pointer to physical buffer */
   unsigned int    v_buflen;   /* size of area to write */
   char           *newfont[MAX_NFONTS];
+  stringvec      *argv, *envv;       /* if != 0, will be freed on destroy time */
 #ifdef KEYSYM_RESOURCE
   const unsigned char *Keysym_map[256];
 #endif
index 66a14ae8a90dcbbeca96d1d93fe8ab3b12c3591a..4be63aefe8854874de7582421dad67167da09042 100644 (file)
@@ -1,4 +1,5 @@
-#include "rxvtlib.h"
+#include "../config.h"
+#include "rxvt.h"
 #include "rxvtdaemon.h"
 #include "iom.h"
 
@@ -107,8 +108,8 @@ void server::read_cb (io_watcher &w, short revents)
     {
       if (!strcmp (tok, "NEW"))
         {
-          stringvec argv;
-          stringvec envv;
+          stringvec *argv = new stringvec;
+          stringvec *envv = new stringvec;
             
           for (;;)
             {
@@ -118,7 +119,7 @@ void server::read_cb (io_watcher &w, short revents)
               if (!strcmp (tok, "END"))
                 break;
               else if (!strcmp (tok, "ENV") && recv (tok))
-                envv.push_back (tok.get ());
+                envv->push_back (tok.get ());
               else if (!strcmp (tok, "CWD") && recv (tok))
                 {
                   if (chdir (tok))
@@ -126,21 +127,23 @@ void server::read_cb (io_watcher &w, short revents)
                          (char *)tok, strerror (errno));
                 }
               else if (!strcmp (tok, "ARG") && recv (tok))
-                argv.push_back (tok.get ());
+                argv->push_back (tok.get ());
               else
                 return err ("protocol error: unexpected NEW token");
             }
 
-          envv.push_back (0);
+          envv->push_back (0);
 
           {
             char **old_environ = environ;
-            environ = envv.begin ();
+            environ = envv->begin ();
 
-            rxvt_init (argv.size (), argv.begin ());
+            rxvt_term *term = rxvt_init (argv->size (), argv->begin ());
+
+            term->argv = argv;
+            term->envv = envv;
 
             environ = old_environ;
-            envv.clear (); // can't yet save the env 'cause rxvt modifies it : (
           }
         }
       else