change get_binary to unsigned char
This commit is contained in:
parent
d50611a198
commit
56f3a9b9bf
@ -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");
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
char *get_binary(const char *, size_t *fsz);
|
||||
unsigned char *get_binary(const char *, size_t *fsz);
|
||||
|
||||
char *get_input(const char *);
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user