projects
/
libjh.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
c1adc47
)
fix file IO: void* instead of char*
author
Jann Horn
<jann@thejh.net>
Sat, 27 Jul 2013 10:21:37 +0000
(12:21 +0200)
committer
Jann Horn
<jann@thejh.net>
Sat, 27 Jul 2013 10:21:37 +0000
(12:21 +0200)
io.c
patch
|
blob
|
history
diff --git
a/io.c
b/io.c
index
ac685fb
..
d2b3197
100644
(file)
--- a/
io.c
+++ b/
io.c
@@
-67,7
+67,7
@@
PUBLIC_FN ssize_t write_nointr(int fd, void *buf, size_t count, int *last_res) {
PUBLIC_CONST JH_SLURP_NO_STAT 1
PUBLIC_CONST JH_SLURP_REALLOC 2 /* realloc result block if it saves RAM */
PUBLIC_CONST JH_SLURP_8BYTE_PAD 4 /* pad buffer with eight nullbytes, not one */
PUBLIC_CONST JH_SLURP_NO_STAT 1
PUBLIC_CONST JH_SLURP_REALLOC 2 /* realloc result block if it saves RAM */
PUBLIC_CONST JH_SLURP_8BYTE_PAD 4 /* pad buffer with eight nullbytes, not one */
-PUBLIC_FN
char
*slurp_fd(int fd, size_t *len_out, int flags) {
+PUBLIC_FN
void
*slurp_fd(int fd, size_t *len_out, int flags) {
int errno_;
// Let's just guess that the file is 1023 bytes. Will become 1024 with
int errno_;
// Let's just guess that the file is 1023 bytes. Will become 1024 with
@@
-120,7
+120,7
@@
PUBLIC_FN char *slurp_fd(int fd, size_t *len_out, int flags) {
}
}
}
}
-PUBLIC_FN
char
*slurp_file(char *path, size_t *len_out, int flags) {
+PUBLIC_FN
void
*slurp_file(char *path, size_t *len_out, int flags) {
int fd = open(path, O_RDONLY|O_CLOEXEC);
if (fd == -1) return NULL;
char *res = slurp_fd(fd, len_out, flags);
int fd = open(path, O_RDONLY|O_CLOEXEC);
if (fd == -1) return NULL;
char *res = slurp_fd(fd, len_out, flags);
@@
-132,7
+132,7
@@
PUBLIC_FN char *slurp_file(char *path, size_t *len_out, int flags) {
// Write data into a file. len can be -1; that means that
// the real length is strlen(buf).
// Write data into a file. len can be -1; that means that
// the real length is strlen(buf).
-PUBLIC_FN int write_file(char *path,
char
*buf, ssize_t len, int open_flags) {
+PUBLIC_FN int write_file(char *path,
void
*buf, ssize_t len, int open_flags) {
if (len == -1) len = strlen(buf);
int fd = open(path, open_flags|O_CLOEXEC|O_WRONLY, 0777);
if (len == -1) len = strlen(buf);
int fd = open(path, open_flags|O_CLOEXEC|O_WRONLY, 0777);