com/instance, Array: Tweaks to MEMTRACKING mode
authorJerome St-Louis <jerome@ecere.com>
Sun, 25 Oct 2015 06:57:41 +0000 (02:57 -0400)
committerJerome St-Louis <jerome@ecere.com>
Mon, 21 Dec 2015 19:03:45 +0000 (14:03 -0500)
ecere/src/com/containers/Array.ec
ecere/src/com/instance.ec

index 07397cf..11a5782 100644 (file)
@@ -72,6 +72,13 @@ public:
             array = renew array T[(int)pos + 1];
          count = (int)pos + 1;
          if(justAdded) *justAdded = true;
+#if !defined(MEMINFO) && defined(MEMTRACKING)
+         if(array)
+         {
+            MemBlock block = (MemBlock)((byte *)array - sizeof(class MemBlock));
+            block._class = class(T);
+         }
+#endif
       }
       return ((int)pos < count && array) ? (IteratorPointer)(array + (int)pos) : null;
    }
@@ -154,7 +161,7 @@ public:
             else if(value > count)
                memset((byte *)array + count * class(T).typeSize, 0, (value - count) * class(T).typeSize);
             count = value;
-#if defined(_DEBUG) && !defined(MEMINFO) && defined(MEMTRACKING)
+#if !defined(MEMINFO) && defined(MEMTRACKING)
             if(array)
             {
                MemBlock block = (MemBlock)((byte *)array - sizeof(class MemBlock));
@@ -176,6 +183,13 @@ public:
                array = renew array T[value];
             minAllocSize = value;
          }
+#if !defined(MEMINFO) && defined(MEMTRACKING)
+         if(array)
+         {
+            MemBlock block = (MemBlock)((byte *)array - sizeof(class MemBlock));
+            block._class = class(T);
+         }
+#endif
       }
    }
 
@@ -185,6 +199,14 @@ public:
       if(count > minAllocSize)
          array = renew array T[count];
 
+#if !defined(MEMINFO) && defined(MEMTRACKING)
+         if(array)
+         {
+            MemBlock block = (MemBlock)((byte *)array - sizeof(class MemBlock));
+            block._class = class(T);
+         }
+#endif
+
       // TOFIX: Precomp fails on (BuiltInContainer *)
       if((source._class == class(BuiltInContainer) && ((struct BuiltInContainer *)source)->type.type != structClass ) ||
          eClass_IsDerived(source._class, class(Array)))
index 24e718e..afa18f9 100644 (file)
@@ -716,7 +716,7 @@ private class MemBlock : struct
    MemBlock prev, next;
    MemPart part;
    uint size;
-#if defined(_DEBUG) && !defined(MEMINFO) && defined(MEMTRACKING)
+#if !defined(MEMINFO) && defined(MEMTRACKING)
    Class _class;
 #endif
 };
@@ -1235,7 +1235,7 @@ static void * _mymalloc(unsigned int size)
          block = pools[p].Add();
          if(block)
          {
-#if defined(_DEBUG) && defined(MEMTRACKING)
+#if defined(MEMTRACKING)
             block._class = null;
 #endif
             block.size = size;
@@ -1250,7 +1250,7 @@ static void * _mymalloc(unsigned int size)
             TOTAL_MEM += sizeof(class MemBlock) + size;
             OUTSIDE_MEM += sizeof(class MemBlock) + size;
             block.part = null;
-#if defined(_DEBUG) && defined(MEMTRACKING)
+#if defined(MEMTRACKING)
             block._class = null;
 #endif
             block.size = size;
@@ -4598,7 +4598,7 @@ public dllexport void * eInstance_New(Class _class)
    memMutex.Release();
 #endif
 
-#if defined(_DEBUG) && !defined(MEMINFO) && defined(MEMTRACKING)
+#if !defined(MEMINFO) && defined(MEMTRACKING)
       {
          MemBlock block = (MemBlock)((byte *)instance - sizeof(class MemBlock));
          block._class = _class;
@@ -7250,7 +7250,7 @@ public uint16 * UTF8toUTF16(const char * source, int * wordCount)
 
 namespace com;
 
-#if defined(_DEBUG) && !defined(MEMINFO) && defined(MEMTRACKING)
+#if !defined(MEMINFO) && defined(MEMTRACKING)
 import "Map"
 
 Map<Class, int> blocksByClass { };
@@ -7258,7 +7258,7 @@ Map<Class, int> blocksByClass { };
 
 public void queryMemInfo(char * string)
 {
-#if defined(_DEBUG) && !defined(MEMINFO) && defined(MEMTRACKING)
+#if !defined(MEMINFO) && defined(MEMTRACKING) && !defined(DISABLE_MEMMGR)
    char s[1024];
    int p;
    uint numBlocks = 0;