1

use std::size_t

This commit is contained in:
2022-07-29 14:19:02 +02:00
parent f14fb63b01
commit fcab6677ac
2 changed files with 6 additions and 6 deletions

View File

@ -1,7 +1,7 @@
#include "Memory.h" #include "Memory.h"
void bse::memset(char* destination, const char value, const unsigned int bytes) { void bse::memset(char* destination, const char value, std::size_t bytes) {
for (unsigned int byte = 0; byte < bytes; ++byte) { for (std::size_t byte = 0; byte < bytes; ++byte) {
*(destination + byte) = value; *(destination + byte) = value;
} }
} }

View File

@ -1,26 +1,26 @@
#ifndef MYSTDLIB_INCLUDE_H_ #ifndef MYSTDLIB_INCLUDE_H_
#define MYSTDLIB_INCLUDE_H_ #define MYSTDLIB_INCLUDE_H_
#include <utility>
namespace bse { namespace bse {
// add using byte or sth to replace char // add using byte or sth to replace char
template<typename T> template<typename T>
void memcpy(T* destination, const T* source, const unsigned int count = 1) { void memcpy(T* destination, const T* source, std::size_t count = 1) {
for (unsigned int i = 0; i < count; ++i) { for (unsigned int i = 0; i < count; ++i) {
*(destination + i) = *(source + i); *(destination + i) = *(source + i);
} }
} }
void memset(char* destination, char value, unsigned int bytes); void memset(char* destination, char value, std::size_t bytes);
template<typename T> template<typename T>
void zero(T* destination) { void zero(T* destination) {
memset(reinterpret_cast<char*>(destination), '\0', sizeof(T)); memset(reinterpret_cast<char*>(destination), '\0', sizeof(T));
} }
// void strcpy(char* destination, char* source);
// unsigned int strlen(char* string);
} // namespace bse } // namespace bse
#endif #endif