Make memory management uniform: _everything_ now goes through the
[u/mdw/putty] / windlg.c
index a912df8..af430ec 100644 (file)
--- a/windlg.c
+++ b/windlg.c
@@ -66,7 +66,7 @@ static int CALLBACK LogProc (HWND hwnd, UINT msg,
                 int *selitems;
                 selcount = SendDlgItemMessage(hwnd, IDN_LIST,
                                               LB_GETSELCOUNT, 0, 0);
-                selitems = malloc(selcount * sizeof(int));
+                selitems = smalloc(selcount * sizeof(int));
                 if (selitems) {
                     int count = SendDlgItemMessage(hwnd, IDN_LIST,
                                                    LB_GETSELITEMS,
@@ -85,7 +85,7 @@ static int CALLBACK LogProc (HWND hwnd, UINT msg,
                     for (i = 0; i < count; i++)
                         size += strlen(events[selitems[i]]) + sizeof(sel_nl);
 
-                    clipdata = malloc(size);
+                    clipdata = smalloc(size);
                     if (clipdata) {
                         char *p = clipdata;
                         for (i = 0; i < count; i++) {
@@ -97,9 +97,9 @@ static int CALLBACK LogProc (HWND hwnd, UINT msg,
                             p += sizeof(sel_nl);
                         }
                         write_clip(clipdata, size, TRUE);
-                        free(clipdata);
+                        sfree(clipdata);
                     }
-                    free(selitems);
+                    sfree(selitems);
 
                     for (i = 0; i < nevents; i++)
                         SendDlgItemMessage(hwnd, IDN_LIST, LB_SETSEL,
@@ -326,6 +326,7 @@ enum { IDCX_ABOUT = IDC_ABOUT, IDCX_TVSTATIC, IDCX_TREEVIEW, controlstartvalue,
     IDC_AGENTFWD,
     IDC_CMDSTATIC,
     IDC_CMDEDIT,
+    IDC_COMPRESS,
     sshpanelend,
 
     selectionpanelstart,
@@ -486,6 +487,7 @@ static void init_dlg_ctrls(HWND hwnd) {
     SetDlgItemText (hwnd, IDC_TTEDIT, cfg.termtype);
     SetDlgItemText (hwnd, IDC_LOGEDIT, cfg.username);
     CheckDlgButton (hwnd, IDC_NOPTY, cfg.nopty);
+    CheckDlgButton (hwnd, IDC_COMPRESS, cfg.compression);
     CheckDlgButton (hwnd, IDC_BUGGYMAC, cfg.buggymac);
     CheckDlgButton (hwnd, IDC_AGENTFWD, cfg.agentfwd);
     CheckRadioButton (hwnd, IDC_CIPHER3DES, IDC_CIPHERDES,
@@ -631,7 +633,7 @@ static int GenericMainDlgProc (HWND hwnd, UINT msg,
            SendMessage(tvstatic, WM_SETFONT, font, MAKELPARAM(TRUE, 0));
 
             r.left = 3; r.right = r.left + 75;
-            r.top = 13; r.bottom = r.top + 196;
+            r.top = 13; r.bottom = r.top + 206;
             MapDialogRect(hwnd, &r);
             treeview = CreateWindowEx(WS_EX_CLIENTEDGE, WC_TREEVIEW, "",
                                       WS_CHILD | WS_VISIBLE |
@@ -972,6 +974,7 @@ static int GenericMainDlgProc (HWND hwnd, UINT msg,
                 beginbox(&cp, "Protocol options",
                          IDC_BOX_SSH3, IDC_BOXT_SSH3);
                checkbox(&cp, "Don't allocate a &pseudo-terminal", IDC_NOPTY);
+               checkbox(&cp, "Enable compr&ession", IDC_COMPRESS);
                radioline(&cp, "Preferred SSH protocol version:",
                          IDC_SSHPROTSTATIC, 2,
                          "&1", IDC_SSHPROT1, "&2", IDC_SSHPROT2, NULL);
@@ -1161,6 +1164,8 @@ static int GenericMainDlgProc (HWND hwnd, UINT msg,
                init_dlg_ctrls(hwnd);
                 if (!isdef)
                     SetDlgItemText(hwnd, IDC_SESSEDIT, sessions[n]);
+               else
+                    SetDlgItemText(hwnd, IDC_SESSEDIT, "");
            }
            if (LOWORD(wParam) == IDC_SESSLIST) {
                /*
@@ -1497,6 +1502,11 @@ static int GenericMainDlgProc (HWND hwnd, UINT msg,
                HIWORD(wParam) == BN_DOUBLECLICKED)
                cfg.nopty = IsDlgButtonChecked (hwnd, IDC_NOPTY);
            break;
+         case IDC_COMPRESS:
+           if (HIWORD(wParam) == BN_CLICKED ||
+               HIWORD(wParam) == BN_DOUBLECLICKED)
+               cfg.compression = IsDlgButtonChecked (hwnd, IDC_COMPRESS);
+           break;
          case IDC_BUGGYMAC:
            if (HIWORD(wParam) == BN_CLICKED ||
                HIWORD(wParam) == BN_DOUBLECLICKED)