On 7 September 2010 22:02, Jose Baars <peut_at_peut.org> wrote:
> Op 9/7/2010 4:13 PM, Ezequiel Ruiz schreef:
>>>
>>>> Indeed. I've tested the code with Mingw (GCC 4.4) and it works OK.
>>>
>>> This will be because Mingw doesn't give you the option of linking to
>>> different runtime versions (such as Debug variants), not because MSVC
>>> is 'broken' and Mingw is not. Your code will still be violating the
>>> rules and works by luck.
>>>
>>> Alex
>>
> Can someone provide a url where these rules are roughly explained?
...snip
> Jose
Hmmm. The first rule, "always deallocate memory with the same
allocator that allocated it" is as old a houses and probably isn't
written anywhere formal. For instance, you would never dream of using
`malloc` to allocate and `delete` to deallocate .However it follows
from the basic rule that if you want to access some data stored in one
location in memory, accessing a completely different location in
memory isn't going to get you the data you were after! The data in
this case being the allocator's table of allocated regions.
The second 'rule' is in fact the absence of a rule: the rule that
different implementations of the C runtime must store their data in a
common location and manipulate it in a common way. There is no such
rule in the C specification and therefore you can't rely on in. In
fact, as has been shown here often, real implementations _don't_ share
their data and any cross-module manipulation leads to memory
corruption.
See also:
- http://blogs.msdn.com/b/oldnewthing/archive/2006/09/15/755966.aspx
- http://msdn.microsoft.com/en-us/library/ms235460%28VS.80%29.aspx
Alex
-- Swish - Easy SFTP for Windows Explorer (http://www.swish-sftp.org) _______________________________________________ libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-develReceived on 2010-09-08