Whamcloud - gitweb
LU-8465 e2fsck: merge icounts after thread finishes
[tools/e2fsprogs.git] / e2fsck / extend.c
index a1a4557..9d17e44 100644 (file)
@@ -1,19 +1,21 @@
 /*
  * extend.c --- extend a file so that it has at least a specified
  *     number of blocks.
- * 
+ *
  * Copyright (C) 1993, 1994, 1995 Theodore Ts'o.
  *
  * This file may be redistributed under the terms of the GNU Public
  * License.
  */
 
+#include "config.h"
 #include <stdio.h>
 #include <unistd.h>
 #include <stdlib.h>
 #include <string.h>
 #include <sys/types.h>
 #include <fcntl.h>
+#include "../misc/nls-enable.h"
 
 static void usage(char *progname)
 {
@@ -29,6 +31,7 @@ int main(int argc, char **argv)
        int     nblocks, blocksize;
        int     fd;
        char    *block;
+       errcode_t retval;
        int     ret;
 
        if (argc != 4)
@@ -43,13 +46,12 @@ int main(int argc, char **argv)
                exit(1);
        }
 
-       block = malloc(blocksize);
-       if (block == 0) {
+       retval = ext2fs_get_memzero(blocksize, &block);
+       if (retval) {
                fprintf(stderr, _("Couldn't allocate block buffer (size=%d)\n"),
                        blocksize);
                exit(1);
        }
-       memset(block, 0, blocksize);
 
        fd = open(filename, O_RDWR);
        if (fd < 0) {
@@ -76,5 +78,6 @@ int main(int argc, char **argv)
                perror("read");
                exit(1);
        }
-       exit(0);
+       ext2fs_free_mem(&block);
+       return(0);
 }