diff --git a/ghc/lib/std/Directory.lhs b/ghc/lib/std/Directory.lhs
index 778ecad661a616535b287356703acea56c721bec..edd0e7ba3ab5a0833b2f1595d5e8e4fdeef264a3 100644
--- a/ghc/lib/std/Directory.lhs
+++ b/ghc/lib/std/Directory.lhs
@@ -337,15 +337,14 @@ The path refers to an existing non-directory object.
 --getDirectoryContents :: FilePath -> IO [FilePath]
 getDirectoryContents path = do
     dir <- _ccall_ openDir__ path
-    ptr <- _ccall_ malloc (``sizeof(struct dirent**)''::Int)
     if dir == ``NULL'' 
 	then constructErrorAndFail "getDirectoryContents"
-     	else loop dir ptr
+     	else loop dir
   where
-    loop :: Addr -> Addr -> IO [String]
-    loop dir dirent_ptr = do
+    loop :: Addr -> IO [String]
+    loop dir  = do
       dirent_ptr <- _ccall_ readDir__ dir
-      if dirent_ptr == ``NULL'' 
+      if (dirent_ptr::Addr) == ``NULL'' 
        then do
 	  return [] 
        else do
@@ -355,7 +354,7 @@ getDirectoryContents path = do
 	    -- calls to readdir() may overwrite it.
           len     <- _ccall_ strlen str
 	  entry   <- stToIO (unpackNBytesST str len)
-	  entries <- loop dir dirent_ptr
+	  entries <- loop dir
           return (entry:entries)
 \end{code}