Danko Radic wrote:
>
> On Wed, 26 May 1999, Ion Popescu wrote:
>
> > DmResizeRecord() should fail (give a Fatal error msg)
> > if the record/handle is locked.
>
> Well, I'd be happy if it has done - I'd know the answer then. Please
> explain, then, how did it happen that the following example actually
> passed well:
>
Once you resize a record, you must use the new Handle returned.
The record may have been moved around. The old Handle as well as
the old pointer ("DataPtr" in your code) *may* have become invalid.
Ideally, whether you have resized or not, you should not use a
pointer once you have unlocked the handle. So your code should
be:-
MemHandleUnlock(myHandle); // or MemPtrUnlock(myPtr)
myHandle = DmResize(...);
myPtr = MemHandleLock(myHandle);
If you forget to store & use the return value of DmResize(..),
your code will work so long there is enough memory to
resize in-place.