aboutsummaryrefslogtreecommitdiff
path: root/src/utils.c
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2022-01-09 21:47:23 +0100
committerHampusM <hampus@hampusmat.com>2022-01-09 21:47:23 +0100
commit8ceb79db1d0687bba005cef4a77bb889bf7ec3c3 (patch)
treeb7c13359f652506d60c8556ea386ae8d50bfc5bc /src/utils.c
parent097aa95c1f0cb159e7d9d0a3edf9284c421ee298 (diff)
refactor: rewrite to c++
Diffstat (limited to 'src/utils.c')
-rw-r--r--src/utils.c45
1 files changed, 0 insertions, 45 deletions
diff --git a/src/utils.c b/src/utils.c
deleted file mode 100644
index fa33cb0..0000000
--- a/src/utils.c
+++ /dev/null
@@ -1,45 +0,0 @@
-#include "utils.h"
-#include <ctype.h>
-#include <limits.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-void *malloc_s(unsigned long amount)
-{
- void *memory = malloc(amount);
-
- if (memory == NULL)
- {
- printf("Error: Memory allocation failed");
- exit(EXIT_FAILURE);
- }
-
- return memory;
-}
-
-unsigned int str_to_uint(char *str, char **err)
-{
- if (*str == '-')
- {
- *err = "Less than 0";
- return 0;
- }
-
- char *str_waste;
- unsigned long num = strtoul(str, &str_waste, 10);
-
- if (strlen(str_waste) != 0UL)
- {
- *err = "Not a number";
- return 0;
- }
-
- if (num > (unsigned long)UINT_MAX)
- {
- *err = "Too large";
- return 0;
- }
-
- return (unsigned int)num;
-}