diff --git a/xtandard.c b/xtandard.c index 569497f..94c9170 100644 --- a/xtandard.c +++ b/xtandard.c @@ -520,6 +520,62 @@ int string_split_space (char * string) { return (++count); } +void memory_delete (void * memory, int length) { + int i = 0; + + char * cast = (char *) memory; + + fatal_failure (memory == NULL, "memory_delete: Memory is null pointer."); + + if (length <= 0) { + return; + } + + for (i = 0; i != length; ++i) { + cast [i] = '\0'; + } +} + +int memory_compare (void * memory, void * source, int length) { + int i = 0; + + char * cast_0 = (char *) memory; + char * cast_1 = (char *) source; + + fatal_failure (memory == NULL, "memory_compare: Memory is null pointer."); + fatal_failure (source == NULL, "memory_compare: Source is null pointer."); + + if (length <= 0) { + return; + } + + for (i = 0; (cast_0 [i] != '\0') && (cast_1 [i] != '\0'); ++i) { + if (cast_0 [i] != cast_1 [i]) { + return (0); + } + } + + return (1); +} + +void memory_copy (void * memory, void * source, int length) { + int i = 0; + + char * cast_0 = (char *) memory; + char * cast_1 = (char *) source; + + fatal_failure (memory == NULL, "memory_copy: Memory is null pointer."); + fatal_failure (source == NULL, "memory_copy: Source is null pointer."); + + if (length <= 0) { + return; + } + + for (i = 0; i != length; ++i) { + cast_0 [i] = cast_1 [i]; + } +} + void terminal_clear (void) { out ("\033[2J\033[H", 7); } diff --git a/xtandard.h b/xtandard.h index d2779cb..532963b 100644 --- a/xtandard.h +++ b/xtandard.h @@ -96,7 +96,7 @@ extern int character_compare_array (char, char *, int); extern int string_length (char *); extern void string_reverse (char *); -extern void string_delete (char *, int); +extern void string_delete (char *, int); extern int string_compare (char *, char *); extern void string_copy (char *, char *); @@ -108,6 +108,11 @@ extern void string_concatenate_limit (char *, char *, int); extern int string_split_space (char *); +extern void memory_delete (void *, int); + +extern int memory_compare (void *, void *, int); +extern void memory_copy (void *, void *, int); + extern void terminal_clear (void); extern void terminal_style (int, int); extern void terminal_show_cursor (int);