minor mailx-5.5 bugfix

David Mosberger-Tang (davidm@azstarnet.com)
Sat, 22 Jun 1996 21:17:00 -0700


Hi Ken,

Here is a tiny patch that avoids getting unaligned faults on
Linux/Alpha. Since pointers (and longs) are 64-bit large, salloc()
should return memory that is aligned at least to the size of a long.

--david

--
--- mailx/mailx-5.5/strings.c~	Fri Dec 17 00:13:00 1993
+++ mailx/mailx-5.5/strings.c	Sat Jun 22 21:11:26 1996
@@ -48,10 +48,11 @@
 
 /*
  * Allocate size more bytes of space and return the address of the
- * first byte to the caller.  An even number of bytes are always
- * allocated so that the space will always be on a word boundary.
- * The string spaces are of exponentially increasing size, to satisfy
- * the occasional user with enormous string size requests.
+ * first byte to the caller.  An size that is an integer multiple of a
+ * "long" is always allocated so that the space will always be on a
+ * word boundary.  The string spaces are of exponentially increasing
+ * size, to satisfy the occasional user with enormous string size
+ * requests.
  */
 
 char *
@@ -63,8 +64,8 @@
 	int index;
 
 	s = size;
-	s += 3;
-	s &= ~03;
+	s += sizeof(long) - 1;
+	s &= ~(sizeof(long) - 1);
 	index = 0;
 	for (sp = &stringdope[0]; sp < &stringdope[NSPACE]; sp++) {
 		if (sp->s_topFree == NOSTR && (STRINGSIZE << index) >= s)