Removed all manual memory management.
This commit is contained in:
parent
d6dcafbc90
commit
a4acac813e
39 changed files with 163 additions and 267 deletions
|
@ -33,6 +33,7 @@
|
|||
#include <SFML/System/Time.hpp>
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
|
||||
|
||||
namespace sf
|
||||
|
@ -217,13 +218,13 @@ private:
|
|||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
SoundFileReader* m_reader; ///< Reader that handles I/O on the file's format
|
||||
InputStream* m_stream; ///< Input stream used to access the file's data
|
||||
bool m_streamOwned; ///< Is the stream internal or external?
|
||||
Uint64 m_sampleOffset; ///< Sample Read Position
|
||||
Uint64 m_sampleCount; ///< Total number of samples in the file
|
||||
unsigned int m_channelCount; ///< Number of channels of the sound
|
||||
unsigned int m_sampleRate; ///< Number of samples per second
|
||||
std::unique_ptr<SoundFileReader> m_reader; ///< Reader that handles I/O on the file's format
|
||||
std::unique_ptr<InputStream> m_ownedStream; ///< The stream we own if any
|
||||
InputStream* m_stream; ///< Input stream used to access the file's data
|
||||
Uint64 m_sampleOffset; ///< Sample Read Position
|
||||
Uint64 m_sampleCount; ///< Total number of samples in the file
|
||||
unsigned int m_channelCount; ///< Number of channels of the sound
|
||||
unsigned int m_sampleRate; ///< Number of samples per second
|
||||
};
|
||||
|
||||
} // namespace sf
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include <SFML/Audio/Export.hpp>
|
||||
#include <SFML/System/NonCopyable.hpp>
|
||||
#include <string>
|
||||
#include <memory>
|
||||
|
||||
|
||||
namespace sf
|
||||
|
@ -93,7 +94,7 @@ private:
|
|||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
SoundFileWriter* m_writer; ///< Writer that handles I/O on the file's format
|
||||
std::unique_ptr<SoundFileWriter> m_writer; ///< Writer that handles I/O on the file's format
|
||||
};
|
||||
|
||||
} // namespace sf
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include <SFML/Audio/Export.hpp>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
|
||||
|
||||
namespace sf
|
||||
|
@ -95,7 +96,7 @@ public:
|
|||
/// \see createReaderFromMemory, createReaderFromStream
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static SoundFileReader* createReaderFromFilename(const std::string& filename);
|
||||
static std::unique_ptr<SoundFileReader> createReaderFromFilename(const std::string& filename);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Instantiate the right codec for the given file in memory
|
||||
|
@ -110,7 +111,7 @@ public:
|
|||
/// \see createReaderFromFilename, createReaderFromStream
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static SoundFileReader* createReaderFromMemory(const void* data, std::size_t sizeInBytes);
|
||||
static std::unique_ptr<SoundFileReader> createReaderFromMemory(const void* data, std::size_t sizeInBytes);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Instantiate the right codec for the given file in stream
|
||||
|
@ -124,7 +125,7 @@ public:
|
|||
/// \see createReaderFromFilename, createReaderFromMemory
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static SoundFileReader* createReaderFromStream(InputStream& stream);
|
||||
static std::unique_ptr<SoundFileReader> createReaderFromStream(InputStream& stream);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Instantiate the right writer for the given file on disk
|
||||
|
@ -136,7 +137,7 @@ public:
|
|||
/// \return A new sound file writer that can write given file, or null if no writer can handle it
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static SoundFileWriter* createWriterFromFilename(const std::string& filename);
|
||||
static std::unique_ptr<SoundFileWriter> createWriterFromFilename(const std::string& filename);
|
||||
|
||||
private:
|
||||
|
||||
|
@ -146,14 +147,14 @@ private:
|
|||
struct ReaderFactory
|
||||
{
|
||||
bool (*check)(InputStream&);
|
||||
SoundFileReader* (*create)();
|
||||
std::unique_ptr<SoundFileReader> (*create)();
|
||||
};
|
||||
typedef std::vector<ReaderFactory> ReaderFactoryArray;
|
||||
|
||||
struct WriterFactory
|
||||
{
|
||||
bool (*check)(const std::string&);
|
||||
SoundFileWriter* (*create)();
|
||||
std::unique_ptr<SoundFileWriter> (*create)();
|
||||
};
|
||||
typedef std::vector<WriterFactory> WriterFactoryArray;
|
||||
|
||||
|
|
|
@ -31,8 +31,8 @@ namespace sf
|
|||
{
|
||||
namespace priv
|
||||
{
|
||||
template <typename T> SoundFileReader* createReader() {return new T;}
|
||||
template <typename T> SoundFileWriter* createWriter() {return new T;}
|
||||
template <typename T> std::unique_ptr<SoundFileReader> createReader() {return std::make_unique<T>();}
|
||||
template <typename T> std::unique_ptr<SoundFileWriter> createWriter() {return std::make_unique<T>();}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
|
||||
|
||||
namespace sf
|
||||
|
@ -348,14 +349,14 @@ private:
|
|||
////////////////////////////////////////////////////////////
|
||||
void* m_library; ///< Pointer to the internal library interface (it is typeless to avoid exposing implementation details)
|
||||
void* m_face; ///< Pointer to the internal font face (it is typeless to avoid exposing implementation details)
|
||||
void* m_streamRec; ///< Pointer to the stream rec instance (it is typeless to avoid exposing implementation details)
|
||||
std::shared_ptr<void> m_streamRec; ///< Pointer to the stream rec instance (it is typeless to avoid exposing implementation details)
|
||||
void* m_stroker; ///< Pointer to the stroker (it is typeless to avoid exposing implementation details)
|
||||
int* m_refCount; ///< Reference counter used by implicit sharing
|
||||
std::shared_ptr<int> m_refCount; ///< Reference counter used by implicit sharing
|
||||
Info m_info; ///< Information about the font
|
||||
mutable PageTable m_pages; ///< Table containing the glyphs pages by character size
|
||||
mutable std::vector<Uint8> m_pixelBuffer; ///< Pixel buffer holding a glyph's pixels before being written to the texture
|
||||
#ifdef SFML_SYSTEM_ANDROID
|
||||
void* m_stream; ///< Asset file streamer (if loaded from file)
|
||||
std::shared_ptr<void> m_stream; ///< Asset file streamer (if loaded from file)
|
||||
#endif
|
||||
};
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
#include <SFML/Graphics/Rect.hpp>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace sf
|
||||
{
|
||||
|
@ -263,10 +263,10 @@ private:
|
|||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
Vector2u m_size; ///< Image size
|
||||
std::vector<Uint8> m_pixels; ///< Pixels of the image
|
||||
Vector2u m_size; ///< Image size
|
||||
std::vector<Uint8> m_pixels; ///< Pixels of the image
|
||||
#ifdef SFML_SYSTEM_ANDROID
|
||||
void* m_stream; ///< Asset file streamer (if loaded from file)
|
||||
std::shared_ptr<void> m_stream; ///< Asset file streamer (if loaded from file)
|
||||
#endif
|
||||
};
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include <SFML/Graphics/Export.hpp>
|
||||
#include <SFML/Graphics/Texture.hpp>
|
||||
#include <SFML/Graphics/RenderTarget.hpp>
|
||||
#include <memory>
|
||||
|
||||
|
||||
namespace sf
|
||||
|
@ -207,8 +208,8 @@ private:
|
|||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
priv::RenderTextureImpl* m_impl; ///< Platform/hardware specific implementation
|
||||
Texture m_texture; ///< Target texture to draw on
|
||||
std::unique_ptr<priv::RenderTextureImpl> m_impl; ///< Platform/hardware specific implementation
|
||||
Texture m_texture; ///< Target texture to draw on
|
||||
};
|
||||
|
||||
} // namespace sf
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
////////////////////////////////////////////////////////////
|
||||
#include <SFML/Network/Export.hpp>
|
||||
#include <SFML/System/Time.hpp>
|
||||
#include <memory>
|
||||
|
||||
|
||||
namespace sf
|
||||
|
@ -158,7 +159,7 @@ private:
|
|||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
SocketSelectorImpl* m_impl; ///< Opaque pointer to the implementation (which requires OS-specific types)
|
||||
std::unique_ptr<SocketSelectorImpl> m_impl; ///< Opaque pointer to the implementation (which requires OS-specific types)
|
||||
};
|
||||
|
||||
} // namespace sf
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include <SFML/System/NonCopyable.hpp>
|
||||
#include <cstdio>
|
||||
#include <string>
|
||||
#include <memory>
|
||||
|
||||
#ifdef ANDROID
|
||||
namespace sf
|
||||
|
@ -123,7 +124,7 @@ private:
|
|||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
#ifdef ANDROID
|
||||
priv::ResourceStream* m_file;
|
||||
std::unique_ptr<priv::ResourceStream> m_file;
|
||||
#else
|
||||
std::FILE* m_file; ///< stdio file stream
|
||||
#endif
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
////////////////////////////////////////////////////////////
|
||||
#include <SFML/System/Export.hpp>
|
||||
#include <SFML/System/NonCopyable.hpp>
|
||||
#include <memory>
|
||||
|
||||
|
||||
namespace sf
|
||||
|
@ -85,7 +86,7 @@ private:
|
|||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
priv::MutexImpl* m_mutexImpl; ///< OS-specific implementation
|
||||
std::shared_ptr<priv::MutexImpl> m_mutexImpl; ///< OS-specific implementation
|
||||
};
|
||||
|
||||
} // namespace sf
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include <SFML/System/Export.hpp>
|
||||
#include <SFML/System/NonCopyable.hpp>
|
||||
#include <cstdlib>
|
||||
#include <memory>
|
||||
|
||||
|
||||
namespace sf
|
||||
|
@ -186,8 +187,8 @@ private:
|
|||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
priv::ThreadImpl* m_impl; ///< OS-specific implementation of the thread
|
||||
priv::ThreadFunc* m_entryPoint; ///< Abstraction of the function to run
|
||||
std::shared_ptr<priv::ThreadImpl> m_impl; ///< OS-specific implementation of the thread
|
||||
std::shared_ptr<priv::ThreadFunc> m_entryPoint; ///< Abstraction of the function to run
|
||||
};
|
||||
|
||||
#include <SFML/System/Thread.inl>
|
||||
|
|
|
@ -66,8 +66,7 @@ struct ThreadMemberFunc : ThreadFunc
|
|||
////////////////////////////////////////////////////////////
|
||||
template <typename F>
|
||||
Thread::Thread(F functor) :
|
||||
m_impl (NULL),
|
||||
m_entryPoint(new priv::ThreadFunctor<F>(functor))
|
||||
m_entryPoint(std::make_shared<priv::ThreadFunctor<F>>(functor))
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -75,8 +74,7 @@ m_entryPoint(new priv::ThreadFunctor<F>(functor))
|
|||
////////////////////////////////////////////////////////////
|
||||
template <typename F, typename A>
|
||||
Thread::Thread(F function, A argument) :
|
||||
m_impl (NULL),
|
||||
m_entryPoint(new priv::ThreadFunctorWithArg<F, A>(function, argument))
|
||||
m_entryPoint(std::make_shared<priv::ThreadFunctorWithArg<F, A>>(function, argument))
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -84,7 +82,6 @@ m_entryPoint(new priv::ThreadFunctorWithArg<F, A>(function, argument))
|
|||
////////////////////////////////////////////////////////////
|
||||
template <typename C>
|
||||
Thread::Thread(void(C::*function)(), C* object) :
|
||||
m_impl (NULL),
|
||||
m_entryPoint(new priv::ThreadMemberFunc<C>(function, object))
|
||||
m_entryPoint(std::make_shared<priv::ThreadMemberFunc<C>>(function, object))
|
||||
{
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include <SFML/System/Export.hpp>
|
||||
#include <SFML/System/NonCopyable.hpp>
|
||||
#include <cstdlib>
|
||||
#include <memory>
|
||||
|
||||
|
||||
namespace sf
|
||||
|
@ -83,7 +84,7 @@ private:
|
|||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
priv::ThreadLocalImpl* m_impl; ///< Pointer to the OS specific implementation
|
||||
std::unique_ptr<priv::ThreadLocalImpl> m_impl; ///< Pointer to the OS specific implementation
|
||||
};
|
||||
|
||||
} // namespace sf
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include <SFML/Window/GlResource.hpp>
|
||||
#include <SFML/Window/ContextSettings.hpp>
|
||||
#include <SFML/System/NonCopyable.hpp>
|
||||
#include <memory>
|
||||
|
||||
|
||||
namespace sf
|
||||
|
@ -135,7 +136,7 @@ private:
|
|||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
priv::GlContext* m_context; ///< Internal OpenGL context
|
||||
std::unique_ptr<priv::GlContext> m_context; ///< Internal OpenGL context
|
||||
};
|
||||
|
||||
} // namespace sf
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include <SFML/System/Vector2.hpp>
|
||||
#include <SFML/System/NonCopyable.hpp>
|
||||
#include <SFML/System/String.hpp>
|
||||
#include <memory>
|
||||
|
||||
|
||||
namespace sf
|
||||
|
@ -522,11 +523,11 @@ private:
|
|||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
priv::WindowImpl* m_impl; ///< Platform-specific implementation of the window
|
||||
priv::GlContext* m_context; ///< Platform-specific implementation of the OpenGL context
|
||||
Clock m_clock; ///< Clock for measuring the elapsed time between frames
|
||||
Time m_frameTimeLimit; ///< Current framerate limit
|
||||
Vector2u m_size; ///< Current size of the window
|
||||
std::unique_ptr<priv::WindowImpl> m_impl; ///< Platform-specific implementation of the window
|
||||
std::unique_ptr<priv::GlContext> m_context; ///< Platform-specific implementation of the OpenGL context
|
||||
Clock m_clock; ///< Clock for measuring the elapsed time between frames
|
||||
Time m_frameTimeLimit; ///< Current framerate limit
|
||||
Vector2u m_size; ///< Current size of the window
|
||||
};
|
||||
|
||||
} // namespace sf
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue