Re: fl_load_browser()

Steve Lamont (spl@szechuan.ucsd.edu)
Wed, 26 Feb 97 11:27:42 PST

To subscribers of the xforms list from spl@szechuan.ucsd.edu (Steve Lamont) :

> How do you refernece the structure in the .h file, I must be doing
> something wrong as it keeps dumping core.

Where are you dumping core? I think your last code fragment (xx_cb.c)
is a little more fragmentary than you might intend.

> **** code frag xx.h **
>
> typefed struct{
> FL_FORM *sect2;
> FL_OBJECT *ciphertext;
> FL_OBJECT *encrypt;
> void *vdata;
> long ldata;
> } FD_sect2;
>
> ** end code frag **
>
> **** code frag xx.c ****
> fdui->ciphertext = obj =
> fl_add_browser(FL_NORMAL_BROWSER,110,220,680,120,"");
>
> ** end code frag **
>
> **** code graf xx_cb.c ****
>
> void encrypt_cb(FL_OBJECT *ob,long data)
> {
> FD_sect2 *ui;
>

How is

FD_sect2 *ui;

initialized? It doesn't get automagically initialized with anything.
Perhaps you mean to do something like...

FD_sect2 *ui;

int main( int argc, char **argv )

{

[...]

ui = create_form_sect2();

[...]

void encrypt_cb(FL_OBJECT *ob,long data)
{

extern FD_sect2 *ui;

fl_do_some_browser_function( ui->ciphertext, ... );

[...]

The code you show (unless there's something more you're *not* showing)
will have `ui' uninitialized and if you try to dereference that
pointer you're going to end up trying to dereference whatever garbage
happens to be on the stack. Hence the core dump.

spl
_________________________________________________
To unsubscribe, send the message "unsubscribe" to
xforms-request@bob.usuf2.usuhs.mil or see
http://bob.usuf2.usuhs.mil/mailserv/xforms.html
Xforms Home Page: http://bragg.phys.uwm.edu/xforms
List Archive: http://bob.usuf2.usuhs.mil/mailserv/list-archives/xforms-archive/