<commit_before>/*=========================================================================

  Program:   Visualization Toolkit
  Module:    vtkFilteringInformationKeyManager.cxx

  Copyright (c) <NAME>, <NAME>, <NAME>
  All rights reserved.
  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notice for more information.

=========================================================================*/
#include "vtkFilteringInformationKeyManager.h"

#include "vtkInformationKey.h"

#include <vtkstd/vector>

//----------------------------------------------------------------------------
// Must NOT be initialized.  Default initialization to zero is
// necessary.
unsigned int vtkFilteringInformationKeyManagerCount;
vtkstd::vector<vtkInformationKey*>* vtkFilteringInformationKeyManagerKeys;

//----------------------------------------------------------------------------
vtkFilteringInformationKeyManager::vtkFilteringInformationKeyManager()
{
  if(++vtkFilteringInformationKeyManagerCount == 1)
    {
    vtkFilteringInformationKeyManager::ClassInitialize();
    }
}

//----------------------------------------------------------------------------
vtkFilteringInformationKeyManager::~vtkFilteringInformationKeyManager()
{
  if(--vtkFilteringInformationKeyManagerCount == 0)
    {
    vtkFilteringInformationKeyManager::ClassFinalize();
    }
}

//----------------------------------------------------------------------------
void vtkFilteringInformationKeyManager::Register(vtkInformationKey* key)
{
  // Register this instance for deletion by the singleton.
  vtkFilteringInformationKeyManagerKeys->push_back(key);
}

//----------------------------------------------------------------------------
void vtkFilteringInformationKeyManager::ClassInitialize()
{
  // Allocate the singleton storing pointers to information keys.
  // This must be a malloc/free pair instead of new/delete to work
  // around problems on MachO (Mac OSX) runtime systems that do lazy
  // symbol loading.  Calling operator new here causes static
  // initialization to occur in other translation units immediately,
  // which then may try to access the vector before it is set here.
  void* keys = malloc(sizeof(vtkstd::vector<vtkInformationKey*>));
  vtkFilteringInformationKeyManagerKeys =
    new (keys) vtkstd::vector<vtkInformationKey*>;
}

//----------------------------------------------------------------------------
void vtkFilteringInformationKeyManager::ClassFinalize()
{
  if(vtkFilteringInformationKeyManagerKeys)
    {
    // Delete information keys.
    for(vtkstd::vector<vtkInformationKey*>::iterator i =
          vtkFilteringInformationKeyManagerKeys->begin();
        i != vtkFilteringInformationKeyManagerKeys->end(); ++i)
      {
      vtkInformationKey* key = *i;
      delete key;
      }

    // Delete the singleton storing pointers to information keys.  See
    // ClassInitialize above for why this is a free instead of a
    // delete.
    vtkFilteringInformationKeyManagerKeys->~vector();
    free(vtkFilteringInformationKeyManagerKeys);
    vtkFilteringInformationKeyManagerKeys = 0;
    }
}<commit_msg>COMP: Work-around for Borland.  In order to directly call the destructor of the vector we need to subclass to give it a simple name.<commit_after>/*=========================================================================

  Program:   Visualization Toolkit
  Module:    vtkFilteringInformationKeyManager.cxx

  Copyright (c) <NAME>, <NAME>, <NAME>
  All rights reserved.
  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notice for more information.

=========================================================================*/
#include "vtkFilteringInformationKeyManager.h"

#include "vtkInformationKey.h"

#include <vtkstd/vector>

// Subclass vector so we can directly call constructor.  This works
// around problems on Borland C++.
struct vtkFilteringInformationKeyManagerKeysType:
  public vtkstd::vector<vtkInformationKey*>
{
  typedef vtkstd::vector<vtkInformationKey*> Superclass;
  typedef Superclass::iterator iterator;
};

//----------------------------------------------------------------------------
// Must NOT be initialized.  Default initialization to zero is
// necessary.
static unsigned int vtkFilteringInformationKeyManagerCount;
static vtkFilteringInformationKeyManagerKeysType* vtkFilteringInformationKeyManagerKeys;

//----------------------------------------------------------------------------
vtkFilteringInformationKeyManager::vtkFilteringInformationKeyManager()
{
  if(++vtkFilteringInformationKeyManagerCount == 1)
    {
    vtkFilteringInformationKeyManager::ClassInitialize();
    }
}

//----------------------------------------------------------------------------
vtkFilteringInformationKeyManager::~vtkFilteringInformationKeyManager()
{
  if(--vtkFilteringInformationKeyManagerCount == 0)
    {
    vtkFilteringInformationKeyManager::ClassFinalize();
    }
}

//----------------------------------------------------------------------------
void vtkFilteringInformationKeyManager::Register(vtkInformationKey* key)
{
  // Register this instance for deletion by the singleton.
  vtkFilteringInformationKeyManagerKeys->push_back(key);
}

//----------------------------------------------------------------------------
void vtkFilteringInformationKeyManager::ClassInitialize()
{
  // Allocate the singleton storing pointers to information keys.
  // This must be a malloc/free pair instead of new/delete to work
  // around problems on MachO (Mac OSX) runtime systems that do lazy
  // symbol loading.  Calling operator new here causes static
  // initialization to occur in other translation units immediately,
  // which then may try to access the vector before it is set here.
  void* keys = malloc(sizeof(vtkFilteringInformationKeyManagerKeysType));
  vtkFilteringInformationKeyManagerKeys =
    new (keys) vtkFilteringInformationKeyManagerKeysType;
}

//----------------------------------------------------------------------------
void vtkFilteringInformationKeyManager::ClassFinalize()
{
  if(vtkFilteringInformationKeyManagerKeys)
    {
    // Delete information keys.
    for(vtkFilteringInformationKeyManagerKeysType::iterator i =
          vtkFilteringInformationKeyManagerKeys->begin();
        i != vtkFilteringInformationKeyManagerKeys->end(); ++i)
      {
      vtkInformationKey* key = *i;
      delete key;
      }

    // Delete the singleton storing pointers to information keys.  See
    // ClassInitialize above for why this is a free instead of a
    // delete.
    vtkFilteringInformationKeyManagerKeys->~vtkFilteringInformationKeyManagerKeysType();
    free(vtkFilteringInformationKeyManagerKeys);
    vtkFilteringInformationKeyManagerKeys = 0;
    }
}
{'fraction_non_alphanumeric': 0.23661655191794295, 'fraction_numerical': 0.0008430518476886329, 'mean_word_length': 2.589510842158346, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '520902', 'n_tokens_mistral': 1664, 'n_tokens_neox': 1623, 'n_words': 448}