Prefix ox stdlib functions with ox_
This commit is contained in:
@@ -204,7 +204,7 @@ void FileStore<FsSize_t>::Inode::setId(InodeId_t id) {
|
||||
|
||||
template<typename FsSize_t>
|
||||
void FileStore<FsSize_t>::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<FsSize_t>::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<FsSize_t>::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<FsSize_t>::alloc(FsSize_t size) {
|
||||
|
||||
const auto retval = next;
|
||||
const auto inode = ptr<Inode*>(retval);
|
||||
memset(inode, 0, size);
|
||||
ox_memset(inode, 0, size);
|
||||
inode->prev = ptr<Inode*>(firstInode())->prev;
|
||||
inode->next = retval + size;
|
||||
ptr<Inode*>(firstInode())->prev = retval;
|
||||
@@ -436,7 +436,7 @@ void FileStore<FsSize_t>::compress(FsSize_t start) {
|
||||
auto dest = ptr<Inode*>(firstInode());
|
||||
auto current = ptr<Inode*>(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<FsSize_t>::version() {
|
||||
|
||||
template<typename FsSize_t>
|
||||
ox::std::uint8_t *FileStore<FsSize_t>::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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
};
|
||||
|
||||
+13
-13
@@ -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 {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user