GithubHelp home page GithubHelp logo

Comments (4)

GoogleCodeExporter avatar GoogleCodeExporter commented on June 8, 2024
The problem I see is that, in c++, allocating memory isn't typically enough: 
you also
need to construct/initialize it.  I agree with you: I've wanted a realloc 
equivalent
for a while.  But I don't see a principled way to do it in C++.

One piece of evidence that this is hard is that the original SGI Allocator
implementation included a realloc function, but the one that eventually made it 
out
into the world doesn't:
   http://www.sgi.com/tech/stl/alloc.html
   http://www.sgi.com/tech/stl/Allocators.html

One interesting note from this discussion:

"This is probably the most questionable design decision. It would have probably 
been
a bit more useful to provide a version of reallocate that either changed the 
size of
the existing object without copying or returned NULL. This would have made it
directly useful for objects with copy constructors. It would also have avoided
unnecessary copying in cases in which the original object had not been 
completely
filled in."

This is exactly the function you're arguing for.  So perhaps it *would* be 
useful for
STL.  But with the standard Allocator type not supporting this kind of realloc, 
I'm
not sure how people could use it effectively in their c++ programs.  I guess it 
would
take a lot of work.

Anyway, I'll definitely take it under consideration.  I don't like extending the
tcmalloc API too much beyond the standard API, but I agree that this 
functionality is
helpful for c++.

Original comment by [email protected] on 9 Jun 2009 at 5:56

  • Added labels: Priority-Low, Type-Enhancement

from gperftools.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 8, 2024
I am currently working with a number of other people, trying to flesh out a 
good basis for this. There has been a 
number of previous proposals on this issue, and it would be nice to try to take 
the best ideas from all these 
suggestions.

Original comment by [email protected] on 10 Jun 2009 at 3:32

from gperftools.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 8, 2024
Any more news on this?  We've introduced malloc_size(), which does something 
like what you want (it doesn't look for unallocated memory adjacent to existing 
memory, but it does indicate if the existing memory block is bigger than was 
asked for).  It may be the most practical solution.  If I don't hear back 
shortly, I'm going to close this WontFix (or maybe PartiallyFixed? :-) )

Original comment by [email protected] on 2 Aug 2010 at 4:51

from gperftools.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 8, 2024
I guess I defined "shortly" to be "a year" in this case. :-)  I'm closing 
WontFix, though PartiallyFixed would be more accurate.

Original comment by [email protected] on 31 Aug 2011 at 10:14

  • Changed state: WontFix

from gperftools.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.