[futurebasic] RE: [FB] Temporary Memory (not in heap)

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : December 1999 : Group Archive : Group : All Groups

From: Chris.Young@...
Date: Wed, 15 Dec 1999 12:27:32 -0600
Herb,

You can dereference the handle and obtain a pointer to the block of 
memory. A handle is really a pointer to a pointer. By grabbing the 
content of the handle, via a PEEK LONG, or [] shorthand, you are 
obtaining the address of the second pointer, and can use it as such. 
One word of caution: the Mac Memory Manager can freely move a memory 
block allocated as a handle around in memory. The handle remains valid, 
but if you dereference the handle to obtain a pointer, the pointer 
address can change (where the block is in memory). You should therefore 
either lock the block down (via the toolbox calls HLOCK/HUNLOCK), or 
dereference the handle only when you need it, such as BLOCKMOVE 
[myHandle&], thisPtr&, blockSize.

If you choose to lock the block down, remember to unlock it when you no 
longer need it locked, to help avoid fragmenting memory.

hth

Chris Young

On Wednesday, December 15, 1999 12:18 PM, 
H.Gluender@... [SMTP:H.Gluender@...] 
wrote:
> Dear experts,
> 
> the MacToolbox supplies nice routines for the allocation of memory
> outside the application heap for temporary buffer needs.
> 
> These routines allocate (if available) a memory block pointed to by a
> _handle_, i.e. they return a handle.
> 
> I should like to use such temporary memory as a big buffer to copy 
files
> really fast -- just as the finder does (cf. IM/ Mem/2-9) -- but all 
READ
> and WRITE toolbox routines I am aware of need a memory block pointed 
to
> by a _pointer_.
> 
> On the other hand it is not possible to move a memory block from a
> handle to a pointer. Am I right?
> 
> Any suggestions to resolve this problem?
> 
> Thank you,
> 
> Herbie
> 
> *********************************
> H.Glu@...
> 
> 
> --
> To unsubscribe, send ANY message to 
<futurebasic-unsubscribe@...>
> 
>