<commit_before>/*! \file FunctionAllocator.h
 *  \author <NAME>
 *  \brief Defines the interface to a 
 *         singleton class for allocating
 *         lots of small types.
 */

#ifndef FUNCTION_ALLOCATOR_H
#define FUNCTION_ALLOCATOR_H

#include <vector>
#include "exportShading.h"

// XXX this is nasty: kill it
#ifndef WIN32
#define DLLAPI
#endif // WIN32

class FunctionAllocator
{
  public:
    /*! Null constructor allocates a huge number of
     *  slots in mStorage.
     */
    FunctionAllocator(void);

    /*! Constructor accepts the number of slots to allocate.
     *  \param n The number of slots to allocate.
     */
    FunctionAllocator(const size_t n);

    /*! This method invalidates all Blocks currently allocated
     *  and resizes the number of slots.
     *  \param n The number of slots to allocate.
     */
    void reserve(const size_t n);
    
    /*! This method allocates memory for a new
     *  shading function object.
     *  \return A pointer to a newly allocated chunk of memory
     *          large enough to accomodate a shading function.
     */
    void *malloc(void);

    /*! This method deallocates all the currently
     *  allocated memory.
     */
    void freeAll(void);

    template<unsigned int size>
      struct DLLAPI Accomodator
    {
      unsigned char mFill[size];
    }; // end Accomodator

    typedef Accomodator<9 * sizeof(size_t)> Block;

  protected:

#ifdef WIN32
    // EXPORT/IMPORT std::vector stuff
    template class DLLAPI std::allocator<Block>;
    template class DLLAPI std::vector<Block>;
#endif // WIN32

    std::vector<Block> mStorage;
}; // end FunctionAllocator

#endif // FUNCTION_ALLOCATOR_H
<commit_msg>The previous implementation wasn't portable to 32b.<commit_after>/*! \file FunctionAllocator.h
 *  \author <NAME>
 *  \brief Defines the interface to a 
 *         singleton class for allocating
 *         lots of small types.
 */

#ifndef FUNCTION_ALLOCATOR_H
#define FUNCTION_ALLOCATOR_H

#include <vector>
#include "exportShading.h"

// XXX this is nasty: kill it
#ifndef WIN32
#define DLLAPI
#endif // WIN32

class FunctionAllocator
{
  public:
    /*! Null constructor allocates a huge number of
     *  slots in mStorage.
     */
    FunctionAllocator(void);

    /*! Constructor accepts the number of slots to allocate.
     *  \param n The number of slots to allocate.
     */
    FunctionAllocator(const size_t n);

    /*! This method invalidates all Blocks currently allocated
     *  and resizes the number of slots.
     *  \param n The number of slots to allocate.
     */
    void reserve(const size_t n);
    
    /*! This method allocates memory for a new
     *  shading function object.
     *  \return A pointer to a newly allocated chunk of memory
     *          large enough to accomodate a shading function.
     */
    void *malloc(void);

    /*! This method deallocates all the currently
     *  allocated memory.
     */
    void freeAll(void);

    template<unsigned int size>
      struct DLLAPI Accomodator
    {
      unsigned char mFill[size];
    }; // end Accomodator

    typedef Accomodator<18 * sizeof(int)> Block;

  protected:

#ifdef WIN32
    // EXPORT/IMPORT std::vector stuff
    template class DLLAPI std::allocator<Block>;
    template class DLLAPI std::vector<Block>;
#endif // WIN32

    std::vector<Block> mStorage;
}; // end FunctionAllocator

#endif // FUNCTION_ALLOCATOR_H

{'fraction_non_alphanumeric': 0.08611599297012303, 'fraction_numerical': 0.006151142355008787, 'mean_word_length': 2.6563169164882225, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '7630597', 'n_tokens_mistral': 1013, 'n_tokens_neox': 980, 'n_words': 352}