From 4f54c7cf884d17c981eaae248c69f354da308b24 Mon Sep 17 00:00:00 2001 From: helixhorned Date: Tue, 17 Feb 2015 16:23:04 +0000 Subject: [PATCH] Fix swapbufreverse(), adding precondition of count >= 4. Also, in premap.c:G_CacheMapData(), comment out what was supposedly intended as a debugging message ("percentage ..."). git-svn-id: https://svn.eduke32.com/eduke32@5009 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/include/pragmas.h | 8 ++++++-- polymer/eduke32/source/premap.c | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/polymer/eduke32/build/include/pragmas.h b/polymer/eduke32/build/include/pragmas.h index 376885c35..fffe66828 100644 --- a/polymer/eduke32/build/include/pragmas.h +++ b/polymer/eduke32/build/include/pragmas.h @@ -248,6 +248,8 @@ static inline int32_t krecipasm(int32_t i) static inline void swapbufreverse(void *s, void *d, int32_t c) { uint8_t *src = (uint8_t *)s, *dst = (uint8_t *)d; + Bassert(c >= 4); + do { swapchar(dst, src); @@ -255,8 +257,10 @@ static inline void swapbufreverse(void *s, void *d, int32_t c) swapchar(dst + 2, src - 2); swapchar(dst + 3, src - 3); dst += 4, src -= 4; - } while (--c > 4); - while (c--) swapchar(dst++, src--); + } while ((c -= 4) > 4); + + while (c--) + swapchar(dst++, src--); } #ifdef __cplusplus diff --git a/polymer/eduke32/source/premap.c b/polymer/eduke32/source/premap.c index e0ba01c12..ccfc6d564 100644 --- a/polymer/eduke32/source/premap.c +++ b/polymer/eduke32/source/premap.c @@ -564,7 +564,7 @@ void G_CacheMapData(void) lpc++; } - OSD_Printf("percentage %d lpc %d\n", percentage, lpc); +// OSD_Printf("percentage %d lpc %d\n", percentage, lpc); } tc = totalclock;