From 56f3a9b9bf965bccad96505530175731674b135a Mon Sep 17 00:00:00 2001 From: Evan Burkey Date: Fri, 15 Dec 2023 13:08:22 -0800 Subject: [PATCH] change get_binary to unsigned char --- docs/input.md | 2 +- include/lfinput.h | 2 +- src/input.c | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/input.md b/docs/input.md index e2a6997..8537d0e 100644 --- a/docs/input.md +++ b/docs/input.md @@ -25,7 +25,7 @@ Reads a file at `path` and returns the contents as a single string. The string i the user is responsible for freeing it when finished. ```c -char *get_input(const char *path); +unsigned char *get_input(const char *path); /* Usage */ char *str = get_input("/home/evan/textfile"); diff --git a/include/lfinput.h b/include/lfinput.h index 2d6f3df..53ecb0c 100644 --- a/include/lfinput.h +++ b/include/lfinput.h @@ -3,7 +3,7 @@ #include -char *get_binary(const char *, size_t *fsz); +unsigned char *get_binary(const char *, size_t *fsz); char *get_input(const char *); diff --git a/src/input.c b/src/input.c index 0c07f52..f20b820 100644 --- a/src/input.c +++ b/src/input.c @@ -26,14 +26,14 @@ static FILE* open_file(const char *path, size_t *fsz) { return fp; } -char *get_binary(const char *path, size_t *fsz) { +unsigned char *get_binary(const char *path, size_t *fsz) { FILE *fp = open_file(path, fsz); if (fp == NULL) { return NULL; } - char *buf = NULL; - buf = malloc(*fsz); + unsigned char *buf = NULL; + buf = (unsigned char*)malloc(sizeof(unsigned char) * (*fsz)); if (buf == NULL) { fprintf(stderr, "Failed to malloc buf. Returning NULL\n"); fclose(fp);