[Issue 7271] New: Calling struct.init causes a memory allocation.

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Jan 11 09:03:35 PST 2012


http://d.puremagic.com/issues/show_bug.cgi?id=7271

           Summary: Calling struct.init causes a memory allocation.
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: code at benjamin-thaut.de


--- Comment #0 from Benjamin Thaut <code at benjamin-thaut.de> 2012-01-11 09:03:33 PST ---
struct MemoryBlockInfo
{
  size_t size;
  long[10] backtrace;
  int backtraceSize;

  this(size_t size)
  {
    this.size = size;
  }
}

int main(string[] argv)
{
  MemoryBlockInfo info;
  info = MemoryBlockInfo.init; //array allocation here
} 

This allocation seems totaly unneccesary. Also TypeInfo.init should return a
immutable(void)[] instead of a void[] as it seems totaly illogical to modify
the data retreived by TypeInfo.init.

This is especially critical when working without a GC because one is not able
to free the allocated memory for the array as the allocation gets generated by
the compiler.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list