mirror of
https://github.com/SFML/SFML.git
synced 2024-11-28 22:31:09 +08:00
Prefer C++ standard lib over C standard lib
This commit is contained in:
parent
6aabb75bcf
commit
6fa330d077
@ -40,6 +40,8 @@
|
|||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
|
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
@ -109,7 +111,7 @@ bool ImageLoader::loadImageFromFile(const std::filesystem::path& filename, std::
|
|||||||
{
|
{
|
||||||
// Copy the loaded pixels to the pixel buffer
|
// Copy the loaded pixels to the pixel buffer
|
||||||
pixels.resize(static_cast<std::size_t>(width * height * 4));
|
pixels.resize(static_cast<std::size_t>(width * height * 4));
|
||||||
memcpy(pixels.data(), ptr, pixels.size());
|
std::memcpy(pixels.data(), ptr, pixels.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Free the loaded pixels (they are now in our own pixel buffer)
|
// Free the loaded pixels (they are now in our own pixel buffer)
|
||||||
@ -154,7 +156,7 @@ bool ImageLoader::loadImageFromMemory(const void* data, std::size_t dataSize, st
|
|||||||
{
|
{
|
||||||
// Copy the loaded pixels to the pixel buffer
|
// Copy the loaded pixels to the pixel buffer
|
||||||
pixels.resize(static_cast<std::size_t>(width * height * 4));
|
pixels.resize(static_cast<std::size_t>(width * height * 4));
|
||||||
memcpy(pixels.data(), ptr, pixels.size());
|
std::memcpy(pixels.data(), ptr, pixels.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Free the loaded pixels (they are now in our own pixel buffer)
|
// Free the loaded pixels (they are now in our own pixel buffer)
|
||||||
@ -213,7 +215,7 @@ bool ImageLoader::loadImageFromStream(InputStream& stream, std::vector<std::uint
|
|||||||
{
|
{
|
||||||
// Copy the loaded pixels to the pixel buffer
|
// Copy the loaded pixels to the pixel buffer
|
||||||
pixels.resize(static_cast<std::size_t>(width * height * 4));
|
pixels.resize(static_cast<std::size_t>(width * height * 4));
|
||||||
memcpy(pixels.data(), ptr, pixels.size());
|
std::memcpy(pixels.data(), ptr, pixels.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Free the loaded pixels (they are now in our own pixel buffer)
|
// Free the loaded pixels (they are now in our own pixel buffer)
|
||||||
|
@ -500,7 +500,7 @@ JNIEXPORT void ANativeActivity_onCreate(ANativeActivity* activity, void* savedSt
|
|||||||
|
|
||||||
if (savedState != nullptr)
|
if (savedState != nullptr)
|
||||||
{
|
{
|
||||||
states->savedState = malloc(savedStateSize);
|
states->savedState = std::malloc(savedStateSize);
|
||||||
states->savedStateSize = savedStateSize;
|
states->savedStateSize = savedStateSize;
|
||||||
std::memcpy(states->savedState, savedState, savedStateSize);
|
std::memcpy(states->savedState, savedState, savedStateSize);
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,8 @@
|
|||||||
|
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
|
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
|
|
||||||
namespace sf::priv
|
namespace sf::priv
|
||||||
{
|
{
|
||||||
@ -91,7 +93,7 @@ void ClipboardImpl::setString(const String& text)
|
|||||||
|
|
||||||
if (stringHandle)
|
if (stringHandle)
|
||||||
{
|
{
|
||||||
memcpy(GlobalLock(stringHandle), text.toWideString().data(), stringSize);
|
std::memcpy(GlobalLock(stringHandle), text.toWideString().data(), stringSize);
|
||||||
GlobalUnlock(stringHandle);
|
GlobalUnlock(stringHandle);
|
||||||
SetClipboardData(CF_UNICODETEXT, stringHandle);
|
SetClipboardData(CF_UNICODETEXT, stringHandle);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user