This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Patch to replace malloc() with new in V3


Attached is a patch to replace use of malloc()/free()  in the library with 
new/delete (where appropriate).

I took the liberty of converting _Temporary_buffer to wrap 
std::get_temporary_buffer()/std::return_temporary_buffer() instead of 
reimplementing the same algorithm twice in two places redundantly twice.

Using new/delete instead of malloc/free consistently in library code makes 
instrumenting allocation tracing and allocation performance tweaking easier.  

Tested using gcc version 3.4 20031114 (experimental) on Xandros Linux 2.4.22.

The partition.cc test in 25_algorithms exercises the _Temporary_buffer mods, 
and therefore the std_memory mods.

Here's a changelog entry:

2003-11-14	Stephen M. Webb <stephen.webb@bregmasoft.com>

  * config/local/generic/c_locale.h: Changed ::malloc() to new char[].
  * config/local/gnu/c_locale.h: Changed ::malloc() to new char[].
  * include/bits/stl_tempbuf.h: Converted _Temporary_buffer to use
    std::get_temporary_buffer() instead of duplicating its code.
    Update to C++STYLE conventions.
  * include/std/std_memory.h: (get_temporary_buffer) used ::operator new()
    instead of std::malloc().
    (return_temporary_buffer) used ::operator delete() instead of std::free().


-- 
Stephen M. Webb
stephen.webb@bregmasoft.com

Attachment: diff.txt
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]