[Scummvm-cvs-logs] SF.net SVN: scummvm:[47496] scummvm/trunk/engines/sci/engine/kstring.cpp
thebluegr at users.sourceforge.net
thebluegr at users.sourceforge.net
Sun Jan 24 12:00:21 CET 2010
Revision: 47496
http://scummvm.svn.sourceforge.net/scummvm/?rev=47496&view=rev
Author: thebluegr
Date: 2010-01-24 11:00:21 +0000 (Sun, 24 Jan 2010)
Log Message:
-----------
Replaced CHECK_OVERFLOW1 with asserts
Modified Paths:
--------------
scummvm/trunk/engines/sci/engine/kstring.cpp
Modified: scummvm/trunk/engines/sci/engine/kstring.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kstring.cpp 2010-01-24 10:06:27 UTC (rev 47495)
+++ scummvm/trunk/engines/sci/engine/kstring.cpp 2010-01-24 11:00:21 UTC (rev 47496)
@@ -179,12 +179,6 @@
#define ALIGN_LEFT -1
#define ALIGN_CENTRE 2
-#define CHECK_OVERFLOW1(pt, size, rv) \
- if (((pt) - (targetbuf)) + (size) > maxsize) { \
- error("String expansion exceeded heap boundaries"); \
- return rv;\
- }
-
/* Format(targ_address, textresnr, index_inside_res, ...)
** or
** Format(targ_address, heap_text_addr, ...)
@@ -229,7 +223,7 @@
while ((xfer = *source++)) {
if (xfer == '%') {
if (mode == 1) {
- CHECK_OVERFLOW1(target, 2, NULL_REG);
+ assert((target - targetbuf) + 2 <= maxsize);
*target++ = '%'; /* Literal % by using "%%" */
mode = 0;
} else {
@@ -274,7 +268,7 @@
} else
str_leng = 0;
- CHECK_OVERFLOW1(target, str_leng + 1, NULL_REG);
+ assert((target - targetbuf) + str_leng + 1 <= maxsize);
switch (xfer) {
case 's': { /* Copy string */
@@ -283,7 +277,7 @@
arguments[paramindex + 1]);
int slen = strlen(tempsource.c_str());
int extralen = str_leng - slen;
- CHECK_OVERFLOW1(target, extralen, NULL_REG);
+ assert((target - targetbuf) + extralen <= maxsize);
if (extralen < 0)
extralen = 0;
@@ -336,7 +330,7 @@
break;
case 'c': { /* insert character */
- CHECK_OVERFLOW1(target, 2, NULL_REG);
+ assert((target - targetbuf) + 2 <= maxsize);
if (align >= 0)
while (str_leng-- > 1)
*target++ = ' '; /* Format into the text */
@@ -362,7 +356,7 @@
target += sprintf(target, format_string, val);
paramindex++;
- CHECK_OVERFLOW1(target, 0, NULL_REG);
+ assert((target - targetbuf) <= maxsize);
unsigned_var = 0;
@@ -407,8 +401,6 @@
return dest; /* Return target addr */
}
-#undef CHECK_OVERFLOW1
-
reg_t kStrLen(EngineState *s, int argc, reg_t *argv) {
return make_reg(0, s->_segMan->strlen(argv[0]));
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list