Dear List,
  I was working with a file containing 660,000 entries and had to make some
changes. I use a hash table for handle->object index resolution to improve
the parse performance by orders of magnitude (down from 14 minutes to 2
seconds). I also put in some const correctness because that's just basic.
My git repo is here: https://github.com/benegon/libredwg

Now for the bad news: I noticed LibreDWG stores pointers into arrays that
are realloced, namely

Dwg_Data.layer_control points into Dwg_Data.object, but this array is
continually realloced and the base pointer may change.
Dwg_Data.header.section_info also seems to be afflicted by this bug.

Possible Dwg_Data.dwg_class* as well.

YOU CANNOT STORE POINTERS INTO THESE ARRAYS; realloc can move the whole
array somewhere else, so please store the offsets instead and calculate the
pointer when needed. This is probably why some people have been seeing
memory corruption.

For my own purposes I will initialize the number of objects to 1000000 or
more, depending on how big my files get. Hopefully you guys can resolve
this memory issue.

-Dave

Reply via email to