Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: urgent question to ´MS-VC++ 6.0´ experts (Dann Corbit?)

Author: martin fierz

Date: 13:26:42 12/05/03

Go up one level in this thread


On December 05, 2003 at 15:10:08, Heiner Marxen wrote:

>On December 05, 2003 at 13:49:31, F. Huber wrote:
>
>>On December 05, 2003 at 13:05:57, martin fierz wrote:
>>
>>>hi franz,
>>>
>>>i believe this might all be consistent: windows has different mem alloc
>>>functions, and the compiler translates "malloc" into one of them. so if the
>>>borland compiler translates it into "virtualalloc" while the MS compiler
>>>translates it into "heapalloc", you get exactly the kind of behavior you
>>>observed.
>
>Yes, that is what it looks like.
>
>>>if portability is not an issue, then you should use the windows functions. my
>>>book says you should use virtualalloc for large chunks of memory, and heapalloc
>>>for small chunks. heapalloc is supposed to be much slower when handling large
>>>amounts of memory.
>>>
>>>virtualalloc is quite easy to use, just do
>>>
>>>pointer = VirtualAlloc(0, number_of_bytes, MEM_RESERVE|MEM_COMMIT,
>>>PAGE_READWRITE);
>>>to allocate memory, and
>
>Does this funtion initialize the memory, like calloc() does,
>or does it leave it uninitialized, like malloc() does?

the memory is initialized to zero. you have further possibilities in the
virtualalloc call that i didn't go into; the things i posted are just
replacements for malloc() and free().

>>>VirtualFree(pointer, 0, MEM_RELEASE);
>>>to free it again.
>
>Also, I suspect, that something must be #include'd to get the manifests
>above (MEM_...).  What does your docu say?

you are right of course, you must include <windows.h> - sorry, i forgot that,
been programming windows for too long and bill is controlling my mind :-)

cheers
  martin



>
>>>cheers
>>>  martin
>>
>>Hi again,
>>
>>that looks really simple - thanks for saving me a lot of time. :)
>>
>>I´ll try this, but since I´m not ´really´ a C-programmer (_my_ language
>>is Borland Delphi), and since I´m manipulating the source code of Heiner
>>Marxen, I must be _very_ carefully to not do any ´blunder´.
>>
>>Regards,
>>Franz.
>
>Franz, you can send me your modified code (snippet) per email,
>and I'll check it, based on the above description.
>
>Cheers,
>Heiner



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.