replace BAD with zBAD so it compiles on AIX
[rsync/rsync.git] / rsync.c
diff --git a/rsync.c b/rsync.c
index 555c009..bb19d4f 100644 (file)
--- a/rsync.c
+++ b/rsync.c
@@ -74,6 +74,7 @@ static int delete_file(char *fname)
        extern int force_delete;
        STRUCT_STAT st;
        int ret;
+       extern int recurse;
 
        if (do_unlink(fname) == 0 || errno == ENOENT) return 0;
 
@@ -93,7 +94,8 @@ static int delete_file(char *fname)
        }
 
        if (do_rmdir(fname) == 0 || errno == ENOENT) return 0;
-       if (!force_delete || (errno != ENOTEMPTY && errno != EEXIST)) {
+       if (!force_delete || !recurse || 
+           (errno != ENOTEMPTY && errno != EEXIST)) {
                rprintf(FERROR,"rmdir(%s) : %s\n", fname, strerror(errno));
                return -1;
        }
@@ -636,11 +638,7 @@ static void add_delete_entry(struct file_struct *file)
 {
        if (dlist_len == dlist_alloc_len) {
                dlist_alloc_len += 1024;
-               if (!delete_list) {
-                       delete_list = (struct delete_list *)malloc(sizeof(delete_list[0])*dlist_alloc_len);
-               } else {
-                       delete_list = (struct delete_list *)realloc(delete_list, sizeof(delete_list[0])*dlist_alloc_len);
-               }
+               delete_list = (struct delete_list *)Realloc(delete_list, sizeof(delete_list[0])*dlist_alloc_len);
                if (!delete_list) out_of_memory("add_delete_entry");
        }
 
@@ -964,7 +962,6 @@ void send_files(struct file_list *flist,int f_out,int f_in)
   int i;
   struct file_struct *file;
   int phase = 0;
-  int offset=0;
 
   if (verbose > 2)
     rprintf(FINFO,"send_files starting\n");
@@ -972,6 +969,8 @@ void send_files(struct file_list *flist,int f_out,int f_in)
   setup_readbuffer(f_in);
 
   while (1) {
+         int offset=0;
+
          i = read_int(f_in);
          if (i == -1) {
                  if (phase==0 && remote_version >= 13) {