RE:stl, vector, unreasonable size

From: Masaharu Goto (MXJ02154@nifty.ne.jp)
Date: Thu Oct 07 1999 - 23:22:03 MEST


Christian,

I found a bug in cint header file. Please modify operatornew function in
$ROOTSYS/cint/include/new.h as follows.

   // work around ::operator new(size) 
   void* operatornew(size_t s) {
     return new char[s];
   }

The problem happens when you use interpreted STL container. The default
allocator uses operatornew and operatordelete function in this file.
The problem was that one side using malloc and the other delete. They
did not correspond.

Thank you
Masaharu Goto

>
>can you make this work?
>
>// test.C
>
>#include <vector.h>
>
>void main()
>{
>     TGMainFrame* w = new TGMainFrame( gClient->GetRoot(), 400, 400 );
>
>     TGLabel* l1 = new TGLabel(w, "hello");
>     TGLabel* l2 = new TGLabel(w, "goodbye");
>
>     vector<TGLabel*> v1;
>     v1.push_back( l1 );
>     v1.push_back( l2 );
>
>     w->AddFrame( l1,    new TGLayoutHints(kLHintsLeft,0,0,0,0) );
>     w->AddFrame( v1[1], new TGLayoutHints(kLHintsLeft,0,0,0,0) );
>
>     w->Resize( w->GetDefaultSize() );
>     w->MapSubwindows();
>     w->MapWindow();
>}
>
>
>cdfsg5$ root.exe
>  *******************************************
>  *                                         *
>  *        W E L C O M E  to  R O O T       *
>  *                                         *
>  *   Version   2.22/10     7 August 1999   *
>  *                                         *
>  *  You are welcome to visit our Web site  *
>  *          http://root.cern.ch            *
>  *                                         *
>  *******************************************
>
>FreeType Engine v1.1 used to render TrueType fonts.
>
>CINT/ROOT C/C++ Interpreter version 5.14.10, Jul 20 1999
>Type ? for help. Commands must be C++ statements.
>Enclose multiple statements between { }.
>set automatic variable allocation mode '0'
>root> .L test.C 
>root> main()    
>Fatal in <operator delete>: unreasonable size (86017)
>aborting
>Abort (core dumped)
>cdfsg5$ 
>



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:40 MET