[Search for users]
[Overall Top Noters]
[List of all Conferences]
[Download this site]
Title: | DECWINDOWS 26-JAN-89 to 29-NOV-90 |
Notice: | See 1639.0 for VMS V5.3 kit; 2043.0 for 5.4 IFT kit |
Moderator: | STAR::VATNE |
|
Created: | Mon Oct 30 1989 |
Last Modified: | Mon Dec 31 1990 |
Last Successful Update: | Fri Jun 06 1997 |
Number of topics: | 3726 |
Total number of notes: | 19516 |
2996.0. "Reserved Operand Fault w/ Compound Strings" by NITMOI::WITHERS (Another Hallmark Moment. -Al Bundy) Tue Jun 26 1990 17:13
Help. I am having trouble with strings in DECwindows. I happen upon a
Reserved Operand Fault. The problem is it comes at strange intervals and
happens on different commands. Any help would be appreciated.
What I am trying to do is take the text from a simple_text widget, append
a keyword onto it, and then Add/Remove the result from a list box. This
is my first UI design attempt and so it could be an obvious mistake. Please
help!
The code in question: The fault has occured at varying times at either line
#1, #2, or #3. It is most often seen in #1 and dies there consitently if a
single character comes back from the simple_text widget (text_value).
.
.
.
#define S_TEXT " (Text)"
char *constant_string = S_TEXT;
.
.
.
activate_callback()
{
static char *list_entry, *status, *text_value;
.
.
.
text_value = DwtSTextGetString (mysimpletextwidget);
status = strcat (text_value,constant_string);
list_entry = DwtLatin1String (text_value); <--#1
item_exists = DwtListBoxItemExists (mylistboxwidget,list_entry);<--#2
if (item_exists == 0) {
DwtListBoxAddItem (mylistboxwidget,list_entry,0); <--#3
.
.
.
Agaian, any help/pointers/etc is *really* appreciated!
George
T.R | Title | User | Personal Name | Date | Lines |
---|
2996.1 | | MARX::BARLOW | | Tue Jun 26 1990 18:20 | 13 |
|
Here's one hint that's probably not affecting you yet. If you do a
DwtSTextGetString on a strcpy, and there's nothing to get, sometimes a
segmentation fault will occur. What you might want to do is :
if( strlen(DwtSTextGetString( whatever) ) >0)
assign DwtSTextGetString
I would step through the debugger and see exactly what's coming out of
each stmt. Perhaps by the time it gets to DwtLatin1String, it's no
longer a good string?
Rachael
|
2996.2 | overwriting random data | RTL::ROLLMAN | | Wed Jun 27 1990 09:57 | 10 |
|
It looks like you're overwriting memory. DwtSTextGetString allocates only
enough memory for the string it returns. Since you're concatenating more
bytes onto that string, you will need to reallocate 'text_value' to hold it.
This would explain why it's seg faulting at various lines - depends upon what
is in the memory that being overwritten.
Pat
|
2996.3 | memory leak | R2ME2::OBRYAN | | Wed Jun 27 1990 19:41 | 7 |
|
> if( strlen(DwtSTextGetString( whatever) ) >0)
> assign DwtSTextGetString
You don't want to do it this way... every call to DwtSTextGetString results
in malloc'd memory. If you don't save the return value, the memory is lost.
|