home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.c++.moderated      Moderated discussion of C++ superhackery      33,346 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 32,681 of 33,346   
   Francis Glassborow to All   
   Re: A new realloc() proposal   
   23 Nov 12 12:59:08   
   
   From: francis.glassborow@btinternet.com   
      
   On 23/11/2012 06:25, fmatthew5876 wrote:   
   > { Please limit your text to fit within 80 columns, preferably around 70,   
   >    so that readers don't have to scroll horizontally to read each line.   
   >    This article has been reformatted manually by the moderator. -mod }   
   >   
   >   
   > realloc() has a lot of problems:   
   >   
   > * It tries to do too many things, malloc, free, and reallocate in place   
   > * It doesn't work with C++ classes that need to be copy constructed when   
   >    moved. It also doesn't work for any kind of C/C++ classes or structs   
   >    that have internal pointers. This means all generic C++ containers have   
   >    to do expensive copies on resize when they may not be necessary.   
      
      
   Please avoid over-stating your case. The only a few of generic container   
   classes relocate. In the Standard library that is limited to vector and   
   adaptors that have vector as an underlying container.   
      
   In practice move ctors have largely removed the costs of re-allcation   
   for an extensive subset of possible case.   
      
   Note that realloc even in C  has always been a dangerous function in the   
   hands of the inexperienced exactly because of the problem of internal   
   pointers.   
      
   My gut reaction is that your suggestion has insufficient potential   
   benefit for the cost of refining and standardising it. However this is   
   not the right newsgroup in which to deal with changes to C++. You need   
   to post it to comp.std.c++   
      
      
   --   
         [ See http://www.gotw.ca/resources/clcm.htm for info about ]   
         [ comp.lang.c++.moderated.    First time posters: Do this! ]   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca