1

add some rudimentary memory manipulation functions

This commit is contained in:
churl
2022-05-09 14:02:30 +02:00
parent 333d5930a5
commit 27d8f13b5e
2 changed files with 31 additions and 0 deletions

7
c_os/lib/MyStdLib.cc Normal file
View File

@ -0,0 +1,7 @@
#include "MyStdLib.h"
void mymemset(char* destination, char value, unsigned int bytes) {
for (unsigned int byte = 0; byte < bytes; ++byte) {
*(destination + byte) = value;
}
}

24
c_os/lib/MyStdLib.h Executable file
View File

@ -0,0 +1,24 @@
#ifndef __MYSTDLIB_INCLUDE_H_
#define __MYSTDLIB_INCLUDE_H_
// NOTE: I added this file
// TODO: namespace this
template<typename T>
void mymemcpy(T* destination, T* source, unsigned int count) {
for (unsigned int i = 0; i < count; ++i) {
*(destination + i) = *(source + i);
}
}
void mymemset(char* destination, char value, unsigned int bytes);
template<typename T>
void myzero(T* destination) {
mymemset((char*)destination, '\0', sizeof(T));
}
void mystrcpy(char* destination, char* source);
unsigned int mystrlen(char* string);
#endif