[Scummvm-cvs-logs] SF.net SVN: scummvm:[53574] scummvm/trunk/engines/scumm/script_v5.cpp
fingolfin at users.sourceforge.net
fingolfin at users.sourceforge.net
Mon Oct 18 20:56:41 CEST 2010
Revision: 53574
http://scummvm.svn.sourceforge.net/scummvm/?rev=53574&view=rev
Author: fingolfin
Date: 2010-10-18 18:56:40 +0000 (Mon, 18 Oct 2010)
Log Message:
-----------
SCUMM: Simplify SO_LOAD_STRING code
Modified Paths:
--------------
scummvm/trunk/engines/scumm/script_v5.cpp
Modified: scummvm/trunk/engines/scumm/script_v5.cpp
===================================================================
--- scummvm/trunk/engines/scumm/script_v5.cpp 2010-10-18 18:56:20 UTC (rev 53573)
+++ scummvm/trunk/engines/scumm/script_v5.cpp 2010-10-18 18:56:40 UTC (rev 53574)
@@ -1840,18 +1840,12 @@
Common::InSaveFile *file = _saveFileMan->openForLoading(filename);
if (file != NULL) {
byte *ptr;
- int len = 256, cnt = 0;
- ptr = (byte *)malloc(len);
- while (ptr) {
- int r = file->read(ptr + cnt, len - cnt);
- cnt += r;
- if (cnt < len)
- break;
- len *= 2;
- ptr = (byte *)realloc(ptr, len);
- assert(ptr);
- }
- ptr[cnt] = '\0';
+ const int len = file->size();
+ ptr = (byte *)malloc(len + 1);
+ assert(ptr);
+ int r = file->read(ptr, len);
+ assert(r == len);
+ ptr[len] = '\0';
loadPtrToResource(rtString, a, ptr);
free(ptr);
delete file;
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