What are the main differences between malloc provided by libc and std::malloc?

孙世龙 sunshilong sunshilong369@gmail.com
Wed Aug 12 09:13:42 GMT 2020


Thank you for taking the time to respond to my question.

>Where do you get std:malloc?  If it's from GCC's libstdc++, there are
>no differents.  It's the same function.
Yes, GCC's libstdc++.

Thank you for your help.
With your guidance, I find the related code snippets and comments:

/** @file include/cstdlib
 *  This is a Standard C++ Library file.  You should @c #include this file
 *  in your programs, rather than any of the @a *.h implementation files.
 *
 *  This is the C++ version of the Standard C Library header @c stdlib.h,
 *  and its contents are (mostly) the same as that header, but are all
 *  contained in the namespace @c std (except for names which are defined
 *  as macros in C).
 */

#undef free
#undef malloc
#undef realloc

namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
  ...
  using ::free;
  ...
  using ::malloc;
  ...
  using ::realloc;
}



---------- Forwarded message ---------
From: Florian Weimer <fw@deneb.enyo.de>
Date: Wed, Aug 12, 2020 at 3:55 PM
Subject: Re: What are the main differences between malloc provided by
libc and std::malloc?
To: 孙世龙 sunshilong via Libc-help <libc-help@sourceware.org>
Cc: 孙世龙 sunshilong <sunshilong369@gmail.com>


* 孙世龙 sunshilong via Libc-help:

> What are the main differences between malloc provided by libc and
> std::malloc?

Where do you get std:malloc?  If it's from GCC's libstdc++, there are
no differents.  It's the same function.

On Wed, Aug 12, 2020 at 3:55 PM Florian Weimer <fw@deneb.enyo.de> wrote:
>
> * 孙世龙 sunshilong via Libc-help:
>
> > What are the main differences between malloc provided by libc and
> > std::malloc?
>
> Where do you get std:malloc?  If it's from GCC's libstdc++, there are
> no differents.  It's the same function.


More information about the Libc-help mailing list