[comp.windows.x.motif] Bus error on XmCreateLabel

twebb@pixel.Berkeley.EDU (Tracy Webb) (12/16/90)

I was wondering if anyone could find some obvious reason for the code
below to receive a bus error.  I haven't done much with arrays of
widgets and so I'm in new territory.  

I'm trying to create two label widgets as needed from an array of
widgets.  Heres the code :

int    x_count = 0;
Widget xlabel[100];
Widget xcurrent[100];

      for (i=x_count; i<total; i++) {
        curpos += 33; /* represents the top of the widget */
        XtSetArg(args[0], XmNy, curpos);

        xlabel[i] = XmCreateLabel(labelForm, "New", args, 1);
        xcurrent[i] = XmCreateLabel(currentForm, "New", args, 1);
        xtext[i] = XmCreateText(changeForm, "New", args, 0);
      }

The error I get comes the first time through the for loop on the second
creation of a label.  It seems to be coming from malloc.  Any clues???

Thanks - I appreciate the help!!!


Tracy Webb



Tracy Webb
Graphics and Windowing Software Group
CONVEX Computer Corporation
Richardson, TX
email: twebb@convex.com
phone: 214/497-4934

kristin@hpcc01.HP.COM (Kristin Hofso) (12/21/90)

Hi,

The code looks fine. My experience is that when you "die" on a malloc
it usually means that you have been "stepping" on memory earlier in
the code. Chances are your error is in a completely different part of
the code.

Sorry, I can't be of more help.

Kristin Hofso, HP
kristin@hpasdd.mayfield.hp.com