Many files:
  Added definition of ext2fs_get_mem, ext2fs_free_mem, and
  ext2fs_resize_mem in ext2fs.h, and changed all library routines to use
  these wrapper functions.

diff --git a/lib/ext2fs/block.c b/lib/ext2fs/block.c
index f938380..2946003 100644
--- a/lib/ext2fs/block.c
+++ b/lib/ext2fs/block.c
@@ -332,9 +332,10 @@
 	if (block_buf) {
 		ctx.ind_buf = block_buf;
 	} else {
-		ctx.ind_buf = malloc(fs->blocksize * 3);
-		if (!ctx.ind_buf)
-			return EXT2_NO_MEMORY;
+		retval = ext2fs_get_mem(fs->blocksize * 3,
+					(void **) &ctx.ind_buf);
+		if (retval)
+			return retval;
 	}
 	ctx.dind_buf = ctx.ind_buf + fs->blocksize;
 	ctx.tind_buf = ctx.dind_buf + fs->blocksize;
@@ -403,7 +404,7 @@
 	}
 
 	if (!block_buf)
-		free(ctx.ind_buf);
+		ext2fs_free_mem((void **) &ctx.ind_buf);
 
 	return (ret & BLOCK_ERROR) ? ctx.errcode : 0;
 }