[Scummvm-git-logs] scummvm master -> e052e45ac6edbdb88fc0e6b18b97e7b5a809d040

mduggan mgithub at guarana.org
Thu Mar 4 14:06:25 UTC 2021


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
fa95f28fc9 PRIVATE: Remove some more unnecessary copies
e052e45ac6 PRIVATE: Restore a memory leak until it can be fixed properly.


Commit: fa95f28fc93cd8755dc98c39f35482c4c7b0d250
    https://github.com/scummvm/scummvm/commit/fa95f28fc93cd8755dc98c39f35482c4c7b0d250
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2021-03-04T23:06:00+09:00

Commit Message:
PRIVATE: Remove some more unnecessary copies

Changed paths:
    engines/private/private.cpp


diff --git a/engines/private/private.cpp b/engines/private/private.cpp
index da0a41bbbe..012dacb44e 100644
--- a/engines/private/private.cpp
+++ b/engines/private/private.cpp
@@ -381,11 +381,10 @@ bool PrivateEngine::cursorExit(Common::Point mousePos) {
 
     int rs = 100000000;
     int cs = 0;
-    ExitInfo e;
-    Common::String cursor = "";
+    Common::String cursor;
 
     for (ExitList::iterator it = _exits.begin(); it != _exits.end(); ++it) {
-        e = *it;
+        const ExitInfo &e = *it;
         cs = e.rect.width()*e.rect.height();
 
         if (e.rect.contains(mousePos)) {
@@ -420,10 +419,9 @@ bool PrivateEngine::inMask(Graphics::ManagedSurface *surf, Common::Point mousePo
 
 
 bool PrivateEngine::cursorMask(Common::Point mousePos) {
-    MaskInfo m;
     bool inside = false;
     for (MaskList::iterator it = _masks.begin(); it != _masks.end(); ++it) {
-        m = *it;
+        const MaskInfo &m = *it;
 
         if (inMask(m.surf, mousePos)) {
             if (!m.cursor.empty()) { // TODO: check this
@@ -466,9 +464,8 @@ void PrivateEngine::selectExit(Common::Point mousePos) {
     Common::String ns = "";
     int rs = 100000000;
     int cs = 0;
-    ExitInfo e;
     for (ExitList::iterator it = _exits.begin(); it != _exits.end(); ++it) {
-        e = *it;
+        const ExitInfo &e = *it;
         cs = e.rect.width()*e.rect.height();
         //debug("Testing exit %s %d", e.nextSetting->c_str(), cs);
         if (e.rect.contains(mousePos)) {
@@ -492,10 +489,9 @@ void PrivateEngine::selectExit(Common::Point mousePos) {
 }
 
 void PrivateEngine::selectMask(Common::Point mousePos) {
-    Common::String ns = "";
-    MaskInfo m;
+    Common::String ns;
     for (MaskList::iterator it = _masks.begin(); it != _masks.end(); ++it) {
-        m = *it;
+        const MaskInfo &m = *it;
         //debug("Testing mask %s", m.nextSetting->c_str());
         if (inMask(m.surf, mousePos)) {
             //debug("Inside!");
@@ -572,7 +568,7 @@ void PrivateEngine::selectPhoneArea(Common::Point mousePos) {
         return;
 
     if (inMask(_phoneArea.surf, mousePos)) {
-        PhoneInfo i = _phone.back();
+        const PhoneInfo &i = _phone.back();
         setSymbol(i.flag, i.val);
         Common::String sound = _phonePrefix + i.sound + ".wav";
         playSound(sound, 1, true, false);


Commit: e052e45ac6edbdb88fc0e6b18b97e7b5a809d040
    https://github.com/scummvm/scummvm/commit/e052e45ac6edbdb88fc0e6b18b97e7b5a809d040
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2021-03-04T23:06:00+09:00

Commit Message:
PRIVATE: Restore a memory leak until it can be fixed properly.

Changed paths:
    engines/private/symbol.cpp


diff --git a/engines/private/symbol.cpp b/engines/private/symbol.cpp
index 3451b6e086..ff4b8ceb95 100644
--- a/engines/private/symbol.cpp
+++ b/engines/private/symbol.cpp
@@ -89,7 +89,7 @@ static Symbol *install(const Common::String &n, int t, int d, const char *s, Com
     if (t == NUM || t == NAME)
         sp->u.val = d;
     else if (t == STRING)
-        sp->u.str = s;
+        sp->u.str = strndup(s, strlen(s)); // FIXME: leaks a string here.
     else if (t == RECT)
         sp->u.rect = r;
     else




More information about the Scummvm-git-logs mailing list