r251 - trunk/code/botlib

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Thu Nov 3 17:26:59 EST 2005


Author: ludwig
Date: 2005-11-03 17:26:59 -0500 (Thu, 03 Nov 2005)
New Revision: 251

Modified:
   trunk/code/botlib/be_ai_chat.c
Log:
disable the alignment "fix" until its clear why it causes crashes


Modified: trunk/code/botlib/be_ai_chat.c
===================================================================
--- trunk/code/botlib/be_ai_chat.c	2005-11-03 19:42:58 UTC (rev 250)
+++ trunk/code/botlib/be_ai_chat.c	2005-11-03 22:26:59 UTC (rev 251)
@@ -20,6 +20,18 @@
 ===========================================================================
 */
 
+#if 0
+#define ALIGN(x) \
+	do { \
+		size_t oldx = x; \
+		x = (x+sizeof(void*)-1) & ~(sizeof(void*)-1L); \
+		if(x != oldx) \
+			botimport.Print(PRT_MESSAGE, "size %zd -> %zd\n", oldx, x); \
+	} while(0)
+#else
+#define ALIGN(x) 
+#endif
+
 /*****************************************************************************
  * name:		be_ai_chat.c
  *
@@ -689,7 +701,8 @@
 							FreeSource(source);
 							return NULL;
 						} //end if
-						len = (strlen(token.string) + 1 +sizeof(void*)-1) & ~(sizeof(void*)-1);
+						len = strlen(token.string) + 1;
+						ALIGN(len);
 						size += sizeof(bot_synonym_t) + len;
 						if (pass)
 						{
@@ -987,7 +1000,8 @@
 				FreeSource(source);
 				return NULL;
 			} //end if
-			len = (strlen(token.string) + 1 +sizeof(void*)-1) & ~(sizeof(void*)-1);
+			len = strlen(token.string) + 1;
+			ALIGN(len);
 			size += sizeof(bot_randomlist_t) + len;
 			if (pass)
 			{
@@ -1017,7 +1031,8 @@
 					FreeSource(source);
 					return NULL;
 				} //end if
-				len = (strlen(chatmessagestring) + 1 +sizeof(void*)-1) & ~(sizeof(void*)-1);
+				len = strlen(chatmessagestring) + 1;
+				ALIGN(len);
 				size += sizeof(bot_randomstring_t) + len;
 				if (pass)
 				{
@@ -2120,6 +2135,7 @@
 							} //end if
 							if (pass)
 							{
+								size_t len;
 								chatmessage = (bot_chatmessage_t *) ptr;
 								chatmessage->time = -2*CHATMESSAGE_RECENTTIME;
 								//put the chat message in the list
@@ -2129,7 +2145,9 @@
 								ptr += sizeof(bot_chatmessage_t);
 								chatmessage->chatmessage = ptr;
 								strcpy(chatmessage->chatmessage, chatmessagestring);
-								ptr += (strlen(chatmessagestring) + 1 +sizeof(void*)-1) & ~(sizeof(void*)-1);
+								len = strlen(chatmessagestring) + 1;
+								ALIGN(len);
+								ptr += len;
 								//the number of chat messages increased
 								chattype->numchatmessages++;
 							} //end if




More information about the quake3-commits mailing list