197403Sobrien// Boilerplate support routines for -*- C++ -*- dynamic memory management.
297403Sobrien
3169691Skan// Copyright (C) 1997, 1998, 1999, 2000, 2004 Free Software Foundation
497403Sobrien//
5132720Skan// This file is part of GCC.
697403Sobrien//
7132720Skan// GCC is free software; you can redistribute it and/or modify
897403Sobrien// it under the terms of the GNU General Public License as published by
997403Sobrien// the Free Software Foundation; either version 2, or (at your option)
1097403Sobrien// any later version.
1197403Sobrien//
12132720Skan// GCC is distributed in the hope that it will be useful,
1397403Sobrien// but WITHOUT ANY WARRANTY; without even the implied warranty of
1497403Sobrien// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1597403Sobrien// GNU General Public License for more details.
1697403Sobrien//
1797403Sobrien// You should have received a copy of the GNU General Public License
18132720Skan// along with GCC; see the file COPYING.  If not, write to
19169691Skan// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
20169691Skan// Boston, MA 02110-1301, USA.
2197403Sobrien//
2297403Sobrien// As a special exception, you may use this file as part of a free software
2397403Sobrien// library without restriction.  Specifically, if other files instantiate
2497403Sobrien// templates or use macros or inline functions from this file, or you compile
2597403Sobrien// this file and link it with other files to produce an executable, this
2697403Sobrien// file does not by itself cause the resulting executable to be covered by
2797403Sobrien// the GNU General Public License.  This exception does not however
2897403Sobrien// invalidate any other reasons why the executable file might be covered by
2997403Sobrien// the GNU General Public License.
3097403Sobrien
31169691Skan#include <bits/c++config.h>
3297403Sobrien#include "new"
33169691Skan#if _GLIBCXX_HOSTED
34169691Skan#include <cstdlib>
35169691Skan#endif
3697403Sobrien
37169691Skan#if _GLIBCXX_HOSTED
38169691Skanusing std::free;
39169691Skan#else
40169691Skan// A freestanding C runtime may not provide "free" -- but there is no
41169691Skan// other reasonable way to implement "operator delete".
42169691Skanextern "C" void free(void *);
43169691Skan#endif
4497403Sobrien
45169691Skan_GLIBCXX_WEAK_DEFINITION void
4697403Sobrienoperator delete (void *ptr) throw ()
4797403Sobrien{
4897403Sobrien  if (ptr)
4997403Sobrien    free (ptr);
5097403Sobrien}
51