Two patches for CVS



Hi,

-- 
Regards,
Andrew V. Samoilov.
vfs/ChangeLog:

	* undelfs.c (undelfs_open): Use g_try_malloc() instead
	of g_malloc().

	* smbfs.c (smbfs_send): Don't account negative "ret".

--- undelfs.c.b	Mon Sep 27 09:29:52 2004
+++ undelfs.c	Thu Oct 14 13:49:50 2004
@@ -423,13 +423,13 @@ undelfs_open (struct vfs_class *me, cons
 	    continue;
 
 	/* Found: setup all the structures needed by read */
-	p = g_new (undelfs_file, 1);
+	p = (undelfs_file *) g_try_malloc (((gsize) sizeof (undelfs_file)));
 	if (!p) {
 	    g_free (file);
 	    g_free (f);
 	    return 0;
 	}
-	p->buf = g_malloc (fs->blocksize);
+	p->buf = g_try_malloc (fs->blocksize);
 	if (!p->buf) {
 	    g_free (p);
 	    g_free (file);
--- smbfs.c.b	Wed Sep 29 09:20:22 2004
+++ smbfs.c	Thu Oct 14 13:52:42 2004
@@ -602,9 +602,11 @@ smbfs_send(struct cli_state *cli)
 
 	while (nwritten < len) {
 		ret = write_socket(cli->fd, cli->outbuf+nwritten, len - nwritten);
-		if (ret <= 0 && errno == EPIPE)
+		if (ret <= 0) {
+		    if (errno == EPIPE)
 			return False;
-		nwritten += ret;
+		} else
+		    nwritten += ret;
 	}
 	
 	return True;
src/ChangeLog:

	* hotlist.c (add_new_entry_cmd): Fix memory leaks.

--- hotlist.c~	Fri Oct 15 19:30:18 2004
+++ hotlist.c	Fri Oct 15 19:31:30 2004
@@ -822,7 +822,7 @@ static void add_widgets_i18n(QuickWidget
 
 static int
 add_new_entry_input (const char *header, const char *text1, const char *text2,
-		    const char *help, char **r1, char **r2)
+		     const char *help, char **r1, char **r2)
 {
 #define RELATIVE_Y_BUTTONS	4
 #define RELATIVE_Y_LABEL_PTH	3
@@ -892,8 +892,8 @@ add_new_entry_input (const char *header,
     
     Quick_input.widgets = quick_widgets;
     if ((i = quick_dialog (&Quick_input)) != B_CANCEL){
-	 *r1 = *(quick_widgets [5].str_result);
-	 *r2 = *(quick_widgets [3].str_result);
+	 *r1 = my_str1;
+	 *r2 = my_str2;
 	 return i;
     } else
 	 return 0;
@@ -901,22 +901,22 @@ add_new_entry_input (const char *header,
 
 static void add_new_entry_cmd (void)
 {
-    char *title = 0, *url = 0;
+    char *title, *url;
     int ret;
 
     /* Take current directory as default value for input fields */
     title = url = current_panel->cwd;
 
-    ret = add_new_entry_input (_("New hotlist entry"), _("Directory label"), _("Directory path"),
-	 "[Hotlist]", &title, &url);
+    ret = add_new_entry_input (_("New hotlist entry"), _("Directory label"),
+			       _("Directory path"), "[Hotlist]", &title, &url);
 
     if (!ret || !title || !*title || !url || !*url)
 	return;
 
     if (ret == B_ENTER || ret == B_APPEND)
-	add2hotlist (g_strdup (title),g_strdup (url), HL_TYPE_ENTRY, 2);
+	add2hotlist (title, url, HL_TYPE_ENTRY, 2);
     else
-	add2hotlist (g_strdup (title),g_strdup (url), HL_TYPE_ENTRY, 1);
+	add2hotlist (title, url, HL_TYPE_ENTRY, 1);
 
     hotlist_state.modified = 1;
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]