- s-nail-14_5_2-sort.patch
  <http://downloads.sourceforge.net/project/s-nail/s-nail-14_5_2-sort.patch>

  Reverses (sort(),thread(): use srelax()!, 2014-01-18, [a9b67e9]),
  which was a hasty commit of an untested diff that i've added few
  minutes beforehand:

    As a rather careless last-minute change i've added string relaxation
    to threaded and sorted display, but it's really one more step towards
    lowering memory pressure -- i couldn't resist [a9b67e9] after seeing

  An alternative, forward-heading patch that keeps string relaxation has
  been pushed to [master] as [5e75529] and is also available as
  s-nail-14_5_2-sort-alt.patch.

I'll attach both patches; git(1) users should update their [master].

Sorry, but hey, memory relaxation is pretty damn cool.  Especially
with large boxes.  (I must have been blinded.  Or whatever.)

--steffen
s-nail-14_5_2-sort-alt.patch, 2014-01-30:

Apply:
  $ cd s-nail-14.5.2
  $ patch -bu < s-nail-14_5_2-sort-alt.patch

Description:
An alternative working thesis for the bugfix s-nail-14_5_2-sort.patch
(2014-01-30).
It instead uses heap allocations, thus continues to relax the dope storage, and
has been pushed to [master].

diff --git a/thread.c b/thread.c
index 3ac5966..12af1fa 100644
--- a/thread.c
+++ b/thread.c
@@ -144,7 +144,7 @@ mlook(char *id, struct mitem *mt, struct message *mdata, int mprime)
 		mp = &mt[c];
 	}
 	if (mdata != NULL && mp->mi_id == NULL) {
-		mp->mi_id = id;
+		mp->mi_id = sstrdup(id);
 		mp->mi_data = mdata;
 		mdata->m_idhash = ~h;
 	}
@@ -395,6 +395,10 @@ makethreads(struct message *m, long cnt, int nmail)
 
 	threadroot = interlink(m, cnt, nmail);
 	finalize(threadroot);
+
+	for (i = 0; i < mprime; ++i)
+		if (mt[i].mi_id != NULL)
+			free(mt[i].mi_id);
 	free(mt);
 	mb.mb_threaded = 1;
 }
@@ -612,11 +616,11 @@ sort(void *vp)
 			case SORT_TO:
 				if ((cp = hfield1(method == SORT_FROM ?
 						"from" : "to", mp)) != NULL) {
-					ms[n].ms_u.ms_char = showname ?
-						realname(cp) : skin(cp);
+					ms[n].ms_u.ms_char = sstrdup(showname ?
+						realname(cp) : skin(cp));
 					makelow(ms[n].ms_u.ms_char);
 				} else
-					ms[n].ms_u.ms_char = UNCONST("");
+					ms[n].ms_u.ms_char = sstrdup("");
 				break;
 			default:
 			case SORT_SUBJECT:
@@ -624,12 +628,12 @@ sort(void *vp)
 					in.s = cp;
 					in.l = strlen(in.s);
 					mime_fromhdr(&in, &out, TD_ICONV);
-					ms[n].ms_u.ms_char =
-						savestr(skipre(out.s));
+					ms[n].ms_u.ms_char = sstrdup(
+							skipre(out.s));
 					free(out.s);
 					makelow(ms[n].ms_u.ms_char);
 				} else
-					ms[n].ms_u.ms_char = UNCONST("");
+					ms[n].ms_u.ms_char = sstrdup("");
 				break;
 			}
 			ms[n++].ms_n = i;
@@ -652,6 +656,17 @@ sort(void *vp)
 		threadroot = &message[0];
 	finalize(threadroot);
 	mb.mb_threaded = 2;
+
+	switch (method) {
+	case SORT_FROM:
+	case SORT_TO:
+	case SORT_SUBJECT:
+		for (i = 0; i < n; ++i)
+			free(ms[i].ms_u.ms_char);
+		/* FALLTHRU */
+	default:
+		break;
+	}
 	ac_free(ms);
 	return ((vp && vp != (void *)-1 && !inhook && ok_blook(header))
 		? headers(msgvec) : 0);
s-nail-14_5_2-sort.patch, 2014-01-30:

Apply:
  $ cd s-nail-14.5.2
  $ patch -bu < s-nail-14_5_2-sort.patch

Description:
Reverses (sort(),thread(): use srelax()!, 2014-01-18, [a9b67e9]), which
was a hasty commit of an untested diff that i've added few minutes
beforehand.
It was of course wrong.
The problem (no memory relaxation during entire sort operation) requires
a different approach (either only relax when we don't need to hold
dope storage (as for SORT_TO/SORT_FROM/SORT_SUBJECT/+) or use heap
memory for those allocations, then).

s-nail-14_5_2-sort-alt.patch is an alternative working thesis that uses
heap allocations, thus continues to relax the dope storage.
This version has been pushed to [master].

diff --git a/thread.c b/thread.c
index 3ac5966..9ec1ac9 100644
--- a/thread.c
+++ b/thread.c
@@ -361,8 +361,6 @@ makethreads(struct message *m, long cnt, int nmail)
 		return;
 	mprime = nextprime(cnt);
 	mt = scalloc(mprime, sizeof *mt);
-
-	srelax_hold();
 	for (i = 0; i < cnt; i++) {
 		if ((m[i].m_flag&MHIDDEN) == 0) {
 			mlook(NULL, mt, &m[i], mprime);
@@ -376,7 +374,6 @@ makethreads(struct message *m, long cnt, int nmail)
 		m[i].m_level = 0;
 		if (!nmail && !(inhook&2))
 			m[i].m_collapsed = 0;
-		srelax();
 	}
 	/*
 	 * Most folders contain the eldest messages first. Traversing
@@ -387,12 +384,8 @@ makethreads(struct message *m, long cnt, int nmail)
 	 * are replies to the one message, and are sorted such that
 	 * youngest messages occur first.
 	 */
-	for (i = cnt-1; i >= 0; i--) {
+	for (i = cnt-1; i >= 0; i--)
 		lookup(&m[i], mt, mprime);
-		srelax();
-	}
-	srelax_rele();
-
 	threadroot = interlink(m, cnt, nmail);
 	finalize(threadroot);
 	free(mt);
@@ -572,8 +565,6 @@ sort(void *vp)
 	default:
 		break;
 	}
-
-	srelax_hold();
 	for (n = 0, i = 0; i < msgCount; i++) {
 		mp = &message[i];
 		if ((mp->m_flag&MHIDDEN) == 0) {
@@ -637,10 +628,7 @@ sort(void *vp)
 		mp->m_child = mp->m_younger = mp->m_elder = mp->m_parent = NULL;
 		mp->m_level = 0;
 		mp->m_collapsed = 0;
-		srelax();
 	}
-	srelax_rele();
-
 	if (n > 0) {
 		qsort(ms, n, sizeof *ms, func);
 		threadroot = &message[ms[0].ms_n];
------------------------------------------------------------------------------
WatchGuard Dimension instantly turns raw network data into actionable 
security intelligence. It gives you real-time visual feedback on key
security issues and trends.  Skip the complicated setup - simply import
a virtual appliance and go from zero to informed in seconds.
http://pubads.g.doubleclick.net/gampad/clk?id=123612991&iu=/4140/ostg.clktrk
_______________________________________________
S-nail-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/s-nail-users

Reply via email to