- assigned_to: nobody --> t1mpy
This really isn't a direct bug in the code but it results in
a memory access violation due to the way some
compilers (Windows / VC++ in this case) work. The
result is that a memory violation exception occurs when
an allocator is deleted.
The error happens when I compiled the DLL version of
the id3lib project. No problem. I then go to use the DLL
in a generic MFC project and I get memory exceptions
every time I try to 'delete' an iterator.
The problem is that the debug version of the MFC will
override operators new & delete and replace them with
their own version for memory tracking and etc. So the
iterator is allocated in the DLL using one version of the
memory allocator and then it's deleted from the external
code using a different allocator.
The simple fix that I put in is to simply add a
ReleaseAllocator() method on the classes that create
them such as:
void ID3_Tag::ReleaseIterator(Iterator* p)
{
delete p;
}
This ensures that the same memory allocator that
originally created the iterator is also the same one that
deletes the allocator. Developers are still able to
call 'delete' themselves if they like but this prevents
potential problems that can arrise when allocating and
freeing memory across executable modules.
/ mark
PS - > Great project. Very useful to me.