summaryrefslogtreecommitdiffstats
path: root/tarWrite.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--tarWrite.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/tarWrite.c b/tarWrite.c
index f5af4491b..7d46014bd 100644
--- a/tarWrite.c
+++ b/tarWrite.c
@@ -29,11 +29,13 @@ int flush = 0, eot_count = -1;
unsigned char *write_buffer;
unsigned buffer_size = 4096;
unsigned buffer_loc = 0;
+int buffer_status = 0;
void reinit_libtar_buffer(void) {
flush = 0;
eot_count = -1;
buffer_loc = 0;
+ buffer_status = 1;
}
void init_libtar_buffer(unsigned new_buff_size) {
@@ -45,7 +47,9 @@ void init_libtar_buffer(unsigned new_buff_size) {
}
void free_libtar_buffer(void) {
- free(write_buffer);
+ if (buffer_status > 0)
+ free(write_buffer);
+ buffer_status = 0;
}
ssize_t write_libtar_buffer(int fd, const void *buffer, size_t size) {
@@ -89,4 +93,5 @@ ssize_t write_libtar_buffer(int fd, const void *buffer, size_t size) {
void flush_libtar_buffer(int fd) {
eot_count = 0;
+ buffer_status = 2;
}