Thank you for a clear explanation!

Cheers,

Michael Switzer
Jump Productions
Phone  +64 7 838 3371
Fax       +64 7 838 3372
Email    [EMAIL PROTECTED]

-----Original Message-----
From: Carl Reynolds <[EMAIL PROTECTED]>
To: Multiple recipients of list delphi <[EMAIL PROTECTED]>
Date: 28 July, 1999 9:15 AM
Subject: RE: [DUG]: Any comments


>Think of a TBitmap as a pointer to a block of memory.
>
>function myapp.getaBM(oldBM:tbitmap):tbitmap;
>var bitmap:tbitmap
>begin
>
> // oldBM->memblock1, Bitmap->nil, Result->nil
>
>bitmap:=tbitmap.create;
>
> // oldBM->memblock1, Bitmap->memblock2, Result->nil
>
>//rest bitmap initialize here
>bitmap:=oldBM;
>
> // oldBM->memblock1, Bitmap->memblock1, Result->nil, no pointers
>to memblock2 so memblock2 is lost!
>
>result:=bitmap;
>
> // oldBM->memblock1, Bitmap->memblock1, Result->memblock1
>
>bitmap.free;    //gwan get lost result
>
> // oldBM->[freed], Bitmap->[freed], Result->[freed]
>
>end;
>
>So the bitmap that you passed to this function has been freed by it, and
>the function will return this (already freed) bitmap.  Access violation
>city.  And the function leaks memory to boot (a TBitmap is created and
>promptly forgotten about)...
>
>Cheers,
>
>Carl Reynolds                      Ph: +64-9-4154790
>CJN Technologies Ltd.             Fax: +64-9-4154791
>[EMAIL PROTECTED]                DDI: +64-9-4154795
>PO Box 302-278, North Harbour, Auckland, New Zealand
>12 Piermark Drive, North Harbour Estate, Auckland, NZ
>Visit our website at http://www.cjntech.co.nz/


---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz

Reply via email to