Add missing check to ItemPtr and instantiate FileStore32 in FS library
This commit is contained in:
12
deps/ox/src/ox/std/new.hpp
vendored
Normal file
12
deps/ox/src/ox/std/new.hpp
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
* Copyright 2015 - 2018 gtalent2@gmail.com
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "types.hpp"
|
||||
|
||||
void* operator new(std::size_t, void*) noexcept;
|
1
deps/ox/src/ox/std/std.hpp
vendored
1
deps/ox/src/ox/std/std.hpp
vendored
@@ -13,6 +13,7 @@
|
||||
#include "byteswap.hpp"
|
||||
#include "math.hpp"
|
||||
#include "memops.hpp"
|
||||
#include "new.hpp"
|
||||
#include "random.hpp"
|
||||
#include "strops.hpp"
|
||||
#include "string.hpp"
|
||||
|
16
deps/ox/src/ox/std/string.hpp
vendored
16
deps/ox/src/ox/std/string.hpp
vendored
@@ -39,6 +39,8 @@ class BString {
|
||||
|
||||
char *data();
|
||||
|
||||
const char *c_str() noexcept;
|
||||
|
||||
/**
|
||||
* Returns the number of characters in this string.
|
||||
*/
|
||||
@@ -92,11 +94,11 @@ const BString<size> &BString<size>::operator=(char *str) {
|
||||
template<size_t size>
|
||||
const BString<size> &BString<size>::operator+=(const char *str) {
|
||||
size_t strLen = ox_strlen(str) + 1;
|
||||
auto currentSize = size();
|
||||
if (cap() < currentSize + strLen) {
|
||||
strLen = cap() - currentSize;
|
||||
auto currentLen = len();
|
||||
if (cap() < currentLen + strLen) {
|
||||
strLen = cap() - currentLen;
|
||||
}
|
||||
ox_memcpy(m_buff + currentSize, str, strLen);
|
||||
ox_memcpy(m_buff + currentLen, str, strLen);
|
||||
// make sure last element is a null terminator
|
||||
m_buff[cap() - 1] = 0;
|
||||
return *this;
|
||||
@@ -126,6 +128,12 @@ char *BString<buffLen>::data() {
|
||||
return (char*) m_buff;
|
||||
}
|
||||
|
||||
template<size_t buffLen>
|
||||
const char *BString<buffLen>::c_str() noexcept {
|
||||
return (const char*) m_buff;
|
||||
}
|
||||
|
||||
|
||||
template<size_t buffLen>
|
||||
size_t BString<buffLen>::len() {
|
||||
size_t length = 0;
|
||||
|
12
deps/ox/src/ox/std/strops.cpp
vendored
12
deps/ox/src/ox/std/strops.cpp
vendored
@@ -26,18 +26,6 @@ int ox_strcmp(const char *str1, const char *str2) {
|
||||
return retval;
|
||||
}
|
||||
|
||||
int ox_strlen(const char *str1) {
|
||||
int len;
|
||||
for (len = 0; str1[len]; len++);
|
||||
return len;
|
||||
}
|
||||
|
||||
int ox_strlen(char *str1) {
|
||||
int len;
|
||||
for (len = 0; str1[len]; len++);
|
||||
return len;
|
||||
}
|
||||
|
||||
const char *ox_strchr(const char *str, int character, size_t maxLen) {
|
||||
for (size_t i = 0; i <= maxLen; i++) {
|
||||
if (str[i] == character) {
|
||||
|
12
deps/ox/src/ox/std/strops.hpp
vendored
12
deps/ox/src/ox/std/strops.hpp
vendored
@@ -13,9 +13,17 @@
|
||||
|
||||
int ox_strcmp(const char *str1, const char *str2);
|
||||
|
||||
int ox_strlen(const char *str1);
|
||||
constexpr int ox_strlen(const char *str1) {
|
||||
int len = 0;
|
||||
for (; str1[len]; len++);
|
||||
return len;
|
||||
}
|
||||
|
||||
int ox_strlen(char *str1);
|
||||
constexpr int ox_strlen(char *str1) {
|
||||
int len = 0;
|
||||
for (; str1[len]; len++);
|
||||
return len;
|
||||
}
|
||||
|
||||
const char *ox_strchr(const char *str, int character, size_t maxLen = 0xFFFFFFFF);
|
||||
|
||||
|
3
deps/ox/src/ox/std/types.hpp
vendored
3
deps/ox/src/ox/std/types.hpp
vendored
@@ -25,8 +25,6 @@ typedef long int64_t;
|
||||
typedef unsigned long uint64_t;
|
||||
typedef int64_t intmax_t;
|
||||
typedef uint64_t uintmax_t;
|
||||
typedef int64_t intptr_t;
|
||||
typedef uint64_t uintptr_t;
|
||||
#endif
|
||||
|
||||
namespace ox {
|
||||
@@ -54,6 +52,7 @@ typedef uint32_t uintptr_t;
|
||||
namespace std {
|
||||
|
||||
typedef decltype(nullptr) nullptr_t;
|
||||
typedef ::size_t size_t;
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user