ChangeLog, e2fsck.h, pass1.c, super.c:
  pass1.c (process_inode_cmp): Use EXT2_QSORT_TYPE to define the
  	appropriate return type for comparison functions for qsort.
  e2fsck.h: Add #ifdef protection for unistd.h
  super.c: Remove header files already included by e2fsck.h
ChangeLog, dblist.c, ext2fs.h:
  ext2fs.h: Define EXT2_QSORT_TYPE appropriately for the return type for
  	comparison functions for qsort.
  dblist.c (dir_block_cmp): Use EXT2_QSORT_TYPE in function declaration.
ChangeLog, extent.c:
  extent.c (ext2fs_create_extent_table): Use ext2fs_free_mem instead of
  	free().
  (extent_cmp): Use EXT2_QSORT_TYPE to define the appropriate return
  	type for comparison functions for qsort.

diff --git a/e2fsck/ChangeLog b/e2fsck/ChangeLog
index 298385e..e0a8e00 100644
--- a/e2fsck/ChangeLog
+++ b/e2fsck/ChangeLog
@@ -1,3 +1,12 @@
+1998-04-28  Theodore Ts'o  <tytso@rsts-11.mit.edu>
+
+	* pass1.c (process_inode_cmp): Use EXT2_QSORT_TYPE to define the
+		appropriate return type for comparison functions for qsort.
+
+	* e2fsck.h: Add #ifdef protection for unistd.h
+
+	* super.c: Remove header files already included by e2fsck.h
+
 1998-04-26  Theodore Ts'o  <tytso@rsts-11.mit.edu>
 
 	* dirinfo.c (e2fsck_add_dir_info): Update function to pass the old
diff --git a/e2fsck/e2fsck.h b/e2fsck/e2fsck.h
index efb7549..a3e3e58 100644
--- a/e2fsck/e2fsck.h
+++ b/e2fsck/e2fsck.h
@@ -8,7 +8,9 @@
 
 #include <stdio.h>
 #include <string.h>
+#ifdef HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 #include <stdlib.h>
 #include <time.h>
 #ifdef HAVE_SYS_TYPES_H
diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c
index 2e258d4..3efe086 100644
--- a/e2fsck/pass1.c
+++ b/e2fsck/pass1.c
@@ -62,7 +62,7 @@
 static void alloc_bb_map(e2fsck_t ctx);
 static void handle_fs_bad_blocks(e2fsck_t ctx);
 static void process_inodes(e2fsck_t ctx, char *block_buf);
-static int process_inode_cmp(const void *a, const void *b);
+static EXT2_QSORT_TYPE process_inode_cmp(const void *a, const void *b);
 static errcode_t scan_callback(ext2_filsys fs, ext2_inode_scan scan,
 				  dgrp_t group, void * priv_data);
 /* static char *describe_illegal_block(ext2_filsys fs, blk_t block); */
@@ -592,7 +592,7 @@
 	ehandler_operation(old_operation);
 }
 
-static int process_inode_cmp(const void *a, const void *b)
+static EXT2_QSORT_TYPE process_inode_cmp(const void *a, const void *b)
 {
 	const struct process_inode_block *ib_a =
 		(const struct process_inode_block *) a;
diff --git a/e2fsck/super.c b/e2fsck/super.c
index 62038be..f5dc7f2 100644
--- a/e2fsck/super.c
+++ b/e2fsck/super.c
@@ -9,22 +9,9 @@
  * %End-Header%
  */
 
-#include <stdio.h>
-#ifdef HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-#include <string.h>
-#include <time.h>
-#ifdef HAVE_GETOPT_H
-#include <getopt.h>
-#endif
-#include <unistd.h>
 #ifdef HAVE_ERRNO_H
 #include <errno.h>
 #endif
-#ifdef HAVE_MNTENT_H
-#include <mntent.h>
-#endif
 
 #ifndef EXT2_SKIP_UUID
 #include "uuid/uuid.h"
diff --git a/lib/ext2fs/ChangeLog b/lib/ext2fs/ChangeLog
index 9fcb3ce..80e054a 100644
--- a/lib/ext2fs/ChangeLog
+++ b/lib/ext2fs/ChangeLog
@@ -1,3 +1,11 @@
+1998-04-28  Theodore Ts'o  <tytso@rsts-11.mit.edu>
+
+	* ext2fs.h: Define EXT2_QSORT_TYPE appropriately for the
+		return type for comparison functions for qsort.
+
+	* dblist.c (dir_block_cmp): Use EXT2_QSORT_TYPE in function
+		declaration.
+
 1998-04-26  Theodore Ts'o  <tytso@rsts-11.mit.edu>
 
 	* ext2fs.h, bitops.h: Add support for the Watcom C compiler to do
diff --git a/lib/ext2fs/dblist.c b/lib/ext2fs/dblist.c
index 9683ef1..b636584 100644
--- a/lib/ext2fs/dblist.c
+++ b/lib/ext2fs/dblist.c
@@ -25,7 +25,7 @@
 
 #include "ext2fsP.h"
 
-static int dir_block_cmp(const void *a, const void *b);
+static EXT2_QSORT_TYPE dir_block_cmp(const void *a, const void *b);
 
 /*
  * Returns the number of directories in the filesystem as reported by
@@ -234,7 +234,7 @@
 }
 
 
-static int dir_block_cmp(const void *a, const void *b)
+static EXT2_QSORT_TYPE dir_block_cmp(const void *a, const void *b)
 {
 	const struct ext2_db_entry *db_a =
 		(const struct ext2_db_entry *) a;
diff --git a/lib/ext2fs/ext2fs.h b/lib/ext2fs/ext2fs.h
index 6c84517..83ca4df 100644
--- a/lib/ext2fs/ext2fs.h
+++ b/lib/ext2fs/ext2fs.h
@@ -66,6 +66,15 @@
 #include "ext2fs/ext2_err.h"
 #endif
 
+/*
+ * Portability help for Microsoft Visual C++
+ */
+#ifdef _MSC_VER
+#define EXT2_QSORT_TYPE int __cdecl
+#else
+#define EXT2_QSORT_TYPE int
+#endif
+
 typedef struct struct_ext2_filsys *ext2_filsys;
 
 struct ext2fs_struct_generic_bitmap {
diff --git a/resize/ChangeLog b/resize/ChangeLog
index 4b85202..1a632fb 100644
--- a/resize/ChangeLog
+++ b/resize/ChangeLog
@@ -1,3 +1,10 @@
+1998-04-28  Theodore Ts'o  <tytso@rsts-11.mit.edu>
+
+	* extent.c (ext2fs_create_extent_table): Use ext2fs_free_mem
+		instead of free().
+	  (extent_cmp): Use EXT2_QSORT_TYPE to define the appropriate
+		return type for comparison functions for qsort.
+
 1998-04-26  Theodore Ts'o  <tytso@rsts-11.mit.edu>
 
 	* resize2fs.c (adjust_superblock): 
diff --git a/resize/extent.c b/resize/extent.c
index b583baa..dbd6022 100644
--- a/resize/extent.c
+++ b/resize/extent.c
@@ -49,7 +49,7 @@
 	retval = ext2fs_get_mem(sizeof(struct ext2_extent_entry) *
 				extent->size, (void **) &extent->list);
 	if (retval) {
-		free(extent);
+		ext2fs_free_mem((void **) &extent);
 		return retval;
 	}
 	memset(extent->list, 0,
@@ -121,7 +121,7 @@
 /*
  * Helper function for qsort
  */
-static int extent_cmp(const void *a, const void *b)
+static EXT2_QSORT_TYPE extent_cmp(const void *a, const void *b)
 {
 	const struct ext2_extent_entry *db_a;
 	const struct ext2_extent_entry *db_b;