]> Dogcows Code - chaz/tar/commitdiff
(record_buffer): New var.
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 3 Aug 2004 04:43:38 +0000 (04:43 +0000)
committerPaul Eggert <eggert@cs.ucla.edu>
Tue, 3 Aug 2004 04:43:38 +0000 (04:43 +0000)
(open_archive): Don't use valloc; on older or buggy hosts, you can't
free the result.  Use page_aligned_alloc instead.
Record the pointer to be freed into record_buffer.
(close_archive): Free record_buffer.

src/buffer.c

index 80bbe829b4d031ed0ea7b47a527f818515550e4b..c1a88a3ee325245047c7dd62fce9c7adb19c4826 100644 (file)
@@ -40,6 +40,7 @@
 
 static tarlong prev_written;   /* bytes written on previous volumes */
 static tarlong bytes_written;  /* bytes written on this volume */
+static void *record_buffer;    /* allocated memory */
 
 /* FIXME: The following variables should ideally be static to this
    module.  However, this cannot be done yet.  The cleanup continues!  */
@@ -270,17 +271,12 @@ open_archive (enum access_mode wanted_access)
   save_name = 0;
   real_s_name = 0;
 
+  record_start =
+    page_aligned_alloc (&record_buffer,
+                       (record_size
+                        + (multi_volume_option ? 2 * BLOCKSIZE : 0)));
   if (multi_volume_option)
-    {
-      record_start = valloc (record_size + (2 * BLOCKSIZE));
-      if (record_start)
-       record_start += 2;
-    }
-  else
-    record_start = valloc (record_size);
-  if (!record_start)
-    FATAL_ERROR ((0, 0, _("Cannot allocate memory for blocking factor %d"),
-                 blocking_factor));
+    record_start += 2;
 
   current_block = record_start;
   record_end = record_start + blocking_factor;
@@ -946,7 +942,7 @@ close_archive (void)
     free (save_name);
   if (real_s_name)
     free (real_s_name);
-  free (multi_volume_option ? record_start - 2 : record_start);
+  free (record_buffer);
 }
 
 /* Called to initialize the global volume number.  */
This page took 0.026794 seconds and 4 git commands to generate.