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.
|
the user is responsible for freeing it when finished.
|
||||||
|
|
||||||
```c
|
```c
|
||||||
char *get_input(const char *path);
|
unsigned char *get_input(const char *path);
|
||||||
|
|
||||||
/* Usage */
|
/* Usage */
|
||||||
char *str = get_input("/home/evan/textfile");
|
char *str = get_input("/home/evan/textfile");
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#include <stdlib.h>
|
#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 *);
|
char *get_input(const char *);
|
||||||
|
|
||||||
|
@ -26,14 +26,14 @@ static FILE* open_file(const char *path, size_t *fsz) {
|
|||||||
return fp;
|
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);
|
FILE *fp = open_file(path, fsz);
|
||||||
if (fp == NULL) {
|
if (fp == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *buf = NULL;
|
unsigned char *buf = NULL;
|
||||||
buf = malloc(*fsz);
|
buf = (unsigned char*)malloc(sizeof(unsigned char) * (*fsz));
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
fprintf(stderr, "Failed to malloc buf. Returning NULL\n");
|
fprintf(stderr, "Failed to malloc buf. Returning NULL\n");
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user