T.R | Title | User | Personal Name | Date | Lines |
---|
3567.1 | Where's the CS going? | TOOLEY::B_WACKER | | Thu Nov 01 1990 17:12 | 3 |
| You probably need to XT$FREE %VAL(CS_PTR) on each iteration.
Bruce
|
3567.2 | Won't that mess up the listbox? | SFCPMO::MILLER | Miles to go before I sleep... | Fri Nov 02 1990 00:17 | 21 |
| But wouldn't that cause my compound string in the listbox to be
deallocated? And then cause a crash when the widget tried to display
the compound string (e.g., on an expose event)? You know something
about finding the memory for the string no longer valid?
I wonder if what's really happening here is that DWT$GET_NEXT_SEGMENT
is grabbing the compound string data structure and dynamically
creating a new copy of it somewhere else in memory. Then it can do
destructive things to it without harming the widget's data structure.
Something else that's kinda interesting: the CS context is made up of
two longwords where the first is an address and the second is an
offset. Why is it that the address is always 0 and the offset look
suspiciously like an address?
Anyway, thanks for the idea. I'll see what happens when I try
XT$FREE(%VAL(CS_PTR)). I think I'll also try using
XT$FREE(%VAL(LB_INDEX(2))).
Matt
|
3567.3 | Some info | LEOVAX::TREGGIARI | | Fri Nov 02 1990 08:21 | 26 |
| > But wouldn't that cause my compound string in the listbox to be
> deallocated?
No
> I wonder if what's really happening here is that DWT$GET_NEXT_SEGMENT
> is grabbing the compound string data structure and dynamically
> creating a new copy of it somewhere else in memory.
Yes
> Something else that's kinda interesting: the CS context is made up of
> two longwords where the first is an address and the second is an
> offset. Why is it that the address is always 0 and the offset look
> suspiciously like an address?
Don't touch anything inside the context. I don't remember exactly
what's in the two lonwords, but in DECwindows V1, the two lonwords
were sufficient to hold the entire context. In DECwindows V2, we
needed more information, but we had made the mistake in V1 of
having the application allocate the context, so we couldn't change
the size. So, one of those two lonwords points to another
data structure.
Leo
|
3567.4 | Which variable do I use for XT$FREE? | SFCPMO::MILLER | Miles to go before I sleep... | Fri Nov 02 1990 09:22 | 10 |
|
If DWT$GET_NEXT_SEGMENT is dynamically allocating memory, how do I
free this memory? I *assumed* that DWT$STRING_FREE_CONTEXT would do
this for me. If this isn't the case, then which variable has the
compound string pointer? Do I use the one which I pulled from the
listbox items list?
I appreciate everyone's ideas.
Matt
|
3567.5 | | QUARK::LIONEL | Free advice is worth every cent | Fri Nov 02 1990 10:28 | 14 |
| Do NOT free the compound string if you got it by calling XT$GET_VALUES, or
pulled it off a callback data structure.
Looking at the manual, it seems you may be out of luck. The C routine
allocates space for the ASCIZ string, and the manual says you should free
it. The VAX routine probably calls the C routine, copies the string into
your descriptor, and then doesn't free the string from the C routine.
I'd suggest trying to use the C routine for GET_NEXT_SEGMENT instead, finding
the length with INDEX or LIB$LOCC, and copying the string to your own
CHARACTER variable, then free the ASCIZ string. (I'm a bit puzzled about
the manual saying to use XT$FREE - isn't that only for compound strings?)
Steve
|
3567.6 | Confirming Steve's guess | TOOLEY::B_WACKER | | Fri Nov 02 1990 13:07 | 4 |
| Bingo! The 5.3 source for DWT$GET_NEXT_SEGMENT doesn't free the text
after copying to your descriptor. Someone should QAR it.
Bruce
|
3567.7 | XtFree not just for compound strings | LEOVAX::TREGGIARI | | Sat Nov 03 1990 09:39 | 9 |
| > (I'm a bit puzzled about
> the manual saying to use XT$FREE - isn't that only for compound strings?)
No. XtFree/XT$FREE must be used with anything allocated with
XtMalloc, XtCalloc, XtRealloc. The toolkit uses those for all
memory that it allocates, not just compound strings.
Leo
|