ecere/com/containers/List: Worked around too much memory being allocated
authorJerome St-Louis <jerome@ecere.com>
Sun, 3 Jul 2016 10:45:04 +0000 (06:45 -0400)
committerJerome St-Louis <jerome@ecere.com>
Thu, 28 Jul 2016 22:23:14 +0000 (18:23 -0400)
- Added a note regarding Link instantiation allocating too much memory

ecere/src/com/containers/List.ec

index e8822d1..edd898c 100644 (file)
@@ -31,13 +31,20 @@ public class List<class LLT> : LinkList<Link, T = LLT, D = LLT>
    Link Insert(Link after, LLT value)
    {
       Link link;
-      if(class(LLT) && class(LLT).type == structClass)
+      Class cLLT = class(LLT);
+      if(cLLT && cLLT.type == structClass)
       {
-         link = (Link)new0 byte[sizeof(class ListItem) + class(LLT).structSize];
-         memcpy((void *)&link.data, (void *)value, class(LLT).structSize);
+         uint sType = cLLT.structSize;
+         link = (Link)new0 byte[sizeof(class ListItem) + sType];
+         memcpy((void *)&link.data, (void *)value, sType);
       }
       else
-         link = Link { data = (uint64)value };
+      {
+         // TOFIX: This allocates too much data?
+         // link = Link { data = (uint64)value };
+         link = (Link)new0 byte[sizeof(class ListItem) + sizeof(uint64)];
+         link.data = (uint64)value;
+      }
       LinkList::Insert(after, (LT)link);
       return link;
    }