diff --git a/src/ox/fs/filestore.hpp b/src/ox/fs/filestore.hpp index e07105b95..cd60fd3fa 100644 --- a/src/ox/fs/filestore.hpp +++ b/src/ox/fs/filestore.hpp @@ -204,7 +204,7 @@ void FileStore::Inode::setId(InodeId_t id) { template void FileStore::Inode::setData(void *data, FsSize_t size) { - memcpy(this->data(), data, size); + ox_memcpy(this->data(), data, size); dataLen = size; } @@ -311,7 +311,7 @@ void FileStore::unlink(Inode *inode) { prev->next = ptr(next); next->prev = ptr(prev); - memset(inode, 0, inode->size()); + ox_memset(inode, 0, inode->size()); inode->prev = firstInode(); inode->next = firstInode(); } @@ -336,7 +336,7 @@ int FileStore::read(InodeId_t id, void *data, FsSize_t *size) { if (size) { *size = inode->dataLen; } - memcpy(data, inode->data(), inode->dataLen); + ox_memcpy(data, inode->data(), inode->dataLen); retval = 0; } return retval; @@ -424,7 +424,7 @@ void *FileStore::alloc(FsSize_t size) { const auto retval = next; const auto inode = ptr(retval); - memset(inode, 0, size); + ox_memset(inode, 0, size); inode->prev = ptr(firstInode())->prev; inode->next = retval + size; ptr(firstInode())->prev = retval; @@ -436,7 +436,7 @@ void FileStore::compress(FsSize_t start) { auto dest = ptr(firstInode()); auto current = ptr(start); while (current->next > ptr(begin()) && current->next < ptr(end())) { - memcpy(dest, current, current->size()); + ox_memcpy(dest, current, current->size()); if (dest->next != firstInode()) { dest->next = ptr(dest) + dest->size(); } @@ -506,7 +506,7 @@ ox::std::uint8_t FileStore::version() { template ox::std::uint8_t *FileStore::format(ox::std::uint8_t *buffer, FsSize_t size, ox::std::uint32_t fsType) { - memset(buffer, 0, size); + ox_memset(buffer, 0, size); auto *fs = (FileStore*) buffer; fs->m_fsType = fsType; diff --git a/src/ox/fs/filesystem.hpp b/src/ox/fs/filesystem.hpp index 2a629eb56..ea0e3e7ee 100644 --- a/src/ox/fs/filesystem.hpp +++ b/src/ox/fs/filesystem.hpp @@ -62,8 +62,8 @@ class FileSystemTemplate: public FileSystem { void setName(const char *name) { auto data = getName(); - auto nameLen = strlen(name); - memcpy(data, &name, nameLen); + auto nameLen = ox_strlen(name); + ox_memcpy(data, &name, nameLen); data[nameLen] = 0; } }; diff --git a/src/ox/fs/oxfstool.cpp b/src/ox/fs/oxfstool.cpp index 7d32aeee4..d39ba4848 100644 --- a/src/ox/fs/oxfstool.cpp +++ b/src/ox/fs/oxfstool.cpp @@ -40,11 +40,11 @@ char *loadFileBuff(const char *path, ::size_t *sizeOut = nullptr) { } ox::std::uint64_t bytes(const char *str) { - auto size = ::strlen(str); + auto size = ::ox_strlen(str); const auto lastChar = str[size-1]; auto multiplier = 1; auto copy = new char[size]; - memcpy(copy, str, size); + ox_memcpy(copy, str, size); if (lastChar < '0' || lastChar > '9') { copy[size-1] = 0; switch (lastChar) { @@ -64,7 +64,7 @@ ox::std::uint64_t bytes(const char *str) { multiplier = -1; } } - const auto retval = ((ox::std::uint64_t) ::atoi(copy)) * multiplier; + const auto retval = ((ox::std::uint64_t) ::ox_atoi(copy)) * multiplier; delete copy; return retval; } @@ -73,7 +73,7 @@ int format(int argc, char **args) { printf("Creating file system...\n"); auto err = 0; if (argc >= 5) { - auto type = atoi(args[2]); + auto type = ox_atoi(args[2]); auto size = bytes(args[3]); auto path = args[4]; auto buff = (ox::std::uint8_t*) malloc(size); @@ -130,7 +130,7 @@ int read(int argc, char **args) { auto err = 1; if (argc >= 4) { auto fsPath = args[2]; - auto inode = atoi(args[3]); + auto inode = ox_atoi(args[3]); ::size_t fsSize; ox::std::uint64_t fileSize; @@ -163,7 +163,7 @@ int write(int argc, char **args) { auto err = 0; if (argc >= 5) { auto fsPath = args[2]; - auto inode = atoi(args[3]); + auto inode = ox_atoi(args[3]); auto srcPath = args[4]; ::size_t srcSize; @@ -221,7 +221,7 @@ int remove(int argc, char **args) { auto err = 1; if (argc >= 4) { auto fsPath = args[2]; - auto inode = atoi(args[3]); + auto inode = ox_atoi(args[3]); ::size_t fsSize; auto fsBuff = loadFileBuff(fsPath, &fsSize); @@ -264,17 +264,17 @@ int main(int argc, char **args) { auto err = 0; if (argc > 1) { auto cmd = args[1]; - if (strcmp(cmd, "format") == 0) { + if (ox_strcmp(cmd, "format") == 0) { err = format(argc, args); - } else if (strcmp(cmd, "read") == 0) { + } else if (ox_strcmp(cmd, "read") == 0) { err = read(argc, args); - } else if (strcmp(cmd, "write") == 0) { + } else if (ox_strcmp(cmd, "write") == 0) { err = write(argc, args); - } else if (strcmp(cmd, "rm") == 0) { + } else if (ox_strcmp(cmd, "rm") == 0) { err = remove(argc, args); - } else if (strcmp(cmd, "help") == 0) { + } else if (ox_strcmp(cmd, "help") == 0) { printf("%s\n", usage); - } else if (strcmp(cmd, "version") == 0) { + } else if (ox_strcmp(cmd, "version") == 0) { printf("oxfstool version %s\n", oxfstoolVersion); printf("oxfs format version %d\n", FileStore16::version()); } else { diff --git a/src/ox/fs/test/filestoreio.cpp b/src/ox/fs/test/filestoreio.cpp index 5e7dfa537..64fbd8c34 100644 --- a/src/ox/fs/test/filestoreio.cpp +++ b/src/ox/fs/test/filestoreio.cpp @@ -23,21 +23,21 @@ int test() { if (fs->write(1, (void*) "Hello", 6) || fs->read(1, (char*) out, &outSize) || - strcmp("Hello", out)) { + ox_strcmp("Hello", out)) { printf("Failure 1\n"); return 1; } if (fs->write(2, (void*) "World", 6) || fs->read(2, (char*) out, &outSize) || - strcmp("World", out)) { + ox_strcmp("World", out)) { printf("Failure 2\n"); return 2; } // make sure first value was not overwritten if (fs->read(1, (char*) out, &outSize) || - strcmp("Hello", out)) { + ox_strcmp("Hello", out)) { printf("Failure 3\n"); return 3; } @@ -56,7 +56,7 @@ int test() { // make sure 2 is still available if (fs->write(2, (void*) "World", 6) || fs->read(2, (char*) out, &outSize) || - strcmp("World", out)) { + ox_strcmp("World", out)) { printf("Failure 6\n"); return 6; } diff --git a/src/ox/std/memops.cpp b/src/ox/std/memops.cpp index 2f90fc77b..fc91a3664 100644 --- a/src/ox/std/memops.cpp +++ b/src/ox/std/memops.cpp @@ -7,7 +7,7 @@ */ #include "memops.hpp" -void *memcpy(void *dest, void *src, size_t size) { +void *ox_memcpy(void *dest, const void *src, size_t size) { char *srcBuf = (char*) src; char *dstBuf = (char*) dest; for (size_t i = 0; i < size; i++) { @@ -16,7 +16,7 @@ void *memcpy(void *dest, void *src, size_t size) { return dest; } -void *memset(void *ptr, int val, size_t size) { +void *ox_memset(void *ptr, int val, size_t size) { char *buf = (char*) ptr; for (size_t i = 0; i < size; i++) { buf[i] = val; diff --git a/src/ox/std/memops.hpp b/src/ox/std/memops.hpp index 025eb7e03..490c2c3cb 100644 --- a/src/ox/std/memops.hpp +++ b/src/ox/std/memops.hpp @@ -9,6 +9,6 @@ #include "types.hpp" -void *memcpy(void *src, void *dest, size_t size); +void *ox_memcpy(void *src, const void *dest, size_t size); -void *memset(void *ptr, int val, size_t size); +void *ox_memset(void *ptr, int val, size_t size); diff --git a/src/ox/std/strops.cpp b/src/ox/std/strops.cpp index 62e5f39c8..bd34e46f2 100644 --- a/src/ox/std/strops.cpp +++ b/src/ox/std/strops.cpp @@ -8,7 +8,7 @@ #include "strops.hpp" -int strcmp(const char *str1, const char *str2) { +int ox_strcmp(const char *str1, const char *str2) { auto retval = 0; auto i = 0; do { @@ -24,17 +24,17 @@ int strcmp(const char *str1, const char *str2) { return retval; } -size_t strlen(const char *str1) { +size_t ox_strlen(const char *str1) { int len; for (len = 0; str1[len]; len++); return len; } -int atoi(const char *str) { +int ox_atoi(const char *str) { int total = 0; int multiplier = 1; - for (size_t i = strlen(str) - 1; i >= 0; i--) { + for (size_t i = ox_strlen(str) - 1; i >= 0; i--) { total += (str[i] - '0') * multiplier; multiplier *= 10; } diff --git a/src/ox/std/strops.hpp b/src/ox/std/strops.hpp index 2e81d9822..b67eaff39 100644 --- a/src/ox/std/strops.hpp +++ b/src/ox/std/strops.hpp @@ -9,8 +9,8 @@ #include "types.hpp" -int strcmp(const char *str1, const char *str2); +int ox_strcmp(const char *str1, const char *str2); -size_t strlen(const char *str1); +size_t ox_strlen(const char *str1); -int atoi(const char *str); +int ox_atoi(const char *str);