[links-list] [PATCH] Write bookmarks only when modified

Fabio Bonelli fabiobonelli at libero.it
Mon May 13 11:37:52 PDT 2002


Little patch.

-- 
Fabio Bonelli <fabiobonelli at libero.it>
gpg fingerprint: 61E6 5442 3BDF EA0E 2D10  35A6 971B 77D1 DA7F 0F59
-------------- next part --------------
--- elinks-orig/src/bookmarks/bookmarks.c	Mon May 13 20:14:19 2002
+++ elinks/src/bookmarks/bookmarks.c	Mon May 13 20:29:34 2002
@@ -28,6 +28,8 @@
 unsigned char *bm_last_searched_name = NULL;
 unsigned char *bm_last_searched_url = NULL;
 
+short bookmarks_dirty = 0;
+
 
 #ifdef BOOKMARKS
 
@@ -58,6 +60,7 @@
 	if (!bm) return 0;
 
 	del_from_list(bm);
+	bookmarks_dirty = 1;
 
 	/* Now wipe the bookmark */
 	mem_free(bm->title);
@@ -94,6 +97,7 @@
 
 	/* Actually add it */
 	add_to_list(bookmarks, bm);
+	bookmarks_dirty = 1;
 }
 
 /* Updates an existing bookmark.
@@ -121,6 +125,7 @@
 		mem_free(bm->url);
 		bm->url = stracpy((unsigned char *)url);
 	}
+	bookmarks_dirty = 1;
 
 	return 1;
 }
@@ -228,6 +233,7 @@
 		add_bookmark(title, url);
 	}
 
+	bookmarks_dirty = 0;
 	fclose(f);
 #undef INBUF_SIZE
 }
@@ -284,7 +290,7 @@
 void
 finalize_bookmarks()
 {
-	write_bookmarks();
+	if (bookmarks_dirty) write_bookmarks();
 	free_bookmarks();
 	if (bm_last_searched_name) mem_free(bm_last_searched_name);
 	if (bm_last_searched_url) mem_free(bm_last_searched_url);


More information about the links-list mailing list