New untested stuff, beware...

This commit is contained in:
Ognjen Milan Robovic 2023-09-12 10:15:13 -04:00
parent d3587d6351
commit 67170c507e
2 changed files with 62 additions and 1 deletions

View File

@ -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);
}

View File

@ -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);