Newer
Older
tree-os / src / kernel / util / util.c
@lukas lukas on 9 Mar 2022 596 bytes add file system: fat 16
#include <alloc.h>
#include <stdint.h>
#include <util.h>

uint32_t strlen(char *string) {
    uint32_t length = 0;
    while (string[length] != 0) {
        length++;
    }
    return length;
}

char *stringCombine(char *string1, char *string2) {
    uint16_t length1 = strlen(string1), length2 = strlen(string2);
    char *result = malloc(length1 + length2 + 1);
    result[length1 + length2] = 0;
    for (uint32_t i = 0; i < length1; i++) {
        result[i] = string1[i];
    }
    for (uint32_t i = 0; i < length2; i++) {
        result[length1 + i] = string2[i];
    }
    return result;
}