Add missing check to ItemPtr and instantiate FileStore32 in FS library

This commit is contained in:
2018-03-13 01:55:25 -05:00
parent 9447967f12
commit 127c6525f7
19 changed files with 224 additions and 75 deletions

12
deps/ox/src/ox/std/new.hpp vendored Normal file
View 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;

View File

@@ -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"

View File

@@ -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;

View File

@@ -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) {

View File

@@ -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);

View File

@@ -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;
}