diff --git a/c_os/user/lib/String.cc b/c_os/user/lib/String.cc index 25dee1a..e4855e8 100644 --- a/c_os/user/lib/String.cc +++ b/c_os/user/lib/String.cc @@ -1,20 +1,20 @@ #include "user/lib/String.h" #include "user/lib/mem/Memory.h" -unsigned int bse::strlen(const char* str) { +std::size_t bse::strlen(const char* str) { const char* current = str; while (*current != '\0') { ++current; } return current - str; } -void bse::strncpy(char* destination, unsigned int n, const char* source) { +void bse::strncpy(char* destination, std::size_t n, const char* source) { memcpy(destination, source, n); } // Only compares equal length strings int bse::strcmp(const char* a, const char* b) { - const unsigned int a_len = strlen(a); - const unsigned int b_len = strlen(b); + std::size_t a_len = strlen(a); + std::size_t b_len = strlen(b); if (a_len < b_len) { return -1; @@ -23,7 +23,7 @@ int bse::strcmp(const char* a, const char* b) { return 1; } - for (unsigned int i = 0; i < a_len; ++i) { + for (std::size_t i = 0; i < a_len; ++i) { if (a[i] < b[i]) { return -1; } diff --git a/c_os/user/lib/String.h b/c_os/user/lib/String.h index d81bdc9..9cc2b08 100644 --- a/c_os/user/lib/String.h +++ b/c_os/user/lib/String.h @@ -12,7 +12,7 @@ namespace bse { class string { private: - unsigned int len = 0; + std::size_t len = 0; char* buf = nullptr; public: @@ -25,9 +25,9 @@ namespace bse { } // Convert char array to string - template + template explicit string(const array& arr) : len(N), buf(new char[len + 1]) { - for (unsigned int i = 0; i < N; ++i) { + for (std::size_t i = 0; i < N; ++i) { buf[i] = arr[i]; } buf[N] = '\0'; @@ -68,8 +68,8 @@ namespace bse { delete[] buf; } - iterator begin() { return iterator(&buf[0]); } - iterator begin() const { return iterator(&buf[0]); } + iterator begin() { return iterator(buf); } + iterator begin() const { return iterator(buf); } iterator end() { return iterator(&buf[len]); } iterator end() const { return iterator(&buf[len]); } @@ -91,7 +91,7 @@ namespace bse { } string operator+(const char* other) const { - unsigned int other_len = strlen(other); + std::size_t other_len = strlen(other); string new_str; new_str.len = len + other_len; @@ -140,7 +140,7 @@ namespace bse { return strcmp(buf, other.buf) != 0; } - unsigned int size() const { + std::size_t size() const { return len; } };