News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

CoGetMalloc function (memory allocation)

Started by drjr, October 05, 2007, 06:07:38 PM

Previous topic - Next topic

drjr


Hi, for all friends programmers:

This is the problem:   I`m using CoGetMalloc function to allocate 1.600.000 byes in memory, and
this function give me almost 8 times this amount but when I try to fill these byte an error write protection fault occurs. Do someone known the answer ?

                                                                best regards for all


MichaelW

AFAIK the IMalloc Alloc method may allocate more than the requested number of bytes, but 8x seems way out of line. Can you post your code?
eschew obfuscation

Tedd

(Just to make sure :wink) CoGetMalloc gives you a pointer to a memory-allocator object, which you can then call Alloc from its IMalloc interface to do the actual memory allocation. The calls on the object are made using a com-style convention, so plain invoke won't work correctly.
Better post your code :bdg
No snowflake in an avalanche feels responsible.

japheth

Quote from: Tedd on October 06, 2007, 02:01:27 PM
(Just to make sure :wink) CoGetMalloc gives you a pointer to a memory-allocator object, which you can then call Alloc from its IMalloc interface to do the actual memory allocation. The calls on the object are made using a com-style convention, so plain invoke won't work correctly.

Yes. Using CoTaskMemAlloc instead of CoGetMalloc might do what you want, drjr.