Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8947567
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T12:47:48+00:00 2026-06-15T12:47:48+00:00

I found some places in visual studio headers where memory is freed via pointer

  • 0

I found some places in visual studio headers where memory is freed via pointer to void.

xlocnum file:

template<class _Elem>
     class numpunct
            : public locale::facet
    { 
     _PROTECTED:
     _VIRTUAL __CLR_OR_THIS_CALL ~numpunct()
     {       // destroy the object
         _Tidy();
     }
     ...
     protected:
        void __CLR_OR_THIS_CALL _Init(const _Locinfo& _Lobj)
        {       // initialize from _Lobj
            _Grouping = 0;
            _Falsename = 0;
            _Truename = 0;

            _TRY_BEGIN
            _Grouping = _MAKLOCSTR(char, _Ptr->grouping, _Lobj._Getcvt());
            _Falsename = _MAKLOCSTR(_Elem, _Lobj._Getfalse(), _Lobj._Getcvt());
            _Truename = _MAKLOCSTR(_Elem, _Lobj._Gettrue(), _Lobj._Getcvt());
            _CATCH_ALL
            _Tidy();
            _RERAISE;
            _CATCH_END
             ...
            }
      ...
      private:
      void __CLR_OR_THIS_CALL _Tidy()
      {       // free all storage
         _DELETE_CRT_VEC((void *)_Grouping);
         _DELETE_CRT_VEC((void *)_Falsename);
         _DELETE_CRT_VEC((void *)_Truename);
      }
    ... 
    const char *_Grouping;  // grouping string, "" for "C" locale
    const _Elem *_Falsename;// name for false, "false" for "C" locale
    const _Elem *_Truename; // name for true, "true" for "C" locale
    };

or another one example in xlocale:

template<> class _CRTIMP2_PURE ctype<char>
    : public ctype_base
    {
       public:
          explicit __CLR_OR_THIS_CALL ctype(const mask *_Table = 0,
              bool _Deletetable = false,
              size_t _Refs = 0)
              : ctype_base(_Refs)
                {       // construct with specified table and delete flag for table
                   ...
                   if (_Table != 0)
                   {       // replace existing char to mask table
                       _Tidy();
                       _Ctype._Table = _Table;
                       _Ctype._Delfl = _Deletetable ? -1 : 0;
                   }
                }
        protected:
           void __CLR_OR_THIS_CALL _Tidy()
           {       // free any allocated storage
              if (0 < _Ctype._Delfl)
                   free((void *)_Ctype._Table);
              else if (_Ctype._Delfl < 0)
                    delete[] (void *)_Ctype._Table;
            }
    }

As were noted at https://stackoverflow.com/a/941959/1549256 deleting via a void pointer is undefined by the C++ Standard.

Why is it correct to free memrory in such cases?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T12:47:49+00:00Added an answer on June 15, 2026 at 12:47 pm

    The code in the standard library implementation does not have to conform to the language definition. It can take advantage of knowledge of the implementation; that’s why it comes with the compiler.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was refactoring some code and found there are two places that can be
I found some mapkit code on the internet that looks like this: - (void)recenterMap
I've found some places on the web saying that operators in Lua are overloadable
I recently created a (C#) project with Visual Studio (2010) and used some Settings
I browsed around here on Stackoverflow and found this topic : https://stackoverflow.com/questions/279/aspnet-visual-studio-and-subversion-how-to-integrate However that
i'm hoping to find some add-ons for Visual Studio to address some specific usability
I have found some places that mention window messages are returned by GetMessage in
I found some lovely websites - http://www.mini.jp/event_campaign/big-point/ , http://www.twenty8twelve.com/ and http://www.scozzese.com - all vertical
I found some problems when implementing Jake Wharton 's ViewPagerIndicator . These are what
I found some things I want to submit a pull request for in the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.