summaryrefslogtreecommitdiff
path: root/c_src/filebuffer.c
diff options
context:
space:
mode:
Diffstat (limited to 'c_src/filebuffer.c')
-rw-r--r--c_src/filebuffer.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/c_src/filebuffer.c b/c_src/filebuffer.c
index 4ba3501..2ca76de 100644
--- a/c_src/filebuffer.c
+++ b/c_src/filebuffer.c
@@ -76,10 +76,8 @@ void
bf_add(buffered_file *file, const void *data, uint64_t length)
{
sha256_update(&file->commit_checksum_context, length, data);
-#if DEBUG_WRITE
- fprintf(stderr, "adding data to %s: ", file->name);
- print_hex(data, length);
-#endif
+ dprintf(WRITE, (stderr, "adding data to %s: ", file->name));
+ dprinthex(WRITE, data, length);
uint64_t needspace = length + bf_unwritten_length(file);
if (needspace > file->writebufferalloc) {
@@ -132,9 +130,7 @@ bf_flush(buffered_file *file)
ret = fsync(file->fd);
sha256_init(&file->commit_checksum_context);
-#if DEBUG_WRITE
- fprintf(stderr, "clearing data for %s\n", file->name);
-#endif
+ dprintf(WRITE, (stderr, "clearing data for %s\n", file->name));
file->lastcommit = bf_total_length(file);
return ret;
}
@@ -143,9 +139,7 @@ unsigned char *
bf_read(buffered_file *file, uint64_t offset, size_t length, char **error)
{
unsigned char *result = malloc(length);
-#if DEBUG_READ
- fprintf(stderr, "reading data: offset %llu\n", offset);
-#endif
+ dprintf(READ, (stderr, "reading data: offset %llu\n", offset));
if (offset >= file->filesize) {
uint64_t writebufferoffset = offset - file->filesize;