add some rudimentary memory manipulation functions
This commit is contained in:
7
c_os/lib/MyStdLib.cc
Normal file
7
c_os/lib/MyStdLib.cc
Normal 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
24
c_os/lib/MyStdLib.h
Executable 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
|
||||
Reference in New Issue
Block a user