|
|
 |
 |
 |
 |
|
 |
 |
|
 |
 |
|
 |
|
 |
|
 |

06-22-2009, 03:01 PM
|
Developer
|
|
Join Date: Apr 2009
Location: USA
Posts: 478
|
|
KLS, try this patch for va_lists under windows. It defines va_copy if it is not already defined.
Code:
Index: common/MiscFunctions.cpp
===================================================================
--- common/MiscFunctions.cpp (revision 702)
+++ common/MiscFunctions.cpp (working copy)
@@ -59,6 +59,10 @@
#include <errno.h>
#endif
+#ifndef va_copy
+ #define va_copy(d,s) ((d) = (s))
+#endif
+
void CoutTimestamp(bool ms) {
time_t rawtime;
struct tm* gmt_t;
@@ -147,7 +151,7 @@
int MakeAnyLenString(char** ret, const char* format, ...) {
int buf_len = 128;
int chars = -1;
- va_list argptr;
+ va_list argptr, tmpargptr;
va_start(argptr, format);
while (chars == -1 || chars >= buf_len) {
safe_delete_array(*ret);
@@ -156,7 +160,8 @@
else
buf_len = chars + 1;
*ret = new char[buf_len];
- chars = vsnprintf(*ret, buf_len, format, argptr);
+ va_copy(tmpargptr, argptr);
+ chars = vsnprintf(*ret, buf_len, format, tmpargptr);
}
va_end(argptr);
return chars;
@@ -169,7 +174,7 @@
*strlen = 0;
int chars = -1;
char* oldret = 0;
- va_list argptr;
+ va_list argptr, tmpargptr;
va_start(argptr, format);
while (chars == -1 || chars >= (sint32)(*bufsize-*strlen)) {
if (chars == -1)
@@ -183,7 +188,8 @@
memcpy(*ret, oldret, *strlen);
safe_delete_array(oldret);
}
- chars = vsnprintf(&(*ret)[*strlen], (*bufsize-*strlen), format, argptr);
+ va_copy(tmpargptr, argptr);
+ chars = vsnprintf(&(*ret)[*strlen], (*bufsize-*strlen), format, tmpargptr);
}
va_end(argptr);
*strlen += chars;
Index: common/debug.cpp
===================================================================
--- common/debug.cpp (revision 702)
+++ common/debug.cpp (working copy)
@@ -20,6 +20,10 @@
#endif
#include "../common/MiscFunctions.h"
+#ifndef va_copy
+ #define va_copy(d,s) ((d) = (s))
+#endif
+
static volatile bool logFileValid = false;
static EQEMuLog realLogFile;
EQEMuLog *LogFile = &realLogFile;
@@ -144,13 +148,16 @@
fprintf(fp[id], "%04i [%02d.%02d. - %02d:%02d:%02d] ", getpid(), newtime->tm_mon+1, newtime->tm_mday, newtime->tm_hour, newtime->tm_min, newtime->tm_sec);
#endif
- va_list argptr;
+ va_list argptr, tmpargptr;
va_start(argptr, fmt);
- if (dofile)
- vfprintf( fp[id], fmt, argptr );
+ if (dofile) {
+ va_copy(tmpargptr, argptr);
+ vfprintf( fp[id], fmt, tmpargptr );
+ }
if(logCallbackFmt[id]) {
msgCallbackFmt p = logCallbackFmt[id];
- p(id, fmt, argptr );
+ va_copy(tmpargptr, argptr);
+ p(id, fmt, tmpargptr );
}
if (pLogStatus[id] & 2) {
if (pLogStatus[id] & 8) {
@@ -204,17 +211,21 @@
time( &aclock ); /* Get time in seconds */
newtime = localtime( &aclock ); /* Convert time to struct */
+ va_list tmpargptr;
+
if (dofile) {
#ifndef NO_PIDLOG
fprintf(fp[id], "[%02d.%02d. - %02d:%02d:%02d] %s", newtime->tm_mon+1, newtime->tm_mday, newtime->tm_hour, newtime->tm_min, newtime->tm_sec, prefix);
#else
fprintf(fp[id], "%04i [%02d.%02d. - %02d:%02d:%02d] %s", getpid(), newtime->tm_mon+1, newtime->tm_mday, newtime->tm_hour, newtime->tm_min, newtime->tm_sec, prefix);
#endif
- vfprintf( fp[id], fmt, argptr );
+ va_copy(tmpargptr, argptr);
+ vfprintf( fp[id], fmt, tmpargptr );
}
if(logCallbackPva[id]) {
msgCallbackPva p = logCallbackPva[id];
- p(id, prefix, fmt, argptr );
+ va_copy(tmpargptr, argptr);
+ p(id, prefix, fmt, tmpargptr );
}
if (pLogStatus[id] & 2) {
if (pLogStatus[id] & 8) {
@@ -295,10 +306,12 @@
}
bool EQEMuLog::writeNTS(LogIDs id, bool dofile, const char *fmt, ...) {
- va_list argptr;
+ va_list argptr, tmpargptr;
va_start(argptr, fmt);
- if (dofile)
- vfprintf( fp[id], fmt, argptr );
+ if (dofile) {
+ va_copy(tmpargptr, argptr);
+ vfprintf( fp[id], fmt, tmpargptr );
+ }
if (pLogStatus[id] & 2) {
if (pLogStatus[id] & 8)
vfprintf( stderr, fmt, argptr );
|
 |
|
 |

06-23-2009, 03:59 AM
|
Developer
|
|
Join Date: Apr 2009
Location: USA
Posts: 478
|
|
Somehow a uint16 in the patch was changed to a uint32 in the SVN. The following patch fixes this:
Code:
Index: zone/map.h
===================================================================
--- zone/map.h (revision 706)
+++ zone/map.h (working copy)
@@ -96,7 +96,7 @@
uint8 flags;
union {
- uint32 nodes[4]; //index 0 means NULL, not root
+ uint16 nodes[4]; //index 0 means NULL, not root
struct {
uint32 count;
uint32 offset;
|
 |
|
 |

06-23-2009, 12:11 PM
|
Developer
|
|
Join Date: Apr 2009
Location: USA
Posts: 478
|
|
If the va_list patch is what is causing the zone.exe crashes under windows, this patch should avoid the problem by using #ifndef WIN32 blocks. This patch should be applied against rev706 or later.
Code:
Index: common/MiscFunctions.cpp
===================================================================
--- common/MiscFunctions.cpp (revision 707)
+++ common/MiscFunctions.cpp (working copy)
@@ -59,10 +59,6 @@
#include <errno.h>
#endif
-#ifndef va_copy
- #define va_copy(d,s) ((d) = (s))
-#endif
-
void CoutTimestamp(bool ms) {
time_t rawtime;
struct tm* gmt_t;
@@ -151,8 +147,12 @@
int MakeAnyLenString(char** ret, const char* format, ...) {
int buf_len = 128;
int chars = -1;
- va_list argptr, tmpargptr;
+ va_list argptr;
va_start(argptr, format);
+#ifndef WIN32
+ va_list tmpargptr;
+ va_copy(tmpargptr, argptr);
+#endif
while (chars == -1 || chars >= buf_len) {
safe_delete_array(*ret);
if (chars == -1)
@@ -160,8 +160,10 @@
else
buf_len = chars + 1;
*ret = new char[buf_len];
- va_copy(tmpargptr, argptr);
- chars = vsnprintf(*ret, buf_len, format, tmpargptr);
+#ifndef WIN32
+ va_copy(argptr, tmpargptr);
+#endif
+ chars = vsnprintf(*ret, buf_len, format, argptr);
}
va_end(argptr);
return chars;
@@ -174,8 +176,12 @@
*strlen = 0;
int chars = -1;
char* oldret = 0;
- va_list argptr, tmpargptr;
+ va_list argptr;
va_start(argptr, format);
+#ifndef WIN32
+ va_list tmpargptr;
+ va_copy(tmpargptr, argptr);
+#endif
while (chars == -1 || chars >= (sint32)(*bufsize-*strlen)) {
if (chars == -1)
*bufsize += 256;
@@ -188,8 +194,10 @@
memcpy(*ret, oldret, *strlen);
safe_delete_array(oldret);
}
- va_copy(tmpargptr, argptr);
- chars = vsnprintf(&(*ret)[*strlen], (*bufsize-*strlen), format, tmpargptr);
+#ifndef WIN32
+ va_copy(argptr, tmpargptr);
+#endif
+ chars = vsnprintf(&(*ret)[*strlen], (*bufsize-*strlen), format, argptr);
}
va_end(argptr);
*strlen += chars;
Index: common/debug.cpp
===================================================================
--- common/debug.cpp (revision 707)
+++ common/debug.cpp (working copy)
@@ -20,10 +20,6 @@
#endif
#include "../common/MiscFunctions.h"
-#ifndef va_copy
- #define va_copy(d,s) ((d) = (s))
-#endif
-
static volatile bool logFileValid = false;
static EQEMuLog realLogFile;
EQEMuLog *LogFile = &realLogFile;
@@ -148,18 +144,29 @@
fprintf(fp[id], "%04i [%02d.%02d. - %02d:%02d:%02d] ", getpid(), newtime->tm_mon+1, newtime->tm_mday, newtime->tm_hour, newtime->tm_min, newtime->tm_sec);
#endif
- va_list argptr, tmpargptr;
+ va_list argptr;
va_start(argptr, fmt);
+#ifndef WIN32
+ va_list tmpargptr;
+ va_copy(tmpargptr, argptr);
+#endif
if (dofile) {
- va_copy(tmpargptr, argptr);
- vfprintf( fp[id], fmt, tmpargptr );
+#ifndef WIN32
+ va_copy(argptr, tmpargptr);
+#endif
+ vfprintf( fp[id], fmt, argptr );
}
if(logCallbackFmt[id]) {
msgCallbackFmt p = logCallbackFmt[id];
- va_copy(tmpargptr, argptr);
- p(id, fmt, tmpargptr );
+#ifndef WIN32
+ va_copy(argptr, tmpargptr);
+#endif
+ p(id, fmt, argptr );
}
if (pLogStatus[id] & 2) {
+#ifndef WIN32
+ va_copy(argptr, tmpargptr);
+#endif
if (pLogStatus[id] & 8) {
fprintf(stderr, "[%s] ", LogNames[id]);
vfprintf( stderr, fmt, argptr );
@@ -211,7 +218,10 @@
time( &aclock ); /* Get time in seconds */
newtime = localtime( &aclock ); /* Convert time to struct */
+#ifndef WIN32
va_list tmpargptr;
+ va_copy(tmpargptr, argptr);
+#endif
if (dofile) {
#ifndef NO_PIDLOG
@@ -219,15 +229,22 @@
#else
fprintf(fp[id], "%04i [%02d.%02d. - %02d:%02d:%02d] %s", getpid(), newtime->tm_mon+1, newtime->tm_mday, newtime->tm_hour, newtime->tm_min, newtime->tm_sec, prefix);
#endif
- va_copy(tmpargptr, argptr);
- vfprintf( fp[id], fmt, tmpargptr );
+#ifndef WIN32
+ va_copy(argptr, tmpargptr);
+#endif
+ vfprintf( fp[id], fmt, argptr );
}
if(logCallbackPva[id]) {
msgCallbackPva p = logCallbackPva[id];
- va_copy(tmpargptr, argptr);
- p(id, prefix, fmt, tmpargptr );
+#ifndef WIN32
+ va_copy(argptr, tmpargptr);
+#endif
+ p(id, prefix, fmt, argptr );
}
if (pLogStatus[id] & 2) {
+#ifndef WIN32
+ va_copy(argptr, tmpargptr);
+#endif
if (pLogStatus[id] & 8) {
fprintf(stderr, "[%s] %s", LogNames[id], prefix);
vfprintf( stderr, fmt, argptr );
@@ -306,13 +323,22 @@
}
bool EQEMuLog::writeNTS(LogIDs id, bool dofile, const char *fmt, ...) {
- va_list argptr, tmpargptr;
+ va_list argptr;
va_start(argptr, fmt);
+#ifndef WIN32
+ va_list tmpargptr;
+ va_copy(tmpargptr, argptr);
+#endif
if (dofile) {
- va_copy(tmpargptr, argptr);
- vfprintf( fp[id], fmt, tmpargptr );
+#ifndef WIN32
+ va_copy(argptr, tmpargptr);
+#endif
+ vfprintf( fp[id], fmt, argptr );
}
if (pLogStatus[id] & 2) {
+#ifndef WIN32
+ va_copy(argptr, tmpargptr);
+#endif
if (pLogStatus[id] & 8)
vfprintf( stderr, fmt, argptr );
else
|
 |
|
 |

06-23-2009, 02:26 PM
|
Administrator
|
|
Join Date: Sep 2006
Posts: 1,348
|
|
No crashes for va_lists from windows that I can find.
|

06-23-2009, 04:25 PM
|
Developer
|
|
Join Date: Apr 2009
Location: USA
Posts: 478
|
|
Excellent.
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -4. The time now is 05:56 PM.
|
|
 |
|
 |
|
|
|
 |
|
 |
|
 |