From 54d5ba67489b3fdaf437c05675eb9b1f6d085a84 Mon Sep 17 00:00:00 2001 From: Marc Pervaz Boocha Date: Thu, 7 Apr 2022 19:33:30 +0530 Subject: Initial commit --- memory/strcoll.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 memory/strcoll.c (limited to 'memory/strcoll.c') diff --git a/memory/strcoll.c b/memory/strcoll.c new file mode 100644 index 0000000..2b7bde7 --- /dev/null +++ b/memory/strcoll.c @@ -0,0 +1,28 @@ +#include "memory.h" + +struct array_container { + char *string; + size_t lenght; +}; + +int strcoll(char const *string1, char const *string2) +{ + char const *string[2] = {string1, string2}; + struct array_container normalized[2]; + + for (size_t i = 0; i < ((sizeof normalized) / (sizeof normalized[0])); + i++) { + normalized[i].lenght = 1 + _strxfrm_wrap(NULL, string[i], 0); + normalized[i].string = reallocarray( + NULL, normalized[i].lenght, sizeof *(normalized[i].string)); + _strxfrm_wrap(normalized[i].string, string[i], + normalized[i].lenght); + } + + int res = strcmp(normalized[0].string, normalized[1].string); + + for (size_t i = 0; i < ((sizeof normalized) / (sizeof normalized[0])); + i++) + _free_wrap(normalized[i].string); + return res; +} -- cgit v1.2.3-70-g09d2