Owen said:

>How long is a pointer returned by FldGetTextPtr guaranteed to be valid?
>
>Obviously, changing the field text could invalidate it, but what other
>actions render the pointer "unsafe"?

and Ingo replied:

>If I understood things right, as long as you lock the handle associated with
>the memory the pointer points to. Unlocked data can be relocated any time.
>
>In an application I am writing, I use FldSetTextPtr/FldGetTextPtr with
>pointers to text which is declared as const in the C source code. Hopefully,
>the application won't be relocated while running.
>
>Does anyone know whether this is true?

1. If you've got a typical editable field, then the pointer returned by
FldGetTextPtr should be valid until:

        a. You make another call to the field code. Some of the Field APIs
would seem safe to call, but given the dynamic nature of the rom code,
you're better off not relying on the pointer staying valid.

        b. You make a call to something that in turn calls a field routine.
For example, the form code will call the field code to dispose of the
handle when the form is being tossed.

        c. The field's text handle gets munged by you or some other routine
which knows about it. Obviously if you mess with the handle then all bets
are off.

Note that if the field is empty, then the call to FldGetTextPtr can return
null if the text handle never had to be allocated.

2. If you've got a field is not editable, then the ptr won't change on
you..and you don't have to worry about the application getting relocated
while running.

-- Ken

Ken Krugler
TransPac Software, Inc.
<http://www.transpac.com>
+1 650-947-9222 (direct) +1 408-261-7550 (main)


Reply via email to