<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[delete[] --&amp;gt; Segmentation Fault?]]></title><description><![CDATA[<p>Hi everyone</p>
<p>Im Moment beschäftige ich mich gerade mit der Serialisierung von boost, genau genommen mit folgendem Code:</p>
<pre><code class="language-cpp">#include &lt;boost/assign/list_of.hpp&gt;
#include &lt;boost/archive/xml_oarchive.hpp&gt;
#include &lt;fstream&gt;
#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;vector&gt;

using namespace boost;
using namespace boost::assign;
using namespace std;

class Meter {
public:
	Meter(string address, vector&lt;string&gt; names, bool isCool, unsigned int theNum) :
		address(address), names(names), isCool(isCool), theNum(theNum) {
	}
private:
	string address;
	vector&lt;string&gt; names;
	bool isCool;
	unsigned int theNum;

	friend class serialization::access;
	template&lt;class archive&gt; void serialize(archive&amp; ar,
			const unsigned int version) {
		using serialization::make_nvp;
		ar &amp; make_nvp(&quot;Address&quot;, address);
		//ar &amp; make_nvp(&quot;Names&quot;, names);
		ar &amp; make_nvp(&quot;IsCool&quot;, isCool);
		ar &amp; make_nvp(&quot;TheNumber&quot;, theNum);
	}
};

int main(void) {
	Meter m1(&quot;8872JFKP&quot;, list_of(&quot;Meter1&quot;)(&quot;ZLMN22&quot;)(&quot;ThaMeeetaa&quot;), true, 88);

	ofstream ofs(&quot;testIt.xml&quot;);
	archive::xml_oarchive xml(ofs);
	xml &lt;&lt; serialization::make_nvp(&quot;Meter&quot;, m1);

	return 0;
}
</code></pre>
<p>Ich habe das so für meinen Windows-Rechner kompiliert - kein Problem, die XML-Datei wird erstellt und das Objekt korrekt serialisiert. Ende der Geschichte.</p>
<p>Nun muss das Ganze allerdings nicht auf besagtem Rechner, sondern auf einem Linux-Embedded Computer ablaufen. Also alles noch 'mal fix mit dem Cross-Plattform Compiler kompiliert (komplett ohne Fehler und Warnungen, bei dem Ding eine Seltenheit <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /> ) und auf den kleinen Kasten kopiert. *Booom*! Segmentation Fault...</p>
<p>Ich habe mit dem Debugger nachgesehen, wo da wohl der Hund begraben liegen könnte, und das Problem auf eine einzige Zeile in der Standard C++ Datei locale_classes.h isolieren können:</p>
<pre><code class="language-cpp">// Implementation object for locale 
  class locale::_Impl
  {
  public:
    // Friends.
    friend class locale;
    friend class locale::facet;
  // ...
  private:
  // ...
    char* 				_M_names[_S_categories_size
						 + _S_extra_categories_size];
  // ...

  };

  // ...

  template&lt;typename _Facet&gt;
    locale::locale(const locale&amp; __other, _Facet* __f)
    {
      _M_impl = new _Impl(*__other._M_impl, 1);
      _M_impl-&gt;_M_install_facet(&amp;_Facet::id, __f);
      for (size_t __i = 0; 
	   __i &lt; _S_categories_size + _S_extra_categories_size; ++__i)
		{
		  delete [] _M_impl-&gt;_M_names[__i];
		  char* __new = new char[2];
		  strcpy(__new, &quot;*&quot;);
		  _M_impl-&gt;_M_names[__i] = __new;
		}
    }
</code></pre>
<p>Gemeint ist die Zeile <strong>delete [] _M_impl-&gt;_M_names[__i];</strong>. Genau dabei crasht das Programm auf der Zielplattform. Kommentiere ich die Zeile aus, läuft das Ding wie geschmiert.</p>
<p>Als geplagter Programmierer schwirrt mir dabei aber sofort das unschöne Wort &quot;Memory Leak&quot; durch den Kopf - denn aus irgendeinem Grund steht diese Zeile wohl da <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /> . Allerdings kann ich diesen nicht auf den ersten Blick erkennen, denn im Debugger zeigen alle char-Pointer auf ein und denselben Punkt irgendwo im Speicher - vermutlich irgend ein Standard-Wert, denn die Dinger können ja schlecht initialisiert sein: _M_impl wurde gerade erst in dieser Funktion mit new erstellt und _M_install_facet scheint sich ebenfalls nicht an diesem Array von Char-Pointern zu schaffen zu machen.</p>
<p>&quot;Scheint&quot; wohlgemerkt, denn dessen Code kann ich mir ja vermutlich nicht mehr ansehen, der wird schon fixfertig als Library kompiliert sein.</p>
<p>Deshalb meine Frage an euch: Kennt jemand diese Library genauer? Führt meine Änderung früher oder später zu einem Memory Leak? Und kann ich das delete[]-Problem evtl. mit einem try-catch umgehen oder soll ich es auskommentiert lassen?</p>
<p>Thx für jede Antwort und greeetz<br />
Kessi</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/196875/delete-gt-segmentation-fault</link><generator>RSS for Node</generator><lastBuildDate>Wed, 30 Sep 2026 18:27:11 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/196875.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 03 Nov 2007 22:57:15 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to delete[] --&amp;gt; Segmentation Fault? on Sat, 03 Nov 2007 22:57:15 GMT]]></title><description><![CDATA[<p>Hi everyone</p>
<p>Im Moment beschäftige ich mich gerade mit der Serialisierung von boost, genau genommen mit folgendem Code:</p>
<pre><code class="language-cpp">#include &lt;boost/assign/list_of.hpp&gt;
#include &lt;boost/archive/xml_oarchive.hpp&gt;
#include &lt;fstream&gt;
#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;vector&gt;

using namespace boost;
using namespace boost::assign;
using namespace std;

class Meter {
public:
	Meter(string address, vector&lt;string&gt; names, bool isCool, unsigned int theNum) :
		address(address), names(names), isCool(isCool), theNum(theNum) {
	}
private:
	string address;
	vector&lt;string&gt; names;
	bool isCool;
	unsigned int theNum;

	friend class serialization::access;
	template&lt;class archive&gt; void serialize(archive&amp; ar,
			const unsigned int version) {
		using serialization::make_nvp;
		ar &amp; make_nvp(&quot;Address&quot;, address);
		//ar &amp; make_nvp(&quot;Names&quot;, names);
		ar &amp; make_nvp(&quot;IsCool&quot;, isCool);
		ar &amp; make_nvp(&quot;TheNumber&quot;, theNum);
	}
};

int main(void) {
	Meter m1(&quot;8872JFKP&quot;, list_of(&quot;Meter1&quot;)(&quot;ZLMN22&quot;)(&quot;ThaMeeetaa&quot;), true, 88);

	ofstream ofs(&quot;testIt.xml&quot;);
	archive::xml_oarchive xml(ofs);
	xml &lt;&lt; serialization::make_nvp(&quot;Meter&quot;, m1);

	return 0;
}
</code></pre>
<p>Ich habe das so für meinen Windows-Rechner kompiliert - kein Problem, die XML-Datei wird erstellt und das Objekt korrekt serialisiert. Ende der Geschichte.</p>
<p>Nun muss das Ganze allerdings nicht auf besagtem Rechner, sondern auf einem Linux-Embedded Computer ablaufen. Also alles noch 'mal fix mit dem Cross-Plattform Compiler kompiliert (komplett ohne Fehler und Warnungen, bei dem Ding eine Seltenheit <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /> ) und auf den kleinen Kasten kopiert. *Booom*! Segmentation Fault...</p>
<p>Ich habe mit dem Debugger nachgesehen, wo da wohl der Hund begraben liegen könnte, und das Problem auf eine einzige Zeile in der Standard C++ Datei locale_classes.h isolieren können:</p>
<pre><code class="language-cpp">// Implementation object for locale 
  class locale::_Impl
  {
  public:
    // Friends.
    friend class locale;
    friend class locale::facet;
  // ...
  private:
  // ...
    char* 				_M_names[_S_categories_size
						 + _S_extra_categories_size];
  // ...

  };

  // ...

  template&lt;typename _Facet&gt;
    locale::locale(const locale&amp; __other, _Facet* __f)
    {
      _M_impl = new _Impl(*__other._M_impl, 1);
      _M_impl-&gt;_M_install_facet(&amp;_Facet::id, __f);
      for (size_t __i = 0; 
	   __i &lt; _S_categories_size + _S_extra_categories_size; ++__i)
		{
		  delete [] _M_impl-&gt;_M_names[__i];
		  char* __new = new char[2];
		  strcpy(__new, &quot;*&quot;);
		  _M_impl-&gt;_M_names[__i] = __new;
		}
    }
</code></pre>
<p>Gemeint ist die Zeile <strong>delete [] _M_impl-&gt;_M_names[__i];</strong>. Genau dabei crasht das Programm auf der Zielplattform. Kommentiere ich die Zeile aus, läuft das Ding wie geschmiert.</p>
<p>Als geplagter Programmierer schwirrt mir dabei aber sofort das unschöne Wort &quot;Memory Leak&quot; durch den Kopf - denn aus irgendeinem Grund steht diese Zeile wohl da <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /> . Allerdings kann ich diesen nicht auf den ersten Blick erkennen, denn im Debugger zeigen alle char-Pointer auf ein und denselben Punkt irgendwo im Speicher - vermutlich irgend ein Standard-Wert, denn die Dinger können ja schlecht initialisiert sein: _M_impl wurde gerade erst in dieser Funktion mit new erstellt und _M_install_facet scheint sich ebenfalls nicht an diesem Array von Char-Pointern zu schaffen zu machen.</p>
<p>&quot;Scheint&quot; wohlgemerkt, denn dessen Code kann ich mir ja vermutlich nicht mehr ansehen, der wird schon fixfertig als Library kompiliert sein.</p>
<p>Deshalb meine Frage an euch: Kennt jemand diese Library genauer? Führt meine Änderung früher oder später zu einem Memory Leak? Und kann ich das delete[]-Problem evtl. mit einem try-catch umgehen oder soll ich es auskommentiert lassen?</p>
<p>Thx für jede Antwort und greeetz<br />
Kessi</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1397268</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1397268</guid><dc:creator><![CDATA[KessiMC]]></dc:creator><pubDate>Sat, 03 Nov 2007 22:57:15 GMT</pubDate></item><item><title><![CDATA[Reply to delete[] --&amp;gt; Segmentation Fault? on Sat, 03 Nov 2007 23:06:50 GMT]]></title><description><![CDATA[<p>wie sehen den die Konstruktoren von locale::_Impl aus?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1397272</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1397272</guid><dc:creator><![CDATA[camper]]></dc:creator><pubDate>Sat, 03 Nov 2007 23:06:50 GMT</pubDate></item><item><title><![CDATA[Reply to delete[] --&amp;gt; Segmentation Fault? on Sat, 03 Nov 2007 23:25:45 GMT]]></title><description><![CDATA[<p>Im Header leider nur deklariert:</p>
<pre><code class="language-cpp">_Impl(const _Impl&amp;, size_t);
</code></pre>
<p>Habe kein passendes cpp-File dazu gefunden und im Debugger war ebenfalls nichts zu sehen (zugehörige library wurde vermutlich eh ohne Debug-Info kompiliert <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /> ) ...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1397279</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1397279</guid><dc:creator><![CDATA[KessiMC]]></dc:creator><pubDate>Sat, 03 Nov 2007 23:25:45 GMT</pubDate></item><item><title><![CDATA[Reply to delete[] --&amp;gt; Segmentation Fault? on Sun, 04 Nov 2007 20:27:35 GMT]]></title><description><![CDATA[<p>Habe jetzt auch 'mal ein bisschen gegoogelt, trotzdem konnte ich die zugehörige Implementation nicht ausmachen.</p>
<p>Gibt es eine Möglichkeit, die Pointer auf Gültigkeit zu überprüfen oder das Fehlschlagen des delete[] mit einem try-catch abzusichern?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1397739</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1397739</guid><dc:creator><![CDATA[KessiMC]]></dc:creator><pubDate>Sun, 04 Nov 2007 20:27:35 GMT</pubDate></item><item><title><![CDATA[Reply to delete[] --&amp;gt; Segmentation Fault? on Sun, 04 Nov 2007 20:39:32 GMT]]></title><description><![CDATA[<p>Wie sehen denn die anderen Konstruktoren (insbesondere der Defaultkonstruktor) von locale aus?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1397747</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1397747</guid><dc:creator><![CDATA[camper]]></dc:creator><pubDate>Sun, 04 Nov 2007 20:39:32 GMT</pubDate></item><item><title><![CDATA[Reply to delete[] --&amp;gt; Segmentation Fault? on Sun, 04 Nov 2007 20:48:36 GMT]]></title><description><![CDATA[<p>Im Header-File gibt es nur den einen Konstruktor von locale...</p>
<p>Hier ist das ganze File:</p>
<pre><code>// Locale support -*- C++ -*-

// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library.  This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2, or (at your option)
// any later version.

// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING.  If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.

// As a special exception, you may use this file as part of a free software
// library without restriction.  Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License.  This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.

//
// ISO C++ 14882: 22.1  Locales
//

/** @file localefwd.h
 *  This is an internal header file, included by other library headers.
 *  You should not attempt to use it directly.
 */

#ifndef _CPP_BITS_LOCALE_CLASSES_H
#define _CPP_BITS_LOCALE_CLASSES_H	1

#pragma GCC system_header

#include &lt;bits/localefwd.h&gt;
#include &lt;cstring&gt;		// For strcmp.
#include &lt;string&gt;
#include &lt;bits/atomicity.h&gt;

namespace std
{
  class __locale_cache_base;
  template&lt;typename _Facet&gt; class __locale_cache;

  // 22.1.1 Class locale
  class locale
  {
  public:
    // Types:
    typedef unsigned int 	category;

    // Forward decls and friends:
    class facet;
    class id;
    class _Impl;

    friend class facet;
    friend class _Impl;

    template&lt;typename _Facet&gt;
      friend const _Facet&amp; 
      use_facet(const locale&amp;);

    template&lt;typename _Facet&gt;
      friend bool 
      has_facet(const locale&amp;) throw();

    template&lt;typename _Facet&gt;
      friend const __locale_cache&lt;_Facet&gt;&amp;
      __use_cache(const locale&amp;);

    // Category values:
    // NB: Order must match _S_facet_categories definition in locale.cc
    static const category none		= 0;
    static const category ctype 	= 1L &lt;&lt; 0;
    static const category numeric 	= 1L &lt;&lt; 1;
    static const category collate  	= 1L &lt;&lt; 2;
    static const category time 		= 1L &lt;&lt; 3;
    static const category monetary 	= 1L &lt;&lt; 4;
    static const category messages 	= 1L &lt;&lt; 5;
    static const category all 		= (ctype | numeric | collate |
				 	   time  | monetary | messages);

    // Construct/copy/destroy:
    locale() throw();

    locale(const locale&amp; __other) throw();

    explicit  
    locale(const char* __s);

    locale(const locale&amp; __base, const char* __s, category __cat);

    locale(const locale&amp; __base, const locale&amp; __add, category __cat);

    template&lt;typename _Facet&gt;
      locale(const locale&amp; __other, _Facet* __f);

    ~locale() throw();

    const locale&amp;  
    operator=(const locale&amp; __other) throw();

    template&lt;typename _Facet&gt;
      locale  
      combine(const locale&amp; __other) const;

    // Locale operations:
    string 
    name() const;

    bool 
    operator==(const locale&amp; __other) const throw ();

    inline bool  
    operator!=(const locale&amp; __other) const throw ()
    { return !(this-&gt;operator==(__other));  }

    template&lt;typename _Char, typename _Traits, typename _Alloc&gt;
      bool  
      operator()(const basic_string&lt;_Char, _Traits, _Alloc&gt;&amp; __s1,
		 const basic_string&lt;_Char, _Traits, _Alloc&gt;&amp; __s2) const;

    // Global locale objects:
    static locale 
    global(const locale&amp;);

    static const locale&amp; 
    classic();

  private:
    // The (shared) implementation
    _Impl* 		_M_impl;  

    // The &quot;C&quot; reference locale
    static _Impl* 	_S_classic; 

    // Current global locale
    static _Impl* 	_S_global;  

    // Number of standard categories. For C++, these categories are
    // collate, ctype, monetary, numeric, time, and messages. These
    // directly correspond to ISO C99 macros LC_COLLATE, LC_CTYPE,
    // LC_MONETARY, LC_NUMERIC, and LC_TIME. In addition, POSIX (IEEE
    // 1003.1-2001) specifies LC_MESSAGES.
    static const size_t	_S_categories_size = 6;

    // In addition to the standard categories, the underlying
    // operating system is allowed to define extra LC_*
    // macros. For GNU systems, the following are also valid:
    // LC_PAPER, LC_NAME, LC_ADDRESS, LC_TELEPHONE, LC_MEASUREMENT,
    // and LC_IDENTIFICATION.
    static const size_t	_S_extra_categories_size = _GLIBCPP_NUM_CATEGORIES;

    // Names of underlying locale categories.  
    // NB: locale::global() has to know how to modify all the
    // underlying categories, not just the ones required by the C++
    // standard.
    static const char* 	_S_categories[_S_categories_size 
				      + _S_extra_categories_size];

    explicit 
    locale(_Impl*) throw();

    static inline void  
    _S_initialize()
    { 
      if (!_S_classic) 
	classic();  
    }

    static category  
    _S_normalize_category(category);

    void
    _M_coalesce(const locale&amp; __base, const locale&amp; __add, category __cat);
  };

  // Implementation object for locale 
  class locale::_Impl
  {
  public:
    // Friends.
    friend class locale;
    friend class locale::facet;

    template&lt;typename _Facet&gt;
      friend const _Facet&amp;  
      use_facet(const locale&amp;);

    template&lt;typename _Facet&gt;
      friend bool  
      has_facet(const locale&amp;) throw();

    template&lt;typename _Facet&gt;
      friend const __locale_cache&lt;_Facet&gt;&amp;
      __use_cache(const locale&amp;);

  private:
    // Data Members.
    _Atomic_word			_M_references;
    facet** 				_M_facets;
    size_t 				_M_facets_size;

    char* 				_M_names[_S_categories_size
						 + _S_extra_categories_size];
    static const locale::id* const 	_S_id_ctype[];
    static const locale::id* const 	_S_id_numeric[];
    static const locale::id* const 	_S_id_collate[];
    static const locale::id* const 	_S_id_time[];
    static const locale::id* const 	_S_id_monetary[];
    static const locale::id* const 	_S_id_messages[];
    static const locale::id* const* const _S_facet_categories[];

    inline void 
    _M_add_reference() throw()
    { __atomic_add(&amp;_M_references, 1); }

    inline void 
    _M_remove_reference() throw()
    {
      if (__exchange_and_add(&amp;_M_references, -1) == 1)
	{
	  try 
	    { delete this; } 
	  catch(...) 
	    { }
	}
    }

    _Impl(const _Impl&amp;, size_t);
    _Impl(const char*, size_t);
    _Impl(facet**, size_t, bool);

   ~_Impl() throw();

    _Impl(const _Impl&amp;);  // Not defined.

    void 
    operator=(const _Impl&amp;);  // Not defined.

    inline bool
    _M_check_same_name()
    {
      bool __ret = true;
      for (size_t __i = 0; 
	   __ret &amp;&amp; __i &lt; _S_categories_size + _S_extra_categories_size - 1; 
	   ++__i)
	__ret &amp;= (strcmp(_M_names[__i], _M_names[__i + 1]) == 0);
      return __ret;
    }

    void 
    _M_replace_categories(const _Impl*, category);

    void 
    _M_replace_category(const _Impl*, const locale::id* const*);

    void 
    _M_replace_facet(const _Impl*, const locale::id*);

    void 
    _M_install_facet(const locale::id*, facet*);

    template&lt;typename _Facet&gt;
      inline void 
      _M_init_facet(_Facet* __facet)
      { _M_install_facet(&amp;_Facet::id, __facet);  }

    // Retrieve the cache at __index.  0 is returned if the cache is
    // missing.  Cache is actually located at __index +
    // _M_facets_size.  __index must be &lt; _M_facets_size.
    inline __locale_cache_base*
      _M_get_cache(size_t __index)
      {
	return (__locale_cache_base*)_M_facets[__index + _M_facets_size];
      }

    // Save the supplied cache at __id.  Assumes _M_get_cache has been
    // called.
    void
    _M_install_cache(__locale_cache_base* __cache, int __id)
    {
      _M_facets[__id + _M_facets_size] = 
	reinterpret_cast&lt;locale::facet*&gt;(__cache);
    }

  };

  template&lt;typename _Facet&gt;
    locale::locale(const locale&amp; __other, _Facet* __f)
    {
      _M_impl = new _Impl(*__other._M_impl, 1);
      _M_impl-&gt;_M_install_facet(&amp;_Facet::id, __f);
      for (size_t __i = 0; 
	   __i &lt; _S_categories_size + _S_extra_categories_size; ++__i)
	{
	  // delete [] _M_impl-&gt;_M_names[__i];
	  char* __new = new char[2];
	  strcpy(__new, &quot;*&quot;);
	  _M_impl-&gt;_M_names[__i] = __new;
	}
    }

  // 22.1.1.1.2  Class locale::facet
  class locale::facet
  {
  private:
    friend class locale;
    friend class locale::_Impl;

    _Atomic_word 			_M_references;

  protected:
    // Contains data from the underlying &quot;C&quot; library for the classic locale.
    static __c_locale		     	_S_c_locale;

    // String literal for the name of the classic locale.
    static char				_S_c_name[2];

    explicit 
    facet(size_t __refs = 0) throw();

    virtual 
    ~facet();

    static void
    _S_create_c_locale(__c_locale&amp; __cloc, const char* __s, 
		       __c_locale __old = 0);

    static __c_locale
    _S_clone_c_locale(__c_locale&amp; __cloc);

    static void
    _S_destroy_c_locale(__c_locale&amp; __cloc);

  private:
    void 
    _M_add_reference() throw();

    void 
    _M_remove_reference() throw();

    facet(const facet&amp;);  // Not defined.

    void 
    operator=(const facet&amp;);  // Not defined.
  };

  // 22.1.1.1.3 Class locale::id
  class locale::id
  {
  private:
    friend class locale;
    friend class locale::_Impl;
    template&lt;typename _Facet&gt;
      friend const _Facet&amp;  
      use_facet(const locale&amp;);
    template&lt;typename _Facet&gt;
      friend bool           
      has_facet(const locale&amp;) throw ();

    // NB: There is no accessor for _M_index because it may be used
    // before the constructor is run; the effect of calling a member
    // function (even an inline) would be undefined.
    mutable size_t 		_M_index;

    // Last id number assigned.
    static _Atomic_word 	_S_highwater;   

    void 
    operator=(const id&amp;);  // Not defined.

    id(const id&amp;);  // Not defined.

  public:
    // NB: This class is always a static data member, and thus can be
    // counted on to be zero-initialized.
    id();

    inline size_t
    _M_id() const
    {
      if (!_M_index)
	_M_index = 1 + __exchange_and_add(&amp;_S_highwater, 1);
      return _M_index - 1;
    }
  };
} // namespace std

#endif
</code></pre>
<p>Hier habe ich das delete[] übrigens bereits ausgeklammert <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
<p>Thx &amp; Greeetz<br />
Kessi</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1397759</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1397759</guid><dc:creator><![CDATA[KessiMC]]></dc:creator><pubDate>Sun, 04 Nov 2007 20:48:36 GMT</pubDate></item></channel></rss>