"new" operator not allocating enough memory?

Angelo Fraietta afraiett at bigpond.net.au
Fri Feb 20 21:43:44 UTC 2004



Mark Mussetter wrote:

> Hello Everyone,
>
> I seem to be having trouble with operator "new" not allocating enough 
> memory for FLTK objects.  Displaying the sizeof the objects in the 
> debugger returns the correct size, but printing the sizeof the objects 
> from within the program gives the wrong result (it matches the amount 
> of space that "new" allocates).  We are using the V4.6pre5 
> m68k-rtems-gcc compiler.  Is there something I could be doing wrong 
> that would cause the compiler to calculate the sizeof the object 
> incorrectly?
> #include <FL/Fl.H>
> #include <FL/Fl_Window.H>
> #include <FL/Fl_Box.H>
> #include <stdio.h>

I would need to see the class definitions (the headers)

>
> extern "C" void startupLCD(void);
> extern "C" void touchScreenInit(void);
> extern "C" int rtems_main(int argc, char **argv);
>
> int rtems_main(int argc, char **argv) {
>         Fl_Window *window = new Fl_Window(200,180);
>         Fl_Box *box = new Fl_Box(20,40,170,100,"Hello, World!");
>
>         printf( "Sizeof(Fl_Window) = (0x%X) %d bytes\n", 
> sizeof(Fl_Window), sizeof(Fl_Window) );
>         printf( "Sizeof(*window) = (0x%X) %d bytes\n", 
> sizeof(*window), sizeof(*window) );
>         printf( "Sizeof(Fl_Box) = (0x%X) %d bytes\n", sizeof(Fl_Box), 
> sizeof(Fl_Box) );
>         printf( "Sizeof(*box) = (0x%X) %d bytes\n", sizeof(*box), 
> sizeof(*box) );
>         printf( "Address of *window = (0x%X) %d\n", window,window );
>         printf( "Address of *box = (0x%X) %d\n", box,box );
>
>         startupLCD();
>         touchScreenInit();
>
>         box->box(FL_UP_BOX);
>         box->labelsize(36);
>         box->labelfont(FL_BOLD+FL_ITALIC);
>         //box->labeltype(FL_SHADOW_LABEL);
>         window->end();
>         window->show(argc, argv);
>         return Fl::run();
> }
>
>
>

-- 
Angelo Fraietta

PO Box 859
Hamilton NSW 2303

Home Page


http://www.users.bigpond.com/angelo_f/

There are those who seek knowledge for the sake of knowledge - that is CURIOSITY
There are those who seek knowledge to be known by others - that is VANITY
There are those who seek knowledge in order to serve - that is LOVE
    Bernard of Clairvaux (1090 - 1153)






More information about the users mailing list