<commit_before>#ifndef __SLSHAREDMEMORYOBJECT__
#define __SLSHAREDMEMORYOBJECT__
#pragma once

#include <memory>

namespace slutil
{ 
	/// <summary>SSE aligned memory allocation/deallocation for Image Processing </summary>
	class SLAlignedMemoryBuffer
	{
	public:
		SLAlignedMemoryBuffer() {};
		explicit SLAlignedMemoryBuffer(unsigned long long totalBytes, unsigned int alignment);
		~SLAlignedMemoryBuffer();
		void AllocateAlignedMemory(unsigned long long totalBytes, unsigned int alignment);

		BYTE* m_BufferEntry = nullptr;

		/// <remarks>m_InstanceCounter counts whenever SLAlignedMemoryBuffer Allocated/Freed</remarks>
		static int m_InstanceCounter;	
	};

	//--------------------------- SLAlignedMemoryBuffer -----------------------------------------------------------------
	//============================================================================================================
	//--------------------------- SLSharedMemoryObject -----------------------------------------------------------------

	/// <summary>Use SLAlignedMemoryBuffer to automatically handle allocate/de-allocate</summary>
	class SLSharedMemoryObject
	{
	public:
		SLSharedMemoryObject(); // Default constructor here for class member initialization
		explicit SLSharedMemoryObject(unsigned long long totalBytes, unsigned int alignment);
		virtual ~SLSharedMemoryObject() {};

		virtual void Reset();

		inline bool IsNull() const { return (m_SharedBuffer == nullptr || m_SharedBuffer->m_BufferEntry == nullptr); }
		BYTE* GetBufferEntryForEdit() { return m_SharedBuffer->m_BufferEntry; }
		const BYTE* GetBufferEntry() const { return const_cast<const BYTE*>(m_SharedBuffer->m_BufferEntry); }
		const unsigned long long GetTotalBytes() const { return m_TotalBytes; }

	protected:
		std::shared_ptr<SLAlignedMemoryBuffer> m_SharedBuffer;
		unsigned long long m_TotalBytes = 0;

		void CreateSharedMemory(unsigned long long totalBytes, unsigned int alignment);
	};


} // End of namespace slutil

#endif //__SLSHAREDMEMORYOBJECT__<commit_msg>Fix nullptr return value in case of crash<commit_after>#ifndef __SLSHAREDMEMORYOBJECT__
#define __SLSHAREDMEMORYOBJECT__
#pragma once

#include <memory>

namespace slutil
{ 
	/// <summary>SSE aligned memory allocation/deallocation for Image Processing </summary>
	class SLAlignedMemoryBuffer
	{
	public:
		SLAlignedMemoryBuffer() {};
		explicit SLAlignedMemoryBuffer(unsigned long long totalBytes, unsigned int alignment);
		~SLAlignedMemoryBuffer();
		void AllocateAlignedMemory(unsigned long long totalBytes, unsigned int alignment);

		BYTE* m_BufferEntry = nullptr;

		/// <remarks>m_InstanceCounter counts whenever SLAlignedMemoryBuffer Allocated/Freed</remarks>
		static int m_InstanceCounter;	
	};

	//--------------------------- SLAlignedMemoryBuffer -----------------------------------------------------------------
	//============================================================================================================
	//--------------------------- SLSharedMemoryObject -----------------------------------------------------------------

	/// <summary>Use SLAlignedMemoryBuffer to automatically handle allocate/de-allocate</summary>
	class SLSharedMemoryObject
	{
	public:
		SLSharedMemoryObject(); // Default constructor here for class member initialization
		explicit SLSharedMemoryObject(unsigned long long totalBytes, unsigned int alignment);
		virtual ~SLSharedMemoryObject() {};

		virtual void Reset();

		inline bool IsNull() const { return (m_SharedBuffer == nullptr || m_SharedBuffer->m_BufferEntry == nullptr); }
		BYTE* GetBufferEntryForEdit() { return m_SharedBuffer != nullptr ? m_SharedBuffer->m_BufferEntry : nullptr; }
		const BYTE* GetBufferEntry() const { return m_SharedBuffer != nullptr ? const_cast<const BYTE*>(m_SharedBuffer->m_BufferEntry) : nullptr; }
		const unsigned long long GetTotalBytes() const { return m_TotalBytes; }

	protected:
		std::shared_ptr<SLAlignedMemoryBuffer> m_SharedBuffer;
		unsigned long long m_TotalBytes = 0;

		void CreateSharedMemory(unsigned long long totalBytes, unsigned int alignment);
	};


} // End of namespace slutil

#endif //__SLSHAREDMEMORYOBJECT__
{'fraction_non_alphanumeric': 0.21452621452621454, 'fraction_numerical': 0.000481000481000481, 'mean_word_length': 3.600663716814159, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 27, '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': '7051140', 'n_tokens_mistral': 1071, 'n_tokens_neox': 1002, 'n_words': 276}