Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(7173)

Issue 5794070: [google] Use delete with size parameter in STL deallocate

Can't Edit
Can't Publish+Mail
Start Review
Created:
12 years, 1 month ago by eraman
Modified:
9 years, 4 months ago
Reviewers:
davidxl, Ollie Wild
CC:
gcc-patches_gcc.gnu.org
Visibility:
Public.

Patch Set 1 #

Unified diffs Side-by-side diffs Delta from patch set Stats (+9 lines, -0 lines) Patch
M gcc/c-family/c-cppbuiltin.c View 1 chunk +2 lines, -0 lines 0 comments Download
M libstdc++-v3/include/ext/new_allocator.h View 1 chunk +7 lines, -0 lines 0 comments Download

Messages

Total messages: 3
eraman
This patch makes -fsized-delete define a macro __GXX_DELETE_WITH_SIZE__. If this macro is defined, the deallocate ...
12 years, 1 month ago (2012-03-13 01:03:49 UTC) #1
Ollie Wild
On Mon, Mar 12, 2012 at 8:03 PM, Easwaran Raman <eraman@google.com> wrote: > > OK ...
12 years, 1 month ago (2012-03-13 01:14:50 UTC) #2
davidxl
12 years, 1 month ago (2012-03-13 04:59:05 UTC) #3
ok. As Ollie said, it needs to be in google/gcc-4_7 as well.

David

On Mon, Mar 12, 2012 at 6:03 PM, Easwaran Raman <eraman@google.com> wrote:
> This patch makes -fsized-delete define a macro __GXX_DELETE_WITH_SIZE__. If
> this macro is defined, the deallocate function in new_allocator.h invokes
> the two parameter delete operator with the size of the object. Tested by
> bootstrapping the compiler and ensuring no tests are broken. Also verified
> that compiling a C++ program that uses std::vector with -fsized-delete invokes
> the two parameter version of operator delete.
>
> OK for google/main and google/4_6 branches?
>
> c-family/ChangeLog.google-main:
> 2012-03-12   Easwaran Raman  <eraman@google.com>
>
>        * c-cppbuiltin.c (c_cpp_builtins): Define __GXX_DELETE_WITH_SIZE__ for
>        C++ files compiled with -fsized-delete.
>
> libstdc++-v3/ChangeLog.google-main:
> 2012-03-12   Easwaran Raman  <eraman@google.com>
>        * include/ext/new_allocator.h (deallocate): Call delete with size if
>        __GXX_DELETE_WITH_SIZE__ is defined.
>
>
> diff --git a/gcc/c-family/c-cppbuiltin.c b/gcc/c-family/c-cppbuiltin.c
> index ccf57fd..3c9a96b 100644
> --- a/gcc/c-family/c-cppbuiltin.c
> +++ b/gcc/c-family/c-cppbuiltin.c
> @@ -970,6 +970,8 @@ c_cpp_builtins (cpp_reader *pfile)
>      format.  */
>   if (ENABLE_DECIMAL_FLOAT && ENABLE_DECIMAL_BID_FORMAT)
>     cpp_define (pfile, "__DECIMAL_BID_FORMAT__");
> +  if (c_dialect_cxx () && flag_sized_delete)
> +    cpp_define (pfile, "__GXX_DELETE_WITH_SIZE__");
>  }
>
>  /* Pass an object-like macro.  If it doesn't lie in the user's
> diff --git a/libstdc++-v3/include/ext/new_allocator.h
b/libstdc++-v3/include/ext/new_allocator.h
> index 0c82bd0..c972c1e 100644
> --- a/libstdc++-v3/include/ext/new_allocator.h
> +++ b/libstdc++-v3/include/ext/new_allocator.h
> @@ -94,10 +94,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
>        return static_cast<_Tp*>(::operator new(__n * sizeof(_Tp)));
>       }
>
> +#ifdef __GXX_DELETE_WITH_SIZE__
> +      // __p is not permitted to be a null pointer.
> +      void
> +      deallocate(pointer __p, size_type __t)
> +      { ::operator delete(__p, __t * sizeof(_Tp)); }
> +#else
>       // __p is not permitted to be a null pointer.
>       void
>       deallocate(pointer __p, size_type)
>       { ::operator delete(__p); }
> +#endif
>
>       size_type
>       max_size() const _GLIBCXX_USE_NOEXCEPT
>
> --
> This patch is available for review at http://codereview.appspot.com/5794070
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b