Jump to content

[11248] SQLStorage::Free


Guest Vinolentus

Recommended Posts

We ignore other format values at loading and it is expected to ignore them here, not increment offset.

diff --git a/src/shared/Database/SQLStorage.cpp b/src/shared/Database/SQLStorage.cpp
index c33530b..287a00e 100644
--- a/src/shared/Database/SQLStorage.cpp
+++ b/src/shared/Database/SQLStorage.cpp
@@ -44,21 +44,31 @@ void SQLStorage::Free ()
{
    uint32 offset=0;
    for(uint32 x=0;x<iNumFields;x++)
-        if (dst_format[x]==FT_STRING)
+    {
+        switch (dst_format[x])
        {
-            for(uint32 y=0;y<MaxEntry;y++)
-                if(pIndex[y])
-                    delete [] *(char**)((char*)(pIndex[y])+offset);
+            case FT_STRING:
+            {
+                for(uint32 y = 0; y < MaxEntry; ++y)
+                    if(pIndex[y])
+                        delete [] *(char**)((char*)(pIndex[y])+offset);

-            offset += sizeof(char*);
+                offset += sizeof(char*);
+                break;
+            }
+            case FT_LOGIC:
+                offset += sizeof(bool);     break;
+            case FT_BYTE:
+                offset += sizeof(char);     break;
+            case FT_INT:
+                offset += sizeof(uint32);   break;
+            case FT_FLOAT:
+                offset += sizeof(float);    break;
+
+            default:                        break;
        }
-        else if (dst_format[x]==FT_LOGIC)
-            offset += sizeof(bool);
-        else if (dst_format[x]==FT_BYTE)
-            offset += sizeof(char);
-        else
-            offset += 4;

+    }
    delete [] pIndex;
    delete [] data;
}

Link to comment
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use